From 06ef4cddf78c79c010cf32f358fa7b2cc91a84ae Mon Sep 17 00:00:00 2001 From: Thomas Wuerthinger Date: Thu, 21 Mar 2013 09:27:54 +0100 Subject: [PATCH 01/52] 7153771: array bound check elimination for c1 When possible optimize out array bound checks, inserting predicates when needed. Reviewed-by: never, kvn, twisti --- .../src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp | 38 +- .../cpu/sparc/vm/c1_LIRAssembler_sparc.cpp | 39 + .../cpu/sparc/vm/c1_LIRGenerator_sparc.cpp | 11 +- .../src/cpu/sparc/vm/c1_Runtime1_sparc.cpp | 19 + hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp | 33 +- .../src/cpu/x86/vm/c1_LIRAssembler_x86.cpp | 38 + .../src/cpu/x86/vm/c1_LIRGenerator_x86.cpp | 12 +- hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp | 3 +- hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp | 18 + hotspot/src/share/vm/c1/c1_Canonicalizer.cpp | 2 + hotspot/src/share/vm/c1/c1_Canonicalizer.hpp | 2 + hotspot/src/share/vm/c1/c1_CodeStubs.hpp | 16 + hotspot/src/share/vm/c1/c1_Compilation.cpp | 54 +- hotspot/src/share/vm/c1/c1_Compilation.hpp | 13 + hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 28 +- hotspot/src/share/vm/c1/c1_GraphBuilder.hpp | 2 + hotspot/src/share/vm/c1/c1_IR.cpp | 94 +- hotspot/src/share/vm/c1/c1_IR.hpp | 7 +- hotspot/src/share/vm/c1/c1_Instruction.cpp | 96 +- hotspot/src/share/vm/c1/c1_Instruction.hpp | 145 +- .../src/share/vm/c1/c1_InstructionPrinter.cpp | 34 + .../src/share/vm/c1/c1_InstructionPrinter.hpp | 2 + hotspot/src/share/vm/c1/c1_LIR.cpp | 15 + hotspot/src/share/vm/c1/c1_LIR.hpp | 36 +- hotspot/src/share/vm/c1/c1_LIRAssembler.hpp | 3 + hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 137 +- hotspot/src/share/vm/c1/c1_LIRGenerator.hpp | 4 + hotspot/src/share/vm/c1/c1_LinearScan.cpp | 35 +- hotspot/src/share/vm/c1/c1_Optimizer.cpp | 11 +- .../share/vm/c1/c1_RangeCheckElimination.cpp | 1517 +++++++++++++++++ .../share/vm/c1/c1_RangeCheckElimination.hpp | 241 +++ hotspot/src/share/vm/c1/c1_Runtime1.cpp | 44 + hotspot/src/share/vm/c1/c1_Runtime1.hpp | 3 + hotspot/src/share/vm/c1/c1_ValueMap.cpp | 210 ++- hotspot/src/share/vm/c1/c1_ValueMap.hpp | 10 + hotspot/src/share/vm/c1/c1_globals.hpp | 18 + .../src/share/vm/compiler/compileBroker.cpp | 3 + hotspot/src/share/vm/oops/instanceKlass.cpp | 11 - hotspot/src/share/vm/oops/methodData.cpp | 8 + hotspot/src/share/vm/runtime/globals.hpp | 2 +- 40 files changed, 2861 insertions(+), 153 deletions(-) create mode 100644 hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp create mode 100644 hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp diff --git a/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp index 6d936b376e0..113665220ae 100644 --- a/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp @@ -51,6 +51,16 @@ RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); + if (_info->deoptimize_on_exception()) { + address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + __ call(a, relocInfo::runtime_call_type); + __ delayed()->nop(); + ce->add_call_info_here(_info); + ce->verify_oop_map(_info); + debug_only(__ should_not_reach_here()); + return; + } + if (_index->is_register()) { __ mov(_index->as_register(), G4); } else { @@ -64,11 +74,22 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ delayed()->nop(); ce->add_call_info_here(_info); ce->verify_oop_map(_info); -#ifdef ASSERT - __ should_not_reach_here(); -#endif + debug_only(__ should_not_reach_here()); } +PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { + _info = new CodeEmitInfo(info); +} + +void PredicateFailedStub::emit_code(LIR_Assembler* ce) { + __ bind(_entry); + address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + __ call(a, relocInfo::runtime_call_type); + __ delayed()->nop(); + ce->add_call_info_here(_info); + ce->verify_oop_map(_info); + debug_only(__ should_not_reach_here()); +} void CounterOverflowStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); @@ -99,10 +120,17 @@ void DivByZeroStub::emit_code(LIR_Assembler* ce) { void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { + address a; + if (_info->deoptimize_on_exception()) { + // Deoptimize, do not throw the exception, because it is probably wrong to do it here. + a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + } else { + a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); + } + ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); __ bind(_entry); - __ call(Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id), - relocInfo::runtime_call_type); + __ call(a, relocInfo::runtime_call_type); __ delayed()->nop(); ce->add_call_info_here(_info); ce->verify_oop_map(_info); diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp index 27bf44244b5..7c4c54ea37f 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @@ -3361,6 +3361,45 @@ void LIR_Assembler::get_thread(LIR_Opr result_reg) { __ mov(G2_thread, result_reg->as_register()); } +#ifdef ASSERT +// emit run-time assertion +void LIR_Assembler::emit_assert(LIR_OpAssert* op) { + assert(op->code() == lir_assert, "must be"); + + if (op->in_opr1()->is_valid()) { + assert(op->in_opr2()->is_valid(), "both operands must be valid"); + comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op); + } else { + assert(op->in_opr2()->is_illegal(), "both operands must be illegal"); + assert(op->condition() == lir_cond_always, "no other conditions allowed"); + } + + Label ok; + if (op->condition() != lir_cond_always) { + Assembler::Condition acond; + switch (op->condition()) { + case lir_cond_equal: acond = Assembler::equal; break; + case lir_cond_notEqual: acond = Assembler::notEqual; break; + case lir_cond_less: acond = Assembler::less; break; + case lir_cond_lessEqual: acond = Assembler::lessEqual; break; + case lir_cond_greaterEqual: acond = Assembler::greaterEqual; break; + case lir_cond_greater: acond = Assembler::greater; break; + case lir_cond_aboveEqual: acond = Assembler::greaterEqualUnsigned; break; + case lir_cond_belowEqual: acond = Assembler::lessEqualUnsigned; break; + default: ShouldNotReachHere(); + }; + __ br(acond, false, Assembler::pt, ok); + __ delayed()->nop(); + } + if (op->halt()) { + const char* str = __ code_string(op->msg()); + __ stop(str); + } else { + breakpoint(); + } + __ bind(ok); +} +#endif void LIR_Assembler::peephole(LIR_List* lir) { LIR_OpList* inst = lir->instructions_list(); diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp index 2d4b3a2f1d1..82cc696e8b7 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp @@ -324,7 +324,7 @@ void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { assert(x->is_pinned(),""); - bool needs_range_check = true; + bool needs_range_check = x->compute_needs_range_check(); bool use_length = x->length() != NULL; bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT; bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL || @@ -339,12 +339,9 @@ void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { array.load_item(); index.load_nonconstant(); - if (use_length) { - needs_range_check = x->compute_needs_range_check(); - if (needs_range_check) { - length.set_instruction(x->length()); - length.load_item(); - } + if (use_length && needs_range_check) { + length.set_instruction(x->length()); + length.load_item(); } if (needs_store_check) { value.load_item(); diff --git a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp index b8c838b1620..6723ef2c352 100644 --- a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp @@ -987,6 +987,25 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { break; #endif // INCLUDE_ALL_GCS + case predicate_failed_trap_id: + { + __ set_info("predicate_failed_trap", dont_gc_arguments); + OopMap* oop_map = save_live_registers(sasm); + + int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, predicate_failed_trap)); + + oop_maps = new OopMapSet(); + oop_maps->add_gc_map(call_offset, oop_map); + + DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); + assert(deopt_blob != NULL, "deoptimization blob must have been created"); + restore_live_registers(sasm); + __ restore(); + __ br(Assembler::always, false, Assembler::pt, deopt_blob->unpack_with_reexecution(), relocInfo::runtime_call_type); + __ delayed()->nop(); + } + break; + default: { __ set_info("unimplemented entry", dont_gc_arguments); __ save_frame(0); diff --git a/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp b/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp index 806bce01bfa..cef3cdbbeaa 100644 --- a/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp @@ -101,6 +101,15 @@ RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index, void RangeCheckStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); + if (_info->deoptimize_on_exception()) { + address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + __ call(RuntimeAddress(a)); + ce->add_call_info_here(_info); + ce->verify_oop_map(_info); + debug_only(__ should_not_reach_here()); + return; + } + // pass the array index on stack because all registers must be preserved if (_index->is_cpu_register()) { ce->store_parameter(_index->as_register(), 0); @@ -115,9 +124,22 @@ void RangeCheckStub::emit_code(LIR_Assembler* ce) { } __ call(RuntimeAddress(Runtime1::entry_for(stub_id))); ce->add_call_info_here(_info); + ce->verify_oop_map(_info); debug_only(__ should_not_reach_here()); } +PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) { + _info = new CodeEmitInfo(info); +} + +void PredicateFailedStub::emit_code(LIR_Assembler* ce) { + __ bind(_entry); + address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + __ call(RuntimeAddress(a)); + ce->add_call_info_here(_info); + ce->verify_oop_map(_info); + debug_only(__ should_not_reach_here()); +} void DivByZeroStub::emit_code(LIR_Assembler* ce) { if (_offset != -1) { @@ -414,10 +436,19 @@ void DeoptimizeStub::emit_code(LIR_Assembler* ce) { void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) { + address a; + if (_info->deoptimize_on_exception()) { + // Deoptimize, do not throw the exception, because it is probably wrong to do it here. + a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id); + } else { + a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id); + } + ce->compilation()->implicit_exception_table()->append(_offset, __ offset()); __ bind(_entry); - __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id))); + __ call(RuntimeAddress(a)); ce->add_call_info_here(_info); + ce->verify_oop_map(_info); debug_only(__ should_not_reach_here()); } diff --git a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp index 83146761cd2..a99d7939373 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @@ -3755,6 +3755,44 @@ void LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, } } +#ifdef ASSERT +// emit run-time assertion +void LIR_Assembler::emit_assert(LIR_OpAssert* op) { + assert(op->code() == lir_assert, "must be"); + + if (op->in_opr1()->is_valid()) { + assert(op->in_opr2()->is_valid(), "both operands must be valid"); + comp_op(op->condition(), op->in_opr1(), op->in_opr2(), op); + } else { + assert(op->in_opr2()->is_illegal(), "both operands must be illegal"); + assert(op->condition() == lir_cond_always, "no other conditions allowed"); + } + + Label ok; + if (op->condition() != lir_cond_always) { + Assembler::Condition acond = Assembler::zero; + switch (op->condition()) { + case lir_cond_equal: acond = Assembler::equal; break; + case lir_cond_notEqual: acond = Assembler::notEqual; break; + case lir_cond_less: acond = Assembler::less; break; + case lir_cond_lessEqual: acond = Assembler::lessEqual; break; + case lir_cond_greaterEqual: acond = Assembler::greaterEqual;break; + case lir_cond_greater: acond = Assembler::greater; break; + case lir_cond_belowEqual: acond = Assembler::belowEqual; break; + case lir_cond_aboveEqual: acond = Assembler::aboveEqual; break; + default: ShouldNotReachHere(); + } + __ jcc(acond, ok); + } + if (op->halt()) { + const char* str = __ code_string(op->msg()); + __ stop(str); + } else { + breakpoint(); + } + __ bind(ok); +} +#endif void LIR_Assembler::membar() { // QQQ sparc TSO uses this, diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp index 5ef14861966..6810ae54216 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @@ -263,7 +263,7 @@ void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { assert(x->is_pinned(),""); - bool needs_range_check = true; + bool needs_range_check = x->compute_needs_range_check(); bool use_length = x->length() != NULL; bool obj_store = x->elt_type() == T_ARRAY || x->elt_type() == T_OBJECT; bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL || @@ -278,12 +278,10 @@ void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { array.load_item(); index.load_nonconstant(); - if (use_length) { - needs_range_check = x->compute_needs_range_check(); - if (needs_range_check) { - length.set_instruction(x->length()); - length.load_item(); - } + if (use_length && needs_range_check) { + length.set_instruction(x->length()); + length.load_item(); + } if (needs_store_check) { value.load_item(); diff --git a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp index 7956a6af59f..baecb9df93d 100644 --- a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp @@ -675,7 +675,8 @@ void FpuStackAllocator::handle_op2(LIR_Op2* op2) { switch (op2->code()) { case lir_cmp: case lir_cmp_fd2i: - case lir_ucmp_fd2i: { + case lir_ucmp_fd2i: + case lir_assert: { assert(left->is_fpu_register(), "invalid LIR"); assert(right->is_fpu_register(), "invalid LIR"); diff --git a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp index d3ac75e4013..ff9c11d86f5 100644 --- a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp @@ -1807,6 +1807,24 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { break; #endif // INCLUDE_ALL_GCS + case predicate_failed_trap_id: + { + StubFrame f(sasm, "predicate_failed_trap", dont_gc_arguments); + + OopMap* map = save_live_registers(sasm, 1); + + int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, predicate_failed_trap)); + oop_maps = new OopMapSet(); + oop_maps->add_gc_map(call_offset, map); + restore_live_registers(sasm); + __ leave(); + DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); + assert(deopt_blob != NULL, "deoptimization blob must have been created"); + + __ jump(RuntimeAddress(deopt_blob->unpack_with_reexecution())); + } + break; + default: { StubFrame f(sasm, "unimplemented entry", dont_gc_arguments); __ movptr(rax, (int)id); diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp index 40ecd64900b..a4cda5f904f 100644 --- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp +++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp @@ -937,4 +937,6 @@ void Canonicalizer::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) {} void Canonicalizer::do_ProfileCall(ProfileCall* x) {} void Canonicalizer::do_ProfileInvoke(ProfileInvoke* x) {} void Canonicalizer::do_RuntimeCall(RuntimeCall* x) {} +void Canonicalizer::do_RangeCheckPredicate(RangeCheckPredicate* x) {} +void Canonicalizer::do_Assert(Assert* x) {} void Canonicalizer::do_MemBar(MemBar* x) {} diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp index d1eb55b07c7..b8bcfd7e65f 100644 --- a/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp +++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp @@ -107,6 +107,8 @@ class Canonicalizer: InstructionVisitor { virtual void do_ProfileInvoke (ProfileInvoke* x); virtual void do_RuntimeCall (RuntimeCall* x); virtual void do_MemBar (MemBar* x); + virtual void do_RangeCheckPredicate(RangeCheckPredicate* x); + virtual void do_Assert (Assert* x); }; #endif // SHARE_VM_C1_C1_CANONICALIZER_HPP diff --git a/hotspot/src/share/vm/c1/c1_CodeStubs.hpp b/hotspot/src/share/vm/c1/c1_CodeStubs.hpp index 9fbeb29b5a4..7235cd6c38a 100644 --- a/hotspot/src/share/vm/c1/c1_CodeStubs.hpp +++ b/hotspot/src/share/vm/c1/c1_CodeStubs.hpp @@ -166,6 +166,22 @@ class RangeCheckStub: public CodeStub { #endif // PRODUCT }; +// stub used when predicate fails and deoptimization is needed +class PredicateFailedStub: public CodeStub { + private: + CodeEmitInfo* _info; + + public: + PredicateFailedStub(CodeEmitInfo* info); + virtual void emit_code(LIR_Assembler* e); + virtual CodeEmitInfo* info() const { return _info; } + virtual void visit(LIR_OpVisitState* visitor) { + visitor->do_slow_case(_info); + } +#ifndef PRODUCT + virtual void print_name(outputStream* out) const { out->print("PredicateFailedStub"); } +#endif // PRODUCT +}; class DivByZeroStub: public CodeStub { private: diff --git a/hotspot/src/share/vm/c1/c1_Compilation.cpp b/hotspot/src/share/vm/c1/c1_Compilation.cpp index cc268ef1450..a8effa4bccf 100644 --- a/hotspot/src/share/vm/c1/c1_Compilation.cpp +++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp @@ -33,13 +33,16 @@ #include "c1/c1_ValueStack.hpp" #include "code/debugInfoRec.hpp" #include "compiler/compileLog.hpp" +#include "c1/c1_RangeCheckElimination.hpp" typedef enum { _t_compile, _t_setup, - _t_optimizeIR, _t_buildIR, + _t_optimize_blocks, + _t_optimize_null_checks, + _t_rangeCheckElimination, _t_emit_lir, _t_linearScan, _t_lirGeneration, @@ -52,8 +55,10 @@ typedef enum { static const char * timer_name[] = { "compile", "setup", - "optimizeIR", "buildIR", + "optimize_blocks", + "optimize_null_checks", + "rangeCheckElimination", "emit_lir", "linearScan", "lirGeneration", @@ -159,9 +164,9 @@ void Compilation::build_hir() { if (UseC1Optimizations) { NEEDS_CLEANUP // optimization - PhaseTraceTime timeit(_t_optimizeIR); + PhaseTraceTime timeit(_t_optimize_blocks); - _hir->optimize(); + _hir->optimize_blocks(); } _hir->verify(); @@ -180,13 +185,47 @@ void Compilation::build_hir() { _hir->compute_code(); if (UseGlobalValueNumbering) { - ResourceMark rm; + // No resource mark here! LoopInvariantCodeMotion can allocate ValueStack objects. int instructions = Instruction::number_of_instructions(); GlobalValueNumbering gvn(_hir); assert(instructions == Instruction::number_of_instructions(), "shouldn't have created an instructions"); } + _hir->verify(); + +#ifndef PRODUCT + if (PrintCFGToFile) { + CFGPrinter::print_cfg(_hir, "Before RangeCheckElimination", true, false); + } +#endif + + if (RangeCheckElimination) { + if (_hir->osr_entry() == NULL) { + PhaseTraceTime timeit(_t_rangeCheckElimination); + RangeCheckElimination::eliminate(_hir); + } + } + +#ifndef PRODUCT + if (PrintCFGToFile) { + CFGPrinter::print_cfg(_hir, "After RangeCheckElimination", true, false); + } +#endif + + if (UseC1Optimizations) { + // loop invariant code motion reorders instructions and range + // check elimination adds new instructions so do null check + // elimination after. + NEEDS_CLEANUP + // optimization + PhaseTraceTime timeit(_t_optimize_null_checks); + + _hir->eliminate_null_checks(); + } + + _hir->verify(); + // compute use counts after global value numbering _hir->compute_use_counts(); @@ -502,6 +541,7 @@ Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* metho , _next_id(0) , _next_block_id(0) , _code(buffer_blob) +, _has_access_indexed(false) , _current_instruction(NULL) #ifndef PRODUCT , _last_instruction_printed(NULL) @@ -567,7 +607,9 @@ void Compilation::print_timers() { tty->print_cr(" Detailed C1 Timings"); tty->print_cr(" Setup time: %6.3f s (%4.1f%%)", timers[_t_setup].seconds(), (timers[_t_setup].seconds() / total) * 100.0); tty->print_cr(" Build IR: %6.3f s (%4.1f%%)", timers[_t_buildIR].seconds(), (timers[_t_buildIR].seconds() / total) * 100.0); - tty->print_cr(" Optimize: %6.3f s (%4.1f%%)", timers[_t_optimizeIR].seconds(), (timers[_t_optimizeIR].seconds() / total) * 100.0); + float t_optimizeIR = timers[_t_optimize_blocks].seconds() + timers[_t_optimize_null_checks].seconds(); + tty->print_cr(" Optimize: %6.3f s (%4.1f%%)", t_optimizeIR, (t_optimizeIR / total) * 100.0); + tty->print_cr(" RCE: %6.3f s (%4.1f%%)", timers[_t_rangeCheckElimination].seconds(), (timers[_t_rangeCheckElimination].seconds() / total) * 100.0); tty->print_cr(" Emit LIR: %6.3f s (%4.1f%%)", timers[_t_emit_lir].seconds(), (timers[_t_emit_lir].seconds() / total) * 100.0); tty->print_cr(" LIR Gen: %6.3f s (%4.1f%%)", timers[_t_lirGeneration].seconds(), (timers[_t_lirGeneration].seconds() / total) * 100.0); tty->print_cr(" Linear Scan: %6.3f s (%4.1f%%)", timers[_t_linearScan].seconds(), (timers[_t_linearScan].seconds() / total) * 100.0); diff --git a/hotspot/src/share/vm/c1/c1_Compilation.hpp b/hotspot/src/share/vm/c1/c1_Compilation.hpp index 0a7373da875..897da9762cb 100644 --- a/hotspot/src/share/vm/c1/c1_Compilation.hpp +++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp @@ -26,8 +26,10 @@ #define SHARE_VM_C1_C1_COMPILATION_HPP #include "ci/ciEnv.hpp" +#include "ci/ciMethodData.hpp" #include "code/exceptionHandlerTable.hpp" #include "memory/resourceArea.hpp" +#include "runtime/deoptimization.hpp" class CompilationResourceObj; class XHandlers; @@ -85,6 +87,7 @@ class Compilation: public StackObj { LinearScan* _allocator; CodeOffsets _offsets; CodeBuffer _code; + bool _has_access_indexed; // compilation helpers void initialize(); @@ -140,6 +143,7 @@ class Compilation: public StackObj { C1_MacroAssembler* masm() const { return _masm; } CodeOffsets* offsets() { return &_offsets; } Arena* arena() { return _arena; } + bool has_access_indexed() { return _has_access_indexed; } // Instruction ids int get_next_id() { return _next_id++; } @@ -154,6 +158,7 @@ class Compilation: public StackObj { void set_has_fpu_code(bool f) { _has_fpu_code = f; } void set_has_unsafe_access(bool f) { _has_unsafe_access = f; } void set_would_profile(bool f) { _would_profile = f; } + void set_has_access_indexed(bool f) { _has_access_indexed = f; } // Add a set of exception handlers covering the given PC offset void add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers); // Statistics gathering @@ -233,6 +238,14 @@ class Compilation: public StackObj { return env()->comp_level() == CompLevel_full_profile && C1UpdateMethodData && C1ProfileCheckcasts; } + + // will compilation make optimistic assumptions that might lead to + // deoptimization and that the runtime will account for? + bool is_optimistic() const { + return !TieredCompilation && + (RangeCheckElimination || UseLoopInvariantCodeMotion) && + method()->method_data()->trap_count(Deoptimization::Reason_none) == 0; + } }; diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index 9491607adfa..8d7619eedd6 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -947,7 +947,9 @@ void GraphBuilder::store_local(ValueStack* state, Value x, int index) { void GraphBuilder::load_indexed(BasicType type) { - ValueStack* state_before = copy_state_for_exception(); + // In case of in block code motion in range check elimination + ValueStack* state_before = copy_state_indexed_access(); + compilation()->set_has_access_indexed(true); Value index = ipop(); Value array = apop(); Value length = NULL; @@ -961,7 +963,9 @@ void GraphBuilder::load_indexed(BasicType type) { void GraphBuilder::store_indexed(BasicType type) { - ValueStack* state_before = copy_state_for_exception(); + // In case of in block code motion in range check elimination + ValueStack* state_before = copy_state_indexed_access(); + compilation()->set_has_access_indexed(true); Value value = pop(as_ValueType(type)); Value index = ipop(); Value array = apop(); @@ -1179,7 +1183,9 @@ void GraphBuilder::if_node(Value x, If::Condition cond, Value y, ValueStack* sta BlockBegin* tsux = block_at(stream()->get_dest()); BlockBegin* fsux = block_at(stream()->next_bci()); bool is_bb = tsux->bci() < stream()->cur_bci() || fsux->bci() < stream()->cur_bci(); - Instruction *i = append(new If(x, cond, false, y, tsux, fsux, is_bb ? state_before : NULL, is_bb)); + // In case of loop invariant code motion or predicate insertion + // before the body of a loop the state is needed + Instruction *i = append(new If(x, cond, false, y, tsux, fsux, (is_bb || compilation()->is_optimistic()) ? state_before : NULL, is_bb)); assert(i->as_Goto() == NULL || (i->as_Goto()->sux_at(0) == tsux && i->as_Goto()->is_safepoint() == tsux->bci() < stream()->cur_bci()) || @@ -1294,7 +1300,9 @@ void GraphBuilder::table_switch() { BlockBegin* tsux = block_at(bci() + sw.dest_offset_at(0)); BlockBegin* fsux = block_at(bci() + sw.default_offset()); bool is_bb = tsux->bci() < bci() || fsux->bci() < bci(); - ValueStack* state_before = is_bb ? copy_state_before() : NULL; + // In case of loop invariant code motion or predicate insertion + // before the body of a loop the state is needed + ValueStack* state_before = copy_state_if_bb(is_bb); append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb)); } else { // collect successors @@ -1308,7 +1316,9 @@ void GraphBuilder::table_switch() { // add default successor if (sw.default_offset() < 0) has_bb = true; sux->at_put(i, block_at(bci() + sw.default_offset())); - ValueStack* state_before = has_bb ? copy_state_before() : NULL; + // In case of loop invariant code motion or predicate insertion + // before the body of a loop the state is needed + ValueStack* state_before = copy_state_if_bb(has_bb); Instruction* res = append(new TableSwitch(ipop(), sux, sw.low_key(), state_before, has_bb)); #ifdef ASSERT if (res->as_Goto()) { @@ -1336,7 +1346,9 @@ void GraphBuilder::lookup_switch() { BlockBegin* tsux = block_at(bci() + pair.offset()); BlockBegin* fsux = block_at(bci() + sw.default_offset()); bool is_bb = tsux->bci() < bci() || fsux->bci() < bci(); - ValueStack* state_before = is_bb ? copy_state_before() : NULL; + // In case of loop invariant code motion or predicate insertion + // before the body of a loop the state is needed + ValueStack* state_before = copy_state_if_bb(is_bb);; append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb)); } else { // collect successors & keys @@ -1353,7 +1365,9 @@ void GraphBuilder::lookup_switch() { // add default successor if (sw.default_offset() < 0) has_bb = true; sux->at_put(i, block_at(bci() + sw.default_offset())); - ValueStack* state_before = has_bb ? copy_state_before() : NULL; + // In case of loop invariant code motion or predicate insertion + // before the body of a loop the state is needed + ValueStack* state_before = copy_state_if_bb(has_bb); Instruction* res = append(new LookupSwitch(ipop(), sux, keys, state_before, has_bb)); #ifdef ASSERT if (res->as_Goto()) { diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp index 1eca297cd15..ae5afd4e04d 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp @@ -301,6 +301,8 @@ class GraphBuilder VALUE_OBJ_CLASS_SPEC { ValueStack* copy_state_exhandling(); ValueStack* copy_state_for_exception_with_bci(int bci); ValueStack* copy_state_for_exception(); + ValueStack* copy_state_if_bb(bool is_bb) { return (is_bb || compilation()->is_optimistic()) ? copy_state_before() : NULL; } + ValueStack* copy_state_indexed_access() { return compilation()->is_optimistic() ? copy_state_before() : copy_state_for_exception(); } // // Inlining support diff --git a/hotspot/src/share/vm/c1/c1_IR.cpp b/hotspot/src/share/vm/c1/c1_IR.cpp index 015874ac0d3..e9e73db0c06 100644 --- a/hotspot/src/share/vm/c1/c1_IR.cpp +++ b/hotspot/src/share/vm/c1/c1_IR.cpp @@ -182,13 +182,14 @@ bool IRScopeDebugInfo::should_reexecute() { // Implementation of CodeEmitInfo // Stack must be NON-null -CodeEmitInfo::CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers) +CodeEmitInfo::CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers, bool deoptimize_on_exception) : _scope(stack->scope()) , _scope_debug_info(NULL) , _oop_map(NULL) , _stack(stack) , _exception_handlers(exception_handlers) - , _is_method_handle_invoke(false) { + , _is_method_handle_invoke(false) + , _deoptimize_on_exception(deoptimize_on_exception) { assert(_stack != NULL, "must be non null"); } @@ -199,7 +200,8 @@ CodeEmitInfo::CodeEmitInfo(CodeEmitInfo* info, ValueStack* stack) , _scope_debug_info(NULL) , _oop_map(NULL) , _stack(stack == NULL ? info->_stack : stack) - , _is_method_handle_invoke(info->_is_method_handle_invoke) { + , _is_method_handle_invoke(info->_is_method_handle_invoke) + , _deoptimize_on_exception(info->_deoptimize_on_exception) { // deep copy of exception handlers if (info->_exception_handlers != NULL) { @@ -239,7 +241,7 @@ IR::IR(Compilation* compilation, ciMethod* method, int osr_bci) : } -void IR::optimize() { +void IR::optimize_blocks() { Optimizer opt(this); if (!compilation()->profile_branches()) { if (DoCEE) { @@ -257,6 +259,10 @@ void IR::optimize() { #endif } } +} + +void IR::eliminate_null_checks() { + Optimizer opt(this); if (EliminateNullChecks) { opt.eliminate_null_checks(); #ifndef PRODUCT @@ -429,6 +435,7 @@ class ComputeLinearScanOrder : public StackObj { BlockList _loop_end_blocks; // list of all loop end blocks collected during count_edges BitMap2D _loop_map; // two-dimensional bit set: a bit is set if a block is contained in a loop BlockList _work_list; // temporary list (used in mark_loops and compute_order) + BlockList _loop_headers; Compilation* _compilation; @@ -594,6 +601,7 @@ void ComputeLinearScanOrder::count_edges(BlockBegin* cur, BlockBegin* parent) { TRACE_LINEAR_SCAN(3, tty->print_cr("Block B%d is loop header of loop %d", cur->block_id(), _num_loops)); cur->set_loop_index(_num_loops); + _loop_headers.append(cur); _num_loops++; } @@ -656,6 +664,16 @@ void ComputeLinearScanOrder::clear_non_natural_loops(BlockBegin* start_block) { // -> this is not a natural loop, so ignore it TRACE_LINEAR_SCAN(2, tty->print_cr("Loop %d is non-natural, so it is ignored", i)); + BlockBegin *loop_header = _loop_headers.at(i); + assert(loop_header->is_set(BlockBegin::linear_scan_loop_header_flag), "Must be loop header"); + + for (int j = 0; j < loop_header->number_of_preds(); j++) { + BlockBegin *pred = loop_header->pred_at(j); + pred->clear(BlockBegin::linear_scan_loop_end_flag); + } + + loop_header->clear(BlockBegin::linear_scan_loop_header_flag); + for (int block_id = _max_block_id - 1; block_id >= 0; block_id--) { clear_block_in_loop(i, block_id); } @@ -729,9 +747,20 @@ void ComputeLinearScanOrder::compute_dominator(BlockBegin* cur, BlockBegin* pare } else if (!(cur->is_set(BlockBegin::linear_scan_loop_header_flag) && parent->is_set(BlockBegin::linear_scan_loop_end_flag))) { TRACE_LINEAR_SCAN(4, tty->print_cr("DOM: computing dominator of B%d: common dominator of B%d and B%d is B%d", cur->block_id(), parent->block_id(), cur->dominator()->block_id(), common_dominator(cur->dominator(), parent)->block_id())); - assert(cur->number_of_preds() > 1, ""); + // Does not hold for exception blocks + assert(cur->number_of_preds() > 1 || cur->is_set(BlockBegin::exception_entry_flag), ""); cur->set_dominator(common_dominator(cur->dominator(), parent)); } + + // Additional edge to xhandler of all our successors + // range check elimination needs that the state at the end of a + // block be valid in every block it dominates so cur must dominate + // the exception handlers of its successors. + int num_cur_xhandler = cur->number_of_exception_handlers(); + for (int j = 0; j < num_cur_xhandler; j++) { + BlockBegin* xhandler = cur->exception_handler_at(j); + compute_dominator(xhandler, parent); + } } @@ -898,7 +927,6 @@ void ComputeLinearScanOrder::compute_order(BlockBegin* start_block) { num_sux = cur->number_of_exception_handlers(); for (i = 0; i < num_sux; i++) { BlockBegin* sux = cur->exception_handler_at(i); - compute_dominator(sux, cur); if (ready_for_processing(sux)) { sort_into_work_list(sux); } @@ -918,8 +946,23 @@ bool ComputeLinearScanOrder::compute_dominators_iter() { BlockBegin* dominator = block->pred_at(0); int num_preds = block->number_of_preds(); - for (int i = 1; i < num_preds; i++) { - dominator = common_dominator(dominator, block->pred_at(i)); + + TRACE_LINEAR_SCAN(4, tty->print_cr("DOM: Processing B%d", block->block_id())); + + for (int j = 0; j < num_preds; j++) { + + BlockBegin *pred = block->pred_at(j); + TRACE_LINEAR_SCAN(4, tty->print_cr(" DOM: Subrocessing B%d", pred->block_id())); + + if (block->is_set(BlockBegin::exception_entry_flag)) { + dominator = common_dominator(dominator, pred); + int num_pred_preds = pred->number_of_preds(); + for (int k = 0; k < num_pred_preds; k++) { + dominator = common_dominator(dominator, pred->pred_at(k)); + } + } else { + dominator = common_dominator(dominator, pred); + } } if (dominator != block->dominator()) { @@ -946,6 +989,21 @@ void ComputeLinearScanOrder::compute_dominators() { // check that dominators are correct assert(!compute_dominators_iter(), "fix point not reached"); + + // Add Blocks to dominates-Array + int num_blocks = _linear_scan_order->length(); + for (int i = 0; i < num_blocks; i++) { + BlockBegin* block = _linear_scan_order->at(i); + + BlockBegin *dom = block->dominator(); + if (dom) { + assert(dom->dominator_depth() != -1, "Dominator must have been visited before"); + dom->dominates()->append(block); + block->set_dominator_depth(dom->dominator_depth() + 1); + } else { + block->set_dominator_depth(0); + } + } } @@ -1032,7 +1090,7 @@ void ComputeLinearScanOrder::verify() { BlockBegin* sux = cur->sux_at(j); assert(sux->linear_scan_number() >= 0 && sux->linear_scan_number() == _linear_scan_order->index_of(sux), "incorrect linear_scan_number"); - if (!cur->is_set(BlockBegin::linear_scan_loop_end_flag)) { + if (!sux->is_set(BlockBegin::backward_branch_target_flag)) { assert(cur->linear_scan_number() < sux->linear_scan_number(), "invalid order"); } if (cur->loop_depth() == sux->loop_depth()) { @@ -1044,7 +1102,7 @@ void ComputeLinearScanOrder::verify() { BlockBegin* pred = cur->pred_at(j); assert(pred->linear_scan_number() >= 0 && pred->linear_scan_number() == _linear_scan_order->index_of(pred), "incorrect linear_scan_number"); - if (!cur->is_set(BlockBegin::linear_scan_loop_header_flag)) { + if (!cur->is_set(BlockBegin::backward_branch_target_flag)) { assert(cur->linear_scan_number() > pred->linear_scan_number(), "invalid order"); } if (cur->loop_depth() == pred->loop_depth()) { @@ -1060,7 +1118,8 @@ void ComputeLinearScanOrder::verify() { } else { assert(cur->dominator() != NULL, "all but first block must have dominator"); } - assert(cur->number_of_preds() != 1 || cur->dominator() == cur->pred_at(0), "Single predecessor must also be dominator"); + // Assertion does not hold for exception handlers + assert(cur->number_of_preds() != 1 || cur->dominator() == cur->pred_at(0) || cur->is_set(BlockBegin::exception_entry_flag), "Single predecessor must also be dominator"); } // check that all loops are continuous @@ -1249,9 +1308,22 @@ class PredecessorValidator : public BlockClosure { } }; +class VerifyBlockBeginField : public BlockClosure { + +public: + + virtual void block_do(BlockBegin *block) { + for ( Instruction *cur = block; cur != NULL; cur = cur->next()) { + assert(cur->block() == block, "Block begin is not correct"); + } + } +}; + void IR::verify() { #ifdef ASSERT PredecessorValidator pv(this); + VerifyBlockBeginField verifier; + this->iterate_postorder(&verifier); #endif } diff --git a/hotspot/src/share/vm/c1/c1_IR.hpp b/hotspot/src/share/vm/c1/c1_IR.hpp index e1f4c15ebcc..bc57300c1f0 100644 --- a/hotspot/src/share/vm/c1/c1_IR.hpp +++ b/hotspot/src/share/vm/c1/c1_IR.hpp @@ -254,6 +254,7 @@ class CodeEmitInfo: public CompilationResourceObj { OopMap* _oop_map; ValueStack* _stack; // used by deoptimization (contains also monitors bool _is_method_handle_invoke; // true if the associated call site is a MethodHandle call site. + bool _deoptimize_on_exception; FrameMap* frame_map() const { return scope()->compilation()->frame_map(); } Compilation* compilation() const { return scope()->compilation(); } @@ -261,7 +262,7 @@ class CodeEmitInfo: public CompilationResourceObj { public: // use scope from ValueStack - CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers); + CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers, bool deoptimize_on_exception = false); // make a copy CodeEmitInfo(CodeEmitInfo* info, ValueStack* stack = NULL); @@ -272,6 +273,7 @@ class CodeEmitInfo: public CompilationResourceObj { IRScope* scope() const { return _scope; } XHandlers* exception_handlers() const { return _exception_handlers; } ValueStack* stack() const { return _stack; } + bool deoptimize_on_exception() const { return _deoptimize_on_exception; } void add_register_oop(LIR_Opr opr); void record_debug_info(DebugInformationRecorder* recorder, int pc_offset); @@ -309,7 +311,8 @@ class IR: public CompilationResourceObj { int max_stack() const { return top_scope()->max_stack(); } // expensive // ir manipulation - void optimize(); + void optimize_blocks(); + void eliminate_null_checks(); void compute_predecessors(); void split_critical_edges(); void compute_code(); diff --git a/hotspot/src/share/vm/c1/c1_Instruction.cpp b/hotspot/src/share/vm/c1/c1_Instruction.cpp index 985cb098e6f..a026b4cbea0 100644 --- a/hotspot/src/share/vm/c1/c1_Instruction.cpp +++ b/hotspot/src/share/vm/c1/c1_Instruction.cpp @@ -34,6 +34,15 @@ // Implementation of Instruction +int Instruction::dominator_depth() { + int result = -1; + if (block()) { + result = block()->dominator_depth(); + } + assert(result != -1 || this->as_Local(), "Only locals have dominator depth -1"); + return result; +} + Instruction::Condition Instruction::mirror(Condition cond) { switch (cond) { case eql: return eql; @@ -42,6 +51,8 @@ Instruction::Condition Instruction::mirror(Condition cond) { case leq: return geq; case gtr: return lss; case geq: return leq; + case aeq: return beq; + case beq: return aeq; } ShouldNotReachHere(); return eql; @@ -56,6 +67,8 @@ Instruction::Condition Instruction::negate(Condition cond) { case leq: return gtr; case gtr: return leq; case geq: return lss; + case aeq: assert(false, "Above equal cannot be negated"); + case beq: assert(false, "Below equal cannot be negated"); } ShouldNotReachHere(); return eql; @@ -70,10 +83,10 @@ void Instruction::update_exception_state(ValueStack* state) { } } - -Instruction* Instruction::prev(BlockBegin* block) { +// Prev without need to have BlockBegin +Instruction* Instruction::prev() { Instruction* p = NULL; - Instruction* q = block; + Instruction* q = block(); while (q != this) { assert(q != NULL, "this is not in the block's instruction list"); p = q; q = q->next(); @@ -122,15 +135,24 @@ void Instruction::print(InstructionPrinter& ip) { // perform constant and interval tests on index value bool AccessIndexed::compute_needs_range_check() { - Constant* clength = length()->as_Constant(); - Constant* cindex = index()->as_Constant(); - if (clength && cindex) { - IntConstant* l = clength->type()->as_IntConstant(); - IntConstant* i = cindex->type()->as_IntConstant(); - if (l && i && i->value() < l->value() && i->value() >= 0) { - return false; + + if (length()) { + + Constant* clength = length()->as_Constant(); + Constant* cindex = index()->as_Constant(); + if (clength && cindex) { + IntConstant* l = clength->type()->as_IntConstant(); + IntConstant* i = cindex->type()->as_IntConstant(); + if (l && i && i->value() < l->value() && i->value() >= 0) { + return false; + } } } + + if (!this->check_flag(NeedsRangeCheckFlag)) { + return false; + } + return true; } @@ -631,19 +653,25 @@ void BlockBegin::substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux) { // of the inserted block, without recomputing the values of the other blocks // in the CFG. Therefore the value of "depth_first_number" in BlockBegin becomes meaningless. BlockBegin* BlockBegin::insert_block_between(BlockBegin* sux) { - BlockBegin* new_sux = new BlockBegin(end()->state()->bci()); + int bci = sux->bci(); + // critical edge splitting may introduce a goto after a if and array + // bound check elimination may insert a predicate between the if and + // goto. The bci of the goto can't be the one of the if otherwise + // the state and bci are inconsistent and a deoptimization triggered + // by the predicate would lead to incorrect execution/a crash. + BlockBegin* new_sux = new BlockBegin(bci); // mark this block (special treatment when block order is computed) new_sux->set(critical_edge_split_flag); // This goto is not a safepoint. Goto* e = new Goto(sux, false); - new_sux->set_next(e, end()->state()->bci()); + new_sux->set_next(e, bci); new_sux->set_end(e); // setup states ValueStack* s = end()->state(); - new_sux->set_state(s->copy()); - e->set_state(s->copy()); + new_sux->set_state(s->copy(s->kind(), bci)); + e->set_state(s->copy(s->kind(), bci)); assert(new_sux->state()->locals_size() == s->locals_size(), "local size mismatch!"); assert(new_sux->state()->stack_size() == s->stack_size(), "stack size mismatch!"); assert(new_sux->state()->locks_size() == s->locks_size(), "locks size mismatch!"); @@ -960,15 +988,14 @@ void BlockEnd::set_begin(BlockBegin* begin) { BlockList* sux = NULL; if (begin != NULL) { sux = begin->successors(); - } else if (_begin != NULL) { + } else if (this->begin() != NULL) { // copy our sux list - BlockList* sux = new BlockList(_begin->number_of_sux()); - for (int i = 0; i < _begin->number_of_sux(); i++) { - sux->append(_begin->sux_at(i)); + BlockList* sux = new BlockList(this->begin()->number_of_sux()); + for (int i = 0; i < this->begin()->number_of_sux(); i++) { + sux->append(this->begin()->sux_at(i)); } } _sux = sux; - _begin = begin; } @@ -1008,7 +1035,38 @@ int Phi::operand_count() const { } } +#ifdef ASSERT +// Constructor of Assert +Assert::Assert(Value x, Condition cond, bool unordered_is_true, Value y) : Instruction(illegalType) + , _x(x) + , _cond(cond) + , _y(y) +{ + set_flag(UnorderedIsTrueFlag, unordered_is_true); + assert(x->type()->tag() == y->type()->tag(), "types must match"); + pin(); + stringStream strStream; + Compilation::current()->method()->print_name(&strStream); + + stringStream strStream1; + InstructionPrinter ip1(1, &strStream1); + ip1.print_instr(x); + + stringStream strStream2; + InstructionPrinter ip2(1, &strStream2); + ip2.print_instr(y); + + stringStream ss; + ss.print("Assertion %s %s %s in method %s", strStream1.as_string(), ip2.cond_name(cond), strStream2.as_string(), strStream.as_string()); + + _message = ss.as_string(); +} +#endif + +void RangeCheckPredicate::check_state() { + assert(state()->kind() != ValueStack::EmptyExceptionState && state()->kind() != ValueStack::ExceptionState, "will deopt with empty state"); +} void ProfileInvoke::state_values_do(ValueVisitor* f) { if (state() != NULL) state()->values_do(f); diff --git a/hotspot/src/share/vm/c1/c1_Instruction.hpp b/hotspot/src/share/vm/c1/c1_Instruction.hpp index 4fff026e0c2..b93525bf502 100644 --- a/hotspot/src/share/vm/c1/c1_Instruction.hpp +++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp @@ -110,6 +110,8 @@ class ProfileCall; class ProfileInvoke; class RuntimeCall; class MemBar; +class RangeCheckPredicate; +class Assert; // A Value is a reference to the instruction creating the value typedef Instruction* Value; @@ -210,6 +212,10 @@ class InstructionVisitor: public StackObj { virtual void do_ProfileInvoke (ProfileInvoke* x) = 0; virtual void do_RuntimeCall (RuntimeCall* x) = 0; virtual void do_MemBar (MemBar* x) = 0; + virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0; +#ifdef ASSERT + virtual void do_Assert (Assert* x) = 0; +#endif }; @@ -306,8 +312,9 @@ class Instruction: public CompilationResourceObj { void update_exception_state(ValueStack* state); - //protected: - public: + protected: + BlockBegin* _block; // Block that contains this instruction + void set_type(ValueType* type) { assert(type != NULL, "type must exist"); _type = type; @@ -342,6 +349,9 @@ class Instruction: public CompilationResourceObj { ThrowIncompatibleClassChangeErrorFlag, ProfileMDOFlag, IsLinkedInBlockFlag, + NeedsRangeCheckFlag, + InWorkListFlag, + DeoptimizeOnException, InstructionLastFlag }; @@ -351,7 +361,7 @@ class Instruction: public CompilationResourceObj { // 'globally' used condition values enum Condition { - eql, neq, lss, leq, gtr, geq + eql, neq, lss, leq, gtr, geq, aeq, beq }; // Instructions may be pinned for many reasons and under certain conditions @@ -381,6 +391,7 @@ class Instruction: public CompilationResourceObj { , _pin_state(0) , _type(type) , _next(NULL) + , _block(NULL) , _subst(NULL) , _flags(0) , _operand(LIR_OprFact::illegalOpr) @@ -399,11 +410,13 @@ class Instruction: public CompilationResourceObj { int printable_bci() const { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; } void set_printable_bci(int bci) { _printable_bci = bci; } #endif + int dominator_depth(); int use_count() const { return _use_count; } int pin_state() const { return _pin_state; } bool is_pinned() const { return _pin_state != 0 || PinAllInstructions; } ValueType* type() const { return _type; } - Instruction* prev(BlockBegin* block); // use carefully, expensive operation + BlockBegin *block() const { return _block; } + Instruction* prev(); // use carefully, expensive operation Instruction* next() const { return _next; } bool has_subst() const { return _subst != NULL; } Instruction* subst() { return _subst == NULL ? this : _subst->subst(); } @@ -432,6 +445,9 @@ class Instruction: public CompilationResourceObj { assert(as_BlockEnd() == NULL, "BlockEnd instructions must have no next"); assert(next->can_be_linked(), "shouldn't link these instructions into list"); + BlockBegin *block = this->block(); + next->_block = block; + next->set_flag(Instruction::IsLinkedInBlockFlag, true); _next = next; return next; @@ -444,6 +460,29 @@ class Instruction: public CompilationResourceObj { return set_next(next); } + // when blocks are merged + void fixup_block_pointers() { + Instruction *cur = next()->next(); // next()'s block is set in set_next + while (cur && cur->_block != block()) { + cur->_block = block(); + cur = cur->next(); + } + } + + Instruction *insert_after(Instruction *i) { + Instruction* n = _next; + set_next(i); + i->set_next(n); + return _next; + } + + Instruction *insert_after_same_bci(Instruction *i) { +#ifndef PRODUCT + i->set_printable_bci(printable_bci()); +#endif + return insert_after(i); + } + void set_subst(Instruction* subst) { assert(subst == NULL || type()->base() == subst->type()->base() || @@ -452,6 +491,7 @@ class Instruction: public CompilationResourceObj { } void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; } void set_exception_state(ValueStack* s) { check_state(s); _exception_state = s; } + void set_state_before(ValueStack* s) { check_state(s); _state_before = s; } // machine-specifics void set_operand(LIR_Opr operand) { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; } @@ -509,6 +549,11 @@ class Instruction: public CompilationResourceObj { virtual ExceptionObject* as_ExceptionObject() { return NULL; } virtual UnsafeOp* as_UnsafeOp() { return NULL; } virtual ProfileInvoke* as_ProfileInvoke() { return NULL; } + virtual RangeCheckPredicate* as_RangeCheckPredicate() { return NULL; } + +#ifdef ASSERT + virtual Assert* as_Assert() { return NULL; } +#endif virtual void visit(InstructionVisitor* v) = 0; @@ -570,7 +615,6 @@ class AssertValues: public ValueVisitor { LEAF(Phi, Instruction) private: - BlockBegin* _block; // the block to which the phi function belongs int _pf_flags; // the flags of the phi function int _index; // to value on operand stack (index < 0) or to local public: @@ -578,9 +622,9 @@ LEAF(Phi, Instruction) Phi(ValueType* type, BlockBegin* b, int index) : Instruction(type->base()) , _pf_flags(0) - , _block(b) , _index(index) { + _block = b; NOT_PRODUCT(set_printable_bci(Value(b)->printable_bci())); if (type->is_illegal()) { make_illegal(); @@ -603,8 +647,6 @@ LEAF(Phi, Instruction) Value operand_at(int i) const; int operand_count() const; - BlockBegin* block() const { return _block; } - void set(Flag f) { _pf_flags |= f; } void clear(Flag f) { _pf_flags &= ~f; } bool is_set(Flag f) const { return (_pf_flags & f) != 0; } @@ -670,6 +712,7 @@ LEAF(Constant, Instruction) pin(); } + // generic virtual bool can_trap() const { return state_before() != NULL; } virtual void input_values_do(ValueVisitor* f) { /* no values */ } @@ -852,6 +895,7 @@ BASE(AccessIndexed, AccessArray) , _length(length) , _elt_type(elt_type) { + set_flag(Instruction::NeedsRangeCheckFlag, true); ASSERT_VALUES } @@ -860,6 +904,7 @@ BASE(AccessIndexed, AccessArray) Value length() const { return _length; } BasicType elt_type() const { return _elt_type; } + void clear_length() { _length = NULL; } // perform elimination of range checks involving constants bool compute_needs_range_check(); @@ -1524,6 +1569,7 @@ LEAF(BlockBegin, StateSplit) int _bci; // start-bci of block int _depth_first_number; // number of this block in a depth-first ordering int _linear_scan_number; // number of this block in linear-scan ordering + int _dominator_depth; int _loop_depth; // the loop nesting level of this block int _loop_index; // number of the innermost loop of this block int _flags; // the flags associated with this block @@ -1535,6 +1581,7 @@ LEAF(BlockBegin, StateSplit) // SSA specific fields: (factor out later) BlockList _successors; // the successors of this block BlockList _predecessors; // the predecessors of this block + BlockList _dominates; // list of blocks that are dominated by this block BlockBegin* _dominator; // the dominator of this block // SSA specific ends BlockEnd* _end; // the last instruction of this block @@ -1583,10 +1630,12 @@ LEAF(BlockBegin, StateSplit) , _linear_scan_number(-1) , _loop_depth(0) , _flags(0) + , _dominator_depth(-1) , _dominator(NULL) , _end(NULL) , _predecessors(2) , _successors(2) + , _dominates(2) , _exception_handlers(1) , _exception_states(NULL) , _exception_handler_pco(-1) @@ -1603,6 +1652,7 @@ LEAF(BlockBegin, StateSplit) , _total_preds(0) , _stores_to_locals() { + _block = this; #ifndef PRODUCT set_printable_bci(bci); #endif @@ -1612,8 +1662,10 @@ LEAF(BlockBegin, StateSplit) int block_id() const { return _block_id; } int bci() const { return _bci; } BlockList* successors() { return &_successors; } + BlockList* dominates() { return &_dominates; } BlockBegin* dominator() const { return _dominator; } int loop_depth() const { return _loop_depth; } + int dominator_depth() const { return _dominator_depth; } int depth_first_number() const { return _depth_first_number; } int linear_scan_number() const { return _linear_scan_number; } BlockEnd* end() const { return _end; } @@ -1634,6 +1686,7 @@ LEAF(BlockBegin, StateSplit) // manipulation void set_dominator(BlockBegin* dom) { _dominator = dom; } void set_loop_depth(int d) { _loop_depth = d; } + void set_dominator_depth(int d) { _dominator_depth = d; } void set_depth_first_number(int dfn) { _depth_first_number = dfn; } void set_linear_scan_number(int lsn) { _linear_scan_number = lsn; } void set_end(BlockEnd* end); @@ -1695,7 +1748,8 @@ LEAF(BlockBegin, StateSplit) parser_loop_header_flag = 1 << 7, // set by parser to identify blocks where phi functions can not be created on demand critical_edge_split_flag = 1 << 8, // set for all blocks that are introduced when critical edges are split linear_scan_loop_header_flag = 1 << 9, // set during loop-detection for LinearScan - linear_scan_loop_end_flag = 1 << 10 // set during loop-detection for LinearScan + linear_scan_loop_end_flag = 1 << 10, // set during loop-detection for LinearScan + donot_eliminate_range_checks = 1 << 11 // Should be try to eliminate range checks in this block }; void set(Flag f) { _flags |= f; } @@ -1728,7 +1782,6 @@ LEAF(BlockBegin, StateSplit) BASE(BlockEnd, StateSplit) private: - BlockBegin* _begin; BlockList* _sux; protected: @@ -1746,7 +1799,6 @@ BASE(BlockEnd, StateSplit) // creation BlockEnd(ValueType* type, ValueStack* state_before, bool is_safepoint) : StateSplit(type, state_before) - , _begin(NULL) , _sux(NULL) { set_flag(IsSafepointFlag, is_safepoint); @@ -1754,7 +1806,8 @@ BASE(BlockEnd, StateSplit) // accessors bool is_safepoint() const { return check_flag(IsSafepointFlag); } - BlockBegin* begin() const { return _begin; } + // For compatibility with old code, for new code use block() + BlockBegin* begin() const { return _block; } // manipulation void set_begin(BlockBegin* begin); @@ -1811,6 +1864,74 @@ LEAF(Goto, BlockEnd) void set_direction(Direction d) { _direction = d; } }; +#ifdef ASSERT +LEAF(Assert, Instruction) + private: + Value _x; + Condition _cond; + Value _y; + char *_message; + + public: + // creation + // unordered_is_true is valid for float/double compares only + Assert(Value x, Condition cond, bool unordered_is_true, Value y); + + // accessors + Value x() const { return _x; } + Condition cond() const { return _cond; } + bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); } + Value y() const { return _y; } + const char *message() const { return _message; } + + // generic + virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); f->visit(&_y); } +}; +#endif + +LEAF(RangeCheckPredicate, StateSplit) + private: + Value _x; + Condition _cond; + Value _y; + + void check_state(); + + public: + // creation + // unordered_is_true is valid for float/double compares only + RangeCheckPredicate(Value x, Condition cond, bool unordered_is_true, Value y, ValueStack* state) : StateSplit(illegalType) + , _x(x) + , _cond(cond) + , _y(y) + { + ASSERT_VALUES + set_flag(UnorderedIsTrueFlag, unordered_is_true); + assert(x->type()->tag() == y->type()->tag(), "types must match"); + this->set_state(state); + check_state(); + } + + // Always deoptimize + RangeCheckPredicate(ValueStack* state) : StateSplit(illegalType) + { + this->set_state(state); + _x = _y = NULL; + check_state(); + } + + // accessors + Value x() const { return _x; } + Condition cond() const { return _cond; } + bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); } + Value y() const { return _y; } + + void always_fail() { _x = _y = NULL; } + + // generic + virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_x); f->visit(&_y); } + HASHING3(RangeCheckPredicate, true, x()->subst(), y()->subst(), cond()) +}; LEAF(If, BlockEnd) private: diff --git a/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp b/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp index 68e0feb5b83..4c88e50cb21 100644 --- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp +++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp @@ -57,6 +57,8 @@ const char* InstructionPrinter::cond_name(If::Condition cond) { case If::leq: return "<="; case If::gtr: return ">"; case If::geq: return ">="; + case If::aeq: return "|>=|"; + case If::beq: return "|<=|"; } ShouldNotReachHere(); return NULL; @@ -181,6 +183,11 @@ void InstructionPrinter::print_indexed(AccessIndexed* indexed) { output()->put('['); print_value(indexed->index()); output()->put(']'); + if (indexed->length() != NULL) { + output()->put('('); + print_value(indexed->length()); + output()->put(')'); + } } @@ -373,6 +380,7 @@ void InstructionPrinter::do_Constant(Constant* x) { void InstructionPrinter::do_LoadField(LoadField* x) { print_field(x); output()->print(" (%c)", type2char(x->field()->type()->basic_type())); + output()->print(" %s", x->field()->name()->as_utf8()); } @@ -381,6 +389,7 @@ void InstructionPrinter::do_StoreField(StoreField* x) { output()->print(" := "); print_value(x->value()); output()->print(" (%c)", type2char(x->field()->type()->basic_type())); + output()->print(" %s", x->field()->name()->as_utf8()); } @@ -393,6 +402,9 @@ void InstructionPrinter::do_ArrayLength(ArrayLength* x) { void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) { print_indexed(x); output()->print(" (%c)", type2char(x->elt_type())); + if (x->check_flag(Instruction::NeedsRangeCheckFlag)) { + output()->print(" [rc]"); + } } @@ -401,6 +413,9 @@ void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) { output()->print(" := "); print_value(x->value()); output()->print(" (%c)", type2char(x->elt_type())); + if (x->check_flag(Instruction::NeedsRangeCheckFlag)) { + output()->print(" [rc]"); + } } void InstructionPrinter::do_NegateOp(NegateOp* x) { @@ -843,6 +858,25 @@ void InstructionPrinter::do_UnsafePrefetchRead(UnsafePrefetchRead* x) { output()->put(')'); } +void InstructionPrinter::do_RangeCheckPredicate(RangeCheckPredicate* x) { + + if (x->x() != NULL && x->y() != NULL) { + output()->print("if "); + print_value(x->x()); + output()->print(" %s ", cond_name(x->cond())); + print_value(x->y()); + output()->print(" then deoptimize!"); + } else { + output()->print("always deoptimize!"); + } +} + +void InstructionPrinter::do_Assert(Assert* x) { + output()->print("assert "); + print_value(x->x()); + output()->print(" %s ", cond_name(x->cond())); + print_value(x->y()); +} void InstructionPrinter::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { print_unsafe_object_op(x, "UnsafePrefetchWrite"); diff --git a/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp b/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp index d1d99cc2116..d8d6502ebd6 100644 --- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp +++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp @@ -135,6 +135,8 @@ class InstructionPrinter: public InstructionVisitor { virtual void do_ProfileInvoke (ProfileInvoke* x); virtual void do_RuntimeCall (RuntimeCall* x); virtual void do_MemBar (MemBar* x); + virtual void do_RangeCheckPredicate(RangeCheckPredicate* x); + virtual void do_Assert (Assert* x); }; #endif // PRODUCT diff --git a/hotspot/src/share/vm/c1/c1_LIR.cpp b/hotspot/src/share/vm/c1/c1_LIR.cpp index 2082b526822..df0828ee555 100644 --- a/hotspot/src/share/vm/c1/c1_LIR.cpp +++ b/hotspot/src/share/vm/c1/c1_LIR.cpp @@ -633,6 +633,7 @@ void LIR_OpVisitState::visit(LIR_Op* op) { case lir_ushr: case lir_xadd: case lir_xchg: + case lir_assert: { assert(op->as_Op2() != NULL, "must be"); LIR_Op2* op2 = (LIR_Op2*)op; @@ -1112,6 +1113,11 @@ void LIR_OpLock::emit_code(LIR_Assembler* masm) { } } +#ifdef ASSERT +void LIR_OpAssert::emit_code(LIR_Assembler* masm) { + masm->emit_assert(this); +} +#endif void LIR_OpDelay::emit_code(LIR_Assembler* masm) { masm->emit_delay(this); @@ -1771,6 +1777,8 @@ const char * LIR_Op::name() const { case lir_cas_int: s = "cas_int"; break; // LIR_OpProfileCall case lir_profile_call: s = "profile_call"; break; + // LIR_OpAssert + case lir_assert: s = "assert"; break; case lir_none: ShouldNotReachHere();break; default: s = "illegal_op"; break; } @@ -2017,6 +2025,13 @@ void LIR_OpLock::print_instr(outputStream* out) const { out->print("[lbl:0x%x]", stub()->entry()); } +void LIR_OpAssert::print_instr(outputStream* out) const { + print_condition(out, condition()); out->print(" "); + in_opr1()->print(out); out->print(" "); + in_opr2()->print(out); out->print(", \""); + out->print(msg()); out->print("\""); +} + void LIR_OpDelay::print_instr(outputStream* out) const { _op->print_on(out); diff --git a/hotspot/src/share/vm/c1/c1_LIR.hpp b/hotspot/src/share/vm/c1/c1_LIR.hpp index 72051f19f34..5bd0e57d6f9 100644 --- a/hotspot/src/share/vm/c1/c1_LIR.hpp +++ b/hotspot/src/share/vm/c1/c1_LIR.hpp @@ -881,6 +881,7 @@ class LIR_OpLock; class LIR_OpTypeCheck; class LIR_OpCompareAndSwap; class LIR_OpProfileCall; +class LIR_OpAssert; // LIR operation codes @@ -1000,6 +1001,9 @@ enum LIR_Code { , begin_opMDOProfile , lir_profile_call , end_opMDOProfile + , begin_opAssert + , lir_assert + , end_opAssert }; @@ -1135,6 +1139,7 @@ class LIR_Op: public CompilationResourceObj { virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; } virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; } virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; } + virtual LIR_OpAssert* as_OpAssert() { return NULL; } virtual void verify() const {} }; @@ -1623,7 +1628,7 @@ class LIR_Op2: public LIR_Op { , _tmp3(LIR_OprFact::illegalOpr) , _tmp4(LIR_OprFact::illegalOpr) , _tmp5(LIR_OprFact::illegalOpr) { - assert(code == lir_cmp, "code check"); + assert(code == lir_cmp || code == lir_assert, "code check"); } LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) @@ -1683,7 +1688,7 @@ class LIR_Op2: public LIR_Op { LIR_Opr tmp4_opr() const { return _tmp4; } LIR_Opr tmp5_opr() const { return _tmp5; } LIR_Condition condition() const { - assert(code() == lir_cmp || code() == lir_cmove, "only valid for cmp and cmove"); return _condition; + assert(code() == lir_cmp || code() == lir_cmove || code() == lir_assert, "only valid for cmp and cmove and assert"); return _condition; } void set_condition(LIR_Condition condition) { assert(code() == lir_cmp || code() == lir_cmove, "only valid for cmp and cmove"); _condition = condition; @@ -1823,6 +1828,30 @@ class LIR_OpDelay: public LIR_Op { CodeEmitInfo* call_info() const { return info(); } }; +#ifdef ASSERT +// LIR_OpAssert +class LIR_OpAssert : public LIR_Op2 { + friend class LIR_OpVisitState; + + private: + const char* _msg; + bool _halt; + + public: + LIR_OpAssert(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, const char* msg, bool halt) + : LIR_Op2(lir_assert, condition, opr1, opr2) + , _halt(halt) + , _msg(msg) { + } + + const char* msg() const { return _msg; } + bool halt() const { return _halt; } + + virtual void emit_code(LIR_Assembler* masm); + virtual LIR_OpAssert* as_OpAssert() { return this; } + virtual void print_instr(outputStream* out) const PRODUCT_RETURN; +}; +#endif // LIR_OpCompareAndSwap class LIR_OpCompareAndSwap : public LIR_Op { @@ -2196,6 +2225,9 @@ class LIR_List: public CompilationResourceObj { void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); } void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); } +#ifdef ASSERT + void lir_assert(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, const char* msg, bool halt) { append(new LIR_OpAssert(condition, opr1, opr2, msg, halt)); } +#endif }; void print_LIR(BlockList* blocks); diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp index 5cce9d0b71c..87dd8dbae15 100644 --- a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp @@ -210,6 +210,9 @@ class LIR_Assembler: public CompilationResourceObj { void arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest, CodeEmitInfo* info, bool pop_fpu_stack); void arithmetic_idiv(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr temp, LIR_Opr result, CodeEmitInfo* info); void intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr unused, LIR_Opr dest, LIR_Op* op); +#ifdef ASSERT + void emit_assert(LIR_OpAssert* op); +#endif void logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest); diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index b46acec1474..a3970cb3f8f 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -403,6 +403,10 @@ void LIRGenerator::walk(Value instr) { CodeEmitInfo* LIRGenerator::state_for(Instruction* x, ValueStack* state, bool ignore_xhandler) { assert(state != NULL, "state must be defined"); +#ifndef PRODUCT + state->verify(); +#endif + ValueStack* s = state; for_each_state(s) { if (s->kind() == ValueStack::EmptyExceptionState) { @@ -453,7 +457,7 @@ CodeEmitInfo* LIRGenerator::state_for(Instruction* x, ValueStack* state, bool ig } } - return new CodeEmitInfo(state, ignore_xhandler ? NULL : x->exception_handlers()); + return new CodeEmitInfo(state, ignore_xhandler ? NULL : x->exception_handlers(), x->check_flag(Instruction::DeoptimizeOnException)); } @@ -1792,11 +1796,18 @@ void LIRGenerator::do_LoadField(LoadField* x) { } #endif + bool stress_deopt = StressLoopInvariantCodeMotion && info && info->deoptimize_on_exception(); if (x->needs_null_check() && (needs_patching || - MacroAssembler::needs_explicit_null_check(x->offset()))) { + MacroAssembler::needs_explicit_null_check(x->offset()) || + stress_deopt)) { + LIR_Opr obj = object.result(); + if (stress_deopt) { + obj = new_register(T_OBJECT); + __ move(LIR_OprFact::oopConst(NULL), obj); + } // emit an explicit null check because the offset is too large - __ null_check(object.result(), new CodeEmitInfo(info)); + __ null_check(obj, new CodeEmitInfo(info)); } LIR_Opr reg = rlock_result(x, field_type); @@ -1861,6 +1872,8 @@ void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) { void LIRGenerator::do_ArrayLength(ArrayLength* x) { + if (x->use_count() == 0 && !x->can_trap()) return; + LIRItem array(x->array(), this); array.load_item(); LIR_Opr reg = rlock_result(x); @@ -1873,6 +1886,11 @@ void LIRGenerator::do_ArrayLength(ArrayLength* x) { } else { info = state_for(nc); } + if (StressLoopInvariantCodeMotion && info->deoptimize_on_exception()) { + LIR_Opr obj = new_register(T_OBJECT); + __ move(LIR_OprFact::oopConst(NULL), obj); + __ null_check(obj, new CodeEmitInfo(info)); + } } __ load(new LIR_Address(array.result(), arrayOopDesc::length_offset_in_bytes(), T_INT), reg, info, lir_patch_none); } @@ -1883,14 +1901,11 @@ void LIRGenerator::do_LoadIndexed(LoadIndexed* x) { LIRItem array(x->array(), this); LIRItem index(x->index(), this); LIRItem length(this); - bool needs_range_check = true; + bool needs_range_check = x->compute_needs_range_check(); - if (use_length) { - needs_range_check = x->compute_needs_range_check(); - if (needs_range_check) { - length.set_instruction(x->length()); - length.load_item(); - } + if (use_length && needs_range_check) { + length.set_instruction(x->length()); + length.load_item(); } array.load_item(); @@ -1910,13 +1925,20 @@ void LIRGenerator::do_LoadIndexed(LoadIndexed* x) { } else { null_check_info = range_check_info; } + if (StressLoopInvariantCodeMotion && null_check_info->deoptimize_on_exception()) { + LIR_Opr obj = new_register(T_OBJECT); + __ move(LIR_OprFact::oopConst(NULL), obj); + __ null_check(obj, new CodeEmitInfo(null_check_info)); + } } // emit array address setup early so it schedules better LIR_Address* array_addr = emit_array_address(array.result(), index.result(), x->elt_type(), false); if (GenerateRangeChecks && needs_range_check) { - if (use_length) { + if (StressLoopInvariantCodeMotion && range_check_info->deoptimize_on_exception()) { + __ branch(lir_cond_always, T_ILLEGAL, new RangeCheckStub(range_check_info, index.result())); + } else if (use_length) { // TODO: use a (modified) version of array_range_check that does not require a // constant length to be loaded to a register __ cmp(lir_cond_belowEqual, length.result(), index.result()); @@ -2634,7 +2656,7 @@ void LIRGenerator::do_Base(Base* x) { LIR_Opr lock = new_register(T_INT); __ load_stack_address_monitor(0, lock); - CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL); + CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, x->check_flag(Instruction::DeoptimizeOnException)); CodeStub* slow_path = new MonitorEnterStub(obj, lock, info); // receiver is guaranteed non-NULL so don't need CodeEmitInfo @@ -2644,7 +2666,7 @@ void LIRGenerator::do_Base(Base* x) { // increment invocation counters if needed if (!method()->is_accessor()) { // Accessors do not have MDOs, so no counting. - CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL); + CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, false); increment_invocation_counter(info); } @@ -3102,6 +3124,95 @@ void LIRGenerator::do_RuntimeCall(RuntimeCall* x) { } } +void LIRGenerator::do_Assert(Assert *x) { +#ifdef ASSERT + ValueTag tag = x->x()->type()->tag(); + If::Condition cond = x->cond(); + + LIRItem xitem(x->x(), this); + LIRItem yitem(x->y(), this); + LIRItem* xin = &xitem; + LIRItem* yin = &yitem; + + assert(tag == intTag, "Only integer assertions are valid!"); + + xin->load_item(); + yin->dont_load_item(); + + set_no_result(x); + + LIR_Opr left = xin->result(); + LIR_Opr right = yin->result(); + + __ lir_assert(lir_cond(x->cond()), left, right, x->message(), true); +#endif +} + + +void LIRGenerator::do_RangeCheckPredicate(RangeCheckPredicate *x) { + + + Instruction *a = x->x(); + Instruction *b = x->y(); + if (!a || StressRangeCheckElimination) { + assert(!b || StressRangeCheckElimination, "B must also be null"); + + CodeEmitInfo *info = state_for(x, x->state()); + CodeStub* stub = new PredicateFailedStub(info); + + __ jump(stub); + } else if (a->type()->as_IntConstant() && b->type()->as_IntConstant()) { + int a_int = a->type()->as_IntConstant()->value(); + int b_int = b->type()->as_IntConstant()->value(); + + bool ok = false; + + switch(x->cond()) { + case Instruction::eql: ok = (a_int == b_int); break; + case Instruction::neq: ok = (a_int != b_int); break; + case Instruction::lss: ok = (a_int < b_int); break; + case Instruction::leq: ok = (a_int <= b_int); break; + case Instruction::gtr: ok = (a_int > b_int); break; + case Instruction::geq: ok = (a_int >= b_int); break; + case Instruction::aeq: ok = ((unsigned int)a_int >= (unsigned int)b_int); break; + case Instruction::beq: ok = ((unsigned int)a_int <= (unsigned int)b_int); break; + default: ShouldNotReachHere(); + } + + if (ok) { + + CodeEmitInfo *info = state_for(x, x->state()); + CodeStub* stub = new PredicateFailedStub(info); + + __ jump(stub); + } + } else { + + ValueTag tag = x->x()->type()->tag(); + If::Condition cond = x->cond(); + LIRItem xitem(x->x(), this); + LIRItem yitem(x->y(), this); + LIRItem* xin = &xitem; + LIRItem* yin = &yitem; + + assert(tag == intTag, "Only integer deoptimizations are valid!"); + + xin->load_item(); + yin->dont_load_item(); + set_no_result(x); + + LIR_Opr left = xin->result(); + LIR_Opr right = yin->result(); + + CodeEmitInfo *info = state_for(x, x->state()); + CodeStub* stub = new PredicateFailedStub(info); + + __ cmp(lir_cond(cond), left, right); + __ branch(lir_cond(cond), right->type(), stub); + } +} + + LIR_Opr LIRGenerator::call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info) { LIRItemList args(1); LIRItem value(arg1, this); diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp index aedd6a69c94..4c70a9f64fd 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp @@ -412,6 +412,8 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { case If::leq: l = lir_cond_lessEqual; break; case If::geq: l = lir_cond_greaterEqual; break; case If::gtr: l = lir_cond_greater; break; + case If::aeq: l = lir_cond_aboveEqual; break; + case If::beq: l = lir_cond_belowEqual; break; }; return l; } @@ -534,6 +536,8 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { virtual void do_ProfileInvoke (ProfileInvoke* x); virtual void do_RuntimeCall (RuntimeCall* x); virtual void do_MemBar (MemBar* x); + virtual void do_RangeCheckPredicate(RangeCheckPredicate* x); + virtual void do_Assert (Assert* x); }; diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.cpp b/hotspot/src/share/vm/c1/c1_LinearScan.cpp index 1db08a8573a..65d4c60b670 100644 --- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp +++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp @@ -6231,26 +6231,29 @@ void ControlFlowOptimizer::delete_unnecessary_jumps(BlockList* code) { assert(prev_op->as_OpBranch() != NULL, "branch must be of type LIR_OpBranch"); LIR_OpBranch* prev_branch = (LIR_OpBranch*)prev_op; - LIR_Op2* prev_cmp = NULL; + if (prev_branch->stub() == NULL) { - for(int j = instructions->length() - 3; j >= 0 && prev_cmp == NULL; j--) { - prev_op = instructions->at(j); - if(prev_op->code() == lir_cmp) { - assert(prev_op->as_Op2() != NULL, "branch must be of type LIR_Op2"); - prev_cmp = (LIR_Op2*)prev_op; - assert(prev_branch->cond() == prev_cmp->condition(), "should be the same"); + LIR_Op2* prev_cmp = NULL; + + for(int j = instructions->length() - 3; j >= 0 && prev_cmp == NULL; j--) { + prev_op = instructions->at(j); + if (prev_op->code() == lir_cmp) { + assert(prev_op->as_Op2() != NULL, "branch must be of type LIR_Op2"); + prev_cmp = (LIR_Op2*)prev_op; + assert(prev_branch->cond() == prev_cmp->condition(), "should be the same"); + } } - } - assert(prev_cmp != NULL, "should have found comp instruction for branch"); - if (prev_branch->block() == code->at(i + 1) && prev_branch->info() == NULL) { + assert(prev_cmp != NULL, "should have found comp instruction for branch"); + if (prev_branch->block() == code->at(i + 1) && prev_branch->info() == NULL) { - TRACE_LINEAR_SCAN(3, tty->print_cr("Negating conditional branch and deleting unconditional branch at end of block B%d", block->block_id())); + TRACE_LINEAR_SCAN(3, tty->print_cr("Negating conditional branch and deleting unconditional branch at end of block B%d", block->block_id())); - // eliminate a conditional branch to the immediate successor - prev_branch->change_block(last_branch->block()); - prev_branch->negate_cond(); - prev_cmp->set_condition(prev_branch->cond()); - instructions->truncate(instructions->length() - 1); + // eliminate a conditional branch to the immediate successor + prev_branch->change_block(last_branch->block()); + prev_branch->negate_cond(); + prev_cmp->set_condition(prev_branch->cond()); + instructions->truncate(instructions->length() - 1); + } } } } diff --git a/hotspot/src/share/vm/c1/c1_Optimizer.cpp b/hotspot/src/share/vm/c1/c1_Optimizer.cpp index 7d24a126b20..74e9d2240db 100644 --- a/hotspot/src/share/vm/c1/c1_Optimizer.cpp +++ b/hotspot/src/share/vm/c1/c1_Optimizer.cpp @@ -178,7 +178,7 @@ void CE_Eliminator::block_do(BlockBegin* block) { // 2) substitute conditional expression // with an IfOp followed by a Goto // cut if_ away and get node before - Instruction* cur_end = if_->prev(block); + Instruction* cur_end = if_->prev(); // append constants of true- and false-block if necessary // clone constants because original block must not be destroyed @@ -202,7 +202,7 @@ void CE_Eliminator::block_do(BlockBegin* block) { } // append Goto to successor - ValueStack* state_before = if_->is_safepoint() ? if_->state_before() : NULL; + ValueStack* state_before = if_->state_before(); Goto* goto_ = new Goto(sux, state_before, if_->is_safepoint() || t_goto->is_safepoint() || f_goto->is_safepoint()); // prepare state for Goto @@ -367,10 +367,11 @@ class BlockMerger: public BlockClosure { #endif // find instruction before end & append first instruction of sux block - Instruction* prev = end->prev(block); + Instruction* prev = end->prev(); Instruction* next = sux->next(); assert(prev->as_BlockEnd() == NULL, "must not be a BlockEnd"); prev->set_next(next); + prev->fixup_block_pointers(); sux->disconnect_from_graph(); block->set_end(sux->end()); // add exception handlers of deleted block, if any @@ -533,6 +534,8 @@ public: void do_ProfileInvoke (ProfileInvoke* x); void do_RuntimeCall (RuntimeCall* x); void do_MemBar (MemBar* x); + void do_RangeCheckPredicate(RangeCheckPredicate* x); + void do_Assert (Assert* x); }; @@ -714,6 +717,8 @@ void NullCheckVisitor::do_ProfileCall (ProfileCall* x) { nce()->clear_las void NullCheckVisitor::do_ProfileInvoke (ProfileInvoke* x) {} void NullCheckVisitor::do_RuntimeCall (RuntimeCall* x) {} void NullCheckVisitor::do_MemBar (MemBar* x) {} +void NullCheckVisitor::do_RangeCheckPredicate(RangeCheckPredicate* x) {} +void NullCheckVisitor::do_Assert (Assert* x) {} void NullCheckEliminator::visit(Value* p) { diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp new file mode 100644 index 00000000000..948f635c27f --- /dev/null +++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp @@ -0,0 +1,1517 @@ +/* + * 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. + * + */ + +#include "precompiled.hpp" +#include "c1/c1_ValueStack.hpp" +#include "c1/c1_RangeCheckElimination.hpp" +#include "c1/c1_IR.hpp" +#include "c1/c1_Canonicalizer.hpp" +#include "c1/c1_ValueMap.hpp" +#include "ci/ciMethodData.hpp" +#include "runtime/deoptimization.hpp" + +// Macros for the Trace and the Assertion flag +#ifdef ASSERT +#define TRACE_RANGE_CHECK_ELIMINATION(code) if (TraceRangeCheckElimination) { code; } +#define ASSERT_RANGE_CHECK_ELIMINATION(code) if (AssertRangeCheckElimination) { code; } +#define TRACE_OR_ASSERT_RANGE_CHECK_ELIMINATION(code) if (TraceRangeCheckElimination || AssertRangeCheckElimination) { code; } +#else +#define TRACE_RANGE_CHECK_ELIMINATION(code) +#define ASSERT_RANGE_CHECK_ELIMINATION(code) +#define TRACE_OR_ASSERT_RANGE_CHECK_ELIMINATION(code) +#endif + +// Entry point for the optimization +void RangeCheckElimination::eliminate(IR *ir) { + bool do_elimination = ir->compilation()->has_access_indexed(); + ASSERT_RANGE_CHECK_ELIMINATION(do_elimination = true); + if (do_elimination) { + RangeCheckEliminator rce(ir); + } +} + +// Constructor +RangeCheckEliminator::RangeCheckEliminator(IR *ir) : + _bounds(Instruction::number_of_instructions(), NULL), + _access_indexed_info(Instruction::number_of_instructions(), NULL) +{ + _visitor.set_range_check_eliminator(this); + _ir = ir; + _number_of_instructions = Instruction::number_of_instructions(); + _optimistic = ir->compilation()->is_optimistic(); + + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr(""); + tty->print_cr("Range check elimination"); + ir->method()->print_name(tty); + tty->print_cr(""); + ); + + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr("optimistic=%d", (int)_optimistic); + ); + +#ifdef ASSERT + // Verifies several conditions that must be true on the IR-input. Only used for debugging purposes. + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr("Verification of IR . . ."); + ); + Verification verification(ir); +#endif + + // Set process block flags + // Optimization so a blocks is only processed if it contains an access indexed instruction or if + // one of its children in the dominator tree contains an access indexed instruction. + set_process_block_flags(ir->start()); + + // Pass over instructions in the dominator tree + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr("Starting pass over dominator tree . . .") + ); + calc_bounds(ir->start(), NULL); + + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr("Finished!") + ); +} + +// Instruction specific work for some instructions +// Constant +void RangeCheckEliminator::Visitor::do_Constant(Constant *c) { + IntConstant *ic = c->type()->as_IntConstant(); + if (ic != NULL) { + int value = ic->value(); + _bound = new Bound(value, NULL, value, NULL); + } +} + +// LogicOp +void RangeCheckEliminator::Visitor::do_LogicOp(LogicOp *lo) { + if (lo->type()->as_IntType() && lo->op() == Bytecodes::_iand && (lo->x()->as_Constant() || lo->y()->as_Constant())) { + int constant = 0; + Constant *c = lo->x()->as_Constant(); + if (c != NULL) { + constant = c->type()->as_IntConstant()->value(); + } else { + constant = lo->y()->as_Constant()->type()->as_IntConstant()->value(); + } + if (constant >= 0) { + _bound = new Bound(0, NULL, constant, NULL); + } + } +} + +// Phi +void RangeCheckEliminator::Visitor::do_Phi(Phi *phi) { + if (!phi->type()->as_IntType() && !phi->type()->as_ObjectType()) return; + + BlockBegin *block = phi->block(); + int op_count = phi->operand_count(); + bool has_upper = true; + bool has_lower = true; + assert(phi, "Phi must not be null"); + Bound *bound = NULL; + + // TODO: support more difficult phis + for (int i=0; ioperand_at(i); + + if (v == phi) continue; + + // Check if instruction is connected with phi itself + Op2 *op2 = v->as_Op2(); + if (op2 != NULL) { + Value x = op2->x(); + Value y = op2->y(); + if ((x == phi || y == phi)) { + Value other = x; + if (other == phi) { + other = y; + } + ArithmeticOp *ao = v->as_ArithmeticOp(); + if (ao != NULL && ao->op() == Bytecodes::_iadd) { + assert(ao->op() == Bytecodes::_iadd, "Has to be add!"); + if (ao->type()->as_IntType()) { + Constant *c = other->as_Constant(); + if (c != NULL) { + assert(c->type()->as_IntConstant(), "Constant has to be of type integer"); + int value = c->type()->as_IntConstant()->value(); + if (value == 1) { + has_upper = false; + } else if (value > 1) { + // Overflow not guaranteed + has_upper = false; + has_lower = false; + } else if (value < 0) { + has_lower = false; + } + continue; + } + } + } + } + } + + // No connection -> new bound + Bound *v_bound = _rce->get_bound(v); + Bound *cur_bound; + int cur_constant = 0; + Value cur_value = v; + + if (v->type()->as_IntConstant()) { + cur_constant = v->type()->as_IntConstant()->value(); + cur_value = NULL; + } + if (!v_bound->has_upper() || !v_bound->has_lower()) { + cur_bound = new Bound(cur_constant, cur_value, cur_constant, cur_value); + } else { + cur_bound = v_bound; + } + if (cur_bound) { + if (!bound) { + bound = cur_bound->copy(); + } else { + bound->or_op(cur_bound); + } + } else { + // No bound! + bound = NULL; + break; + } + } + + if (bound) { + if (!has_upper) { + bound->remove_upper(); + } + if (!has_lower) { + bound->remove_lower(); + } + _bound = bound; + } else { + _bound = new Bound(); + } +} + + +// ArithmeticOp +void RangeCheckEliminator::Visitor::do_ArithmeticOp(ArithmeticOp *ao) { + Value x = ao->x(); + Value y = ao->y(); + + if (ao->op() == Bytecodes::_irem) { + Bound* x_bound = _rce->get_bound(x); + Bound* y_bound = _rce->get_bound(y); + if (x_bound->lower() >= 0 && x_bound->lower_instr() == NULL && y->as_ArrayLength() != NULL) { + _bound = new Bound(0, NULL, -1, y); + } else { + _bound = new Bound(); + } + } else if (!x->as_Constant() || !y->as_Constant()) { + assert(!x->as_Constant() || !y->as_Constant(), "One of the operands must be non-constant!"); + if (((x->as_Constant() || y->as_Constant()) && (ao->op() == Bytecodes::_iadd)) || (y->as_Constant() && ao->op() == Bytecodes::_isub)) { + assert(ao->op() == Bytecodes::_iadd || ao->op() == Bytecodes::_isub, "Operand must be iadd or isub"); + + if (y->as_Constant()) { + Value tmp = x; + x = y; + y = tmp; + } + assert(x->as_Constant()->type()->as_IntConstant(), "Constant must be int constant!"); + + // Constant now in x + int const_value = x->as_Constant()->type()->as_IntConstant()->value(); + if (ao->op() == Bytecodes::_iadd || const_value != min_jint) { + if (ao->op() == Bytecodes::_isub) { + const_value = -const_value; + } + + Bound * bound = _rce->get_bound(y); + if (bound->has_upper() && bound->has_lower()) { + int new_lower = bound->lower() + const_value; + jlong new_lowerl = ((jlong)bound->lower()) + const_value; + int new_upper = bound->upper() + const_value; + jlong new_upperl = ((jlong)bound->upper()) + const_value; + + if (((jlong)new_lower) == new_lowerl && ((jlong)new_upper == new_upperl)) { + Bound *newBound = new Bound(new_lower, bound->lower_instr(), new_upper, bound->upper_instr()); + _bound = newBound; + } else { + // overflow + _bound = new Bound(); + } + } else { + _bound = new Bound(); + } + } else { + _bound = new Bound(); + } + } else { + Bound *bound = _rce->get_bound(x); + if (ao->op() == Bytecodes::_isub) { + if (bound->lower_instr() == y) { + _bound = new Bound(Instruction::geq, NULL, bound->lower()); + } else { + _bound = new Bound(); + } + } else { + _bound = new Bound(); + } + } + } +} + +// IfOp +void RangeCheckEliminator::Visitor::do_IfOp(IfOp *ifOp) +{ + if (ifOp->tval()->type()->as_IntConstant() && ifOp->fval()->type()->as_IntConstant()) { + int min = ifOp->tval()->type()->as_IntConstant()->value(); + int max = ifOp->fval()->type()->as_IntConstant()->value(); + if (min > max) { + // min ^= max ^= min ^= max; + int tmp = min; + min = max; + max = tmp; + } + _bound = new Bound(min, NULL, max, NULL); + } +} + +// Get bound. Returns the current bound on Value v. Normally this is the topmost element on the bound stack. +RangeCheckEliminator::Bound *RangeCheckEliminator::get_bound(Value v) { + // Wrong type or NULL -> No bound + if (!v || (!v->type()->as_IntType() && !v->type()->as_ObjectType())) return NULL; + + if (!_bounds[v->id()]) { + // First (default) bound is calculated + // Create BoundStack + _bounds[v->id()] = new BoundStack(); + _visitor.clear_bound(); + Value visit_value = v; + visit_value->visit(&_visitor); + Bound *bound = _visitor.bound(); + if (bound) { + _bounds[v->id()]->push(bound); + } + if (_bounds[v->id()]->length() == 0) { + assert(!(v->as_Constant() && v->type()->as_IntConstant()), "constants not handled here"); + _bounds[v->id()]->push(new Bound()); + } + } else if (_bounds[v->id()]->length() == 0) { + // To avoid endless loops, bound is currently in calculation -> nothing known about it + return new Bound(); + } + + // Return bound + return _bounds[v->id()]->top(); +} + +// Update bound +void RangeCheckEliminator::update_bound(IntegerStack &pushed, Value v, Instruction::Condition cond, Value value, int constant) { + if (cond == Instruction::gtr) { + cond = Instruction::geq; + constant++; + } else if (cond == Instruction::lss) { + cond = Instruction::leq; + constant--; + } + Bound *bound = new Bound(cond, value, constant); + update_bound(pushed, v, bound); +} + +// Checks for loop invariance. Returns true if the instruction is outside of the loop which is identified by loop_header. +bool RangeCheckEliminator::loop_invariant(BlockBegin *loop_header, Instruction *instruction) { + assert(loop_header, "Loop header must not be null!"); + if (!instruction) return true; + return instruction->dominator_depth() < loop_header->dominator_depth(); +} + +// Update bound. Pushes a new bound onto the stack. Tries to do a conjunction with the current bound. +void RangeCheckEliminator::update_bound(IntegerStack &pushed, Value v, Bound *bound) { + if (v->as_Constant()) { + // No bound update for constants + return; + } + if (!_bounds[v->id()]) { + get_bound(v); + assert(_bounds[v->id()], "Now Stack must exist"); + } + Bound *top = NULL; + if (_bounds[v->id()]->length() > 0) { + top = _bounds[v->id()]->top(); + } + if (top) { + bound->and_op(top); + } + _bounds[v->id()]->push(bound); + pushed.append(v->id()); +} + +// Add instruction + idx for in block motion +void RangeCheckEliminator::add_access_indexed_info(InstructionList &indices, int idx, Value instruction, AccessIndexed *ai) { + int id = instruction->id(); + AccessIndexedInfo *aii = _access_indexed_info[id]; + if (aii == NULL) { + aii = new AccessIndexedInfo(); + _access_indexed_info[id] = aii; + indices.append(instruction); + aii->_min = idx; + aii->_max = idx; + aii->_list = new AccessIndexedList(); + } else if (idx >= aii->_min && idx <= aii->_max) { + remove_range_check(ai); + return; + } + aii->_min = MIN2(aii->_min, idx); + aii->_max = MAX2(aii->_max, idx); + aii->_list->append(ai); +} + +// In block motion. Tries to reorder checks in order to reduce some of them. +// Example: +// a[i] = 0; +// a[i+2] = 0; +// a[i+1] = 0; +// In this example the check for a[i+1] would be considered as unnecessary during the first iteration. +// After this i is only checked once for i >= 0 and i+2 < a.length before the first array access. If this +// check fails, deoptimization is called. +void RangeCheckEliminator::in_block_motion(BlockBegin *block, AccessIndexedList &accessIndexed, InstructionList &arrays) { + InstructionList indices; + + // Now iterate over all arrays + for (int i=0; iarray() != array || !ai->check_flag(Instruction::NeedsRangeCheckFlag)) continue; + + Value index = ai->index(); + Constant *c = index->as_Constant(); + if (c != NULL) { + int constant_value = c->type()->as_IntConstant()->value(); + if (constant_value >= 0) { + if (constant_value <= max_constant) { + // No range check needed for this + remove_range_check(ai); + } else { + max_constant = constant_value; + list_constant.append(ai); + } + } + } else { + int last_integer = 0; + Instruction *last_instruction = index; + int base = 0; + ArithmeticOp *ao = index->as_ArithmeticOp(); + + while (ao != NULL && (ao->x()->as_Constant() || ao->y()->as_Constant()) && (ao->op() == Bytecodes::_iadd || ao->op() == Bytecodes::_isub)) { + c = ao->y()->as_Constant(); + Instruction *other = ao->x(); + if (!c && ao->op() == Bytecodes::_iadd) { + c = ao->x()->as_Constant(); + other = ao->y(); + } + + if (c) { + int value = c->type()->as_IntConstant()->value(); + if (value != min_jint) { + if (ao->op() == Bytecodes::_isub) { + value = -value; + } + base += value; + last_integer = base; + last_instruction = other; + } + index = other; + } else { + break; + } + ao = index->as_ArithmeticOp(); + } + add_access_indexed_info(indices, last_integer, last_instruction, ai); + } + } + + // Iterate over all different indices + if (_optimistic) { + for (int i=0; iid()]; + assert(info != NULL, "Info must not be null"); + + // if idx < 0, max > 0, max + idx may fall between 0 and + // length-1 and if min < 0, min + idx may overflow and be >= + // 0. The predicate wouldn't trigger but some accesses could + // be with a negative index. This test guarantees that for the + // min and max value that are kept the predicate can't let + // some incorrect accesses happen. + bool range_cond = (info->_max < 0 || info->_max + min_jint <= info->_min); + + // Generate code only if more than 2 range checks can be eliminated because of that. + // 2 because at least 2 comparisons are done + if (info->_list->length() > 2 && range_cond) { + AccessIndexed *first = info->_list->at(0); + Instruction *insert_position = first->prev(); + assert(insert_position->next() == first, "prev was calculated"); + ValueStack *state = first->state_before(); + + // Load min Constant + Constant *min_constant = NULL; + if (info->_min != 0) { + min_constant = new Constant(new IntConstant(info->_min)); + NOT_PRODUCT(min_constant->set_printable_bci(first->printable_bci())); + insert_position = insert_position->insert_after(min_constant); + } + + // Load max Constant + Constant *max_constant = NULL; + if (info->_max != 0) { + max_constant = new Constant(new IntConstant(info->_max)); + NOT_PRODUCT(max_constant->set_printable_bci(first->printable_bci())); + insert_position = insert_position->insert_after(max_constant); + } + + // Load array length + Value length_instr = first->length(); + if (!length_instr) { + ArrayLength *length = new ArrayLength(array, first->state_before()->copy()); + length->set_exception_state(length->state_before()); + length->set_flag(Instruction::DeoptimizeOnException, true); + insert_position = insert_position->insert_after_same_bci(length); + length_instr = length; + } + + // Calculate lower bound + Instruction *lower_compare = index_instruction; + if (min_constant) { + ArithmeticOp *ao = new ArithmeticOp(Bytecodes::_iadd, min_constant, lower_compare, false, NULL); + insert_position = insert_position->insert_after_same_bci(ao); + lower_compare = ao; + } + + // Calculate upper bound + Instruction *upper_compare = index_instruction; + if (max_constant) { + ArithmeticOp *ao = new ArithmeticOp(Bytecodes::_iadd, max_constant, upper_compare, false, NULL); + insert_position = insert_position->insert_after_same_bci(ao); + upper_compare = ao; + } + + // Trick with unsigned compare is done + int bci = NOT_PRODUCT(first->printable_bci()) PRODUCT_ONLY(-1); + insert_position = predicate(upper_compare, Instruction::aeq, length_instr, state, insert_position, bci); + insert_position = predicate_cmp_with_const(lower_compare, Instruction::leq, -1, state, insert_position); + for (int j = 0; j_list->length(); j++) { + AccessIndexed *ai = info->_list->at(j); + remove_range_check(ai); + } + } + _access_indexed_info[index_instruction->id()] = NULL; + } + indices.clear(); + + if (list_constant.length() > 1) { + AccessIndexed *first = list_constant.at(0); + Instruction *insert_position = first->prev(); + ValueStack *state = first->state_before(); + // Load max Constant + Constant *constant = new Constant(new IntConstant(max_constant)); + NOT_PRODUCT(constant->set_printable_bci(first->printable_bci())); + insert_position = insert_position->insert_after(constant); + Instruction *compare_instr = constant; + Value length_instr = first->length(); + if (!length_instr) { + ArrayLength *length = new ArrayLength(array, state->copy()); + length->set_exception_state(length->state_before()); + length->set_flag(Instruction::DeoptimizeOnException, true); + insert_position = insert_position->insert_after_same_bci(length); + length_instr = length; + } + // Compare for greater or equal to array length + insert_position = predicate(compare_instr, Instruction::geq, length_instr, state, insert_position); + for (int j = 0; jas_AccessIndexed() != NULL); + cur = cur->next(); + } + + BlockList *dominates = block->dominates(); + for (int i=0; ilength(); i++) { + BlockBegin *next = dominates->at(i); + process |= set_process_block_flags(next); + } + + if (!process) { + block->set(BlockBegin::donot_eliminate_range_checks); + } + return process; +} + +bool RangeCheckEliminator::is_ok_for_deoptimization(Instruction *insert_position, Instruction *array_instr, Instruction *length_instr, Instruction *lower_instr, int lower, Instruction *upper_instr, int upper) { + bool upper_check = true; + assert(lower_instr || lower >= 0, "If no lower_instr present, lower must be greater 0"); + assert(!lower_instr || lower_instr->dominator_depth() <= insert_position->dominator_depth(), "Dominator depth must be smaller"); + assert(!upper_instr || upper_instr->dominator_depth() <= insert_position->dominator_depth(), "Dominator depth must be smaller"); + assert(array_instr, "Array instruction must exist"); + assert(array_instr->dominator_depth() <= insert_position->dominator_depth(), "Dominator depth must be smaller"); + assert(!length_instr || length_instr->dominator_depth() <= insert_position->dominator_depth(), "Dominator depth must be smaller"); + + if (upper_instr && upper_instr->as_ArrayLength() && upper_instr->as_ArrayLength()->array() == array_instr) { + // static check + if (upper >= 0) return false; // would always trigger a deopt: + // array_length + x >= array_length, x >= 0 is always true + upper_check = false; + } + if (lower_instr && lower_instr->as_ArrayLength() && lower_instr->as_ArrayLength()->array() == array_instr) { + if (lower > 0) return false; + } + // No upper check required -> skip + if (upper_check && upper_instr && upper_instr->type()->as_ObjectType() && upper_instr == array_instr) { + // upper_instr is object means that the upper bound is the length + // of the upper_instr. + return false; + } + return true; +} + +Instruction* RangeCheckEliminator::insert_after(Instruction* insert_position, Instruction* instr, int bci) { + if (bci != -1) { + NOT_PRODUCT(instr->set_printable_bci(bci)); + return insert_position->insert_after(instr); + } else { + return insert_position->insert_after_same_bci(instr); + } +} + +Instruction* RangeCheckEliminator::predicate(Instruction* left, Instruction::Condition cond, Instruction* right, ValueStack* state, Instruction *insert_position, int bci) { + RangeCheckPredicate *deoptimize = new RangeCheckPredicate(left, cond, true, right, state->copy()); + return insert_after(insert_position, deoptimize, bci); +} + +Instruction* RangeCheckEliminator::predicate_cmp_with_const(Instruction* instr, Instruction::Condition cond, int constant, ValueStack* state, Instruction *insert_position, int bci) { + Constant *const_instr = new Constant(new IntConstant(constant)); + insert_position = insert_after(insert_position, const_instr, bci); + return predicate(instr, cond, const_instr, state, insert_position); +} + +Instruction* RangeCheckEliminator::predicate_add(Instruction* left, int left_const, Instruction::Condition cond, Instruction* right, ValueStack* state, Instruction *insert_position, int bci) { + Constant *constant = new Constant(new IntConstant(left_const)); + insert_position = insert_after(insert_position, constant, bci); + ArithmeticOp *ao = new ArithmeticOp(Bytecodes::_iadd, constant, left, false, NULL); + insert_position = insert_position->insert_after_same_bci(ao); + return predicate(ao, cond, right, state, insert_position); +} + +Instruction* RangeCheckEliminator::predicate_add_cmp_with_const(Instruction* left, int left_const, Instruction::Condition cond, int constant, ValueStack* state, Instruction *insert_position, int bci) { + Constant *const_instr = new Constant(new IntConstant(constant)); + insert_position = insert_after(insert_position, const_instr, bci); + return predicate_add(left, left_const, cond, const_instr, state, insert_position); +} + +// Insert deoptimization, returns true if sucessful or false if range check should not be removed +void RangeCheckEliminator::insert_deoptimization(ValueStack *state, Instruction *insert_position, Instruction *array_instr, Instruction *length_instr, Instruction *lower_instr, int lower, Instruction *upper_instr, int upper, AccessIndexed *ai) { + assert(is_ok_for_deoptimization(insert_position, array_instr, length_instr, lower_instr, lower, upper_instr, upper), "should have been tested before"); + bool upper_check = !(upper_instr && upper_instr->as_ArrayLength() && upper_instr->as_ArrayLength()->array() == array_instr); + + int bci = NOT_PRODUCT(ai->printable_bci()) PRODUCT_ONLY(-1); + if (lower_instr) { + assert(!lower_instr->type()->as_ObjectType(), "Must not be object type"); + if (lower == 0) { + // Compare for less than 0 + insert_position = predicate_cmp_with_const(lower_instr, Instruction::lss, 0, state, insert_position, bci); + } else if (lower > 0) { + // Compare for smaller 0 + insert_position = predicate_add_cmp_with_const(lower_instr, lower, Instruction::lss, 0, state, insert_position, bci); + } else { + assert(lower < 0, ""); + // Add 1 + lower++; + lower = -lower; + // Compare for smaller or equal 0 + insert_position = predicate_cmp_with_const(lower_instr, Instruction::leq, lower, state, insert_position, bci); + } + } + + // We need to know length of array + if (!length_instr) { + // Load length if necessary + ArrayLength *length = new ArrayLength(array_instr, state->copy()); + NOT_PRODUCT(length->set_printable_bci(ai->printable_bci())); + length->set_exception_state(length->state_before()); + length->set_flag(Instruction::DeoptimizeOnException, true); + insert_position = insert_position->insert_after(length); + length_instr = length; + } + + // No upper check required -> skip + if (!upper_check) return; + + if (!upper_instr) { + // Compare for geq array.length + insert_position = predicate_cmp_with_const(length_instr, Instruction::leq, upper, state, insert_position, bci); + } else { + if (upper_instr->type()->as_ObjectType()) { + assert(state, "must not be null"); + assert(upper_instr != array_instr, "should be"); + ArrayLength *length = new ArrayLength(upper_instr, state->copy()); + NOT_PRODUCT(length->set_printable_bci(ai->printable_bci())); + length->set_flag(Instruction::DeoptimizeOnException, true); + length->set_exception_state(length->state_before()); + insert_position = insert_position->insert_after(length); + upper_instr = length; + } + assert(upper_instr->type()->as_IntType(), "Must not be object type!"); + + if (upper == 0) { + // Compare for geq array.length + insert_position = predicate(upper_instr, Instruction::geq, length_instr, state, insert_position, bci); + } else if (upper < 0) { + // Compare for geq array.length + insert_position = predicate_add(upper_instr, upper, Instruction::geq, length_instr, state, insert_position, bci); + } else { + assert(upper > 0, ""); + upper = -upper; + // Compare for geq array.length + insert_position = predicate_add(length_instr, upper, Instruction::leq, upper_instr, state, insert_position, bci); + } + } +} + +// Add if condition +void RangeCheckEliminator::add_if_condition(IntegerStack &pushed, Value x, Value y, Instruction::Condition condition) { + if (y->as_Constant()) return; + + int const_value = 0; + Value instr_value = x; + Constant *c = x->as_Constant(); + ArithmeticOp *ao = x->as_ArithmeticOp(); + + if (c != NULL) { + const_value = c->type()->as_IntConstant()->value(); + instr_value = NULL; + } else if (ao != NULL && (!ao->x()->as_Constant() || !ao->y()->as_Constant()) && ((ao->op() == Bytecodes::_isub && ao->y()->as_Constant()) || ao->op() == Bytecodes::_iadd)) { + assert(!ao->x()->as_Constant() || !ao->y()->as_Constant(), "At least one operator must be non-constant!"); + assert(ao->op() == Bytecodes::_isub || ao->op() == Bytecodes::_iadd, "Operation has to be add or sub!"); + c = ao->x()->as_Constant(); + if (c != NULL) { + const_value = c->type()->as_IntConstant()->value(); + instr_value = ao->y(); + } else { + c = ao->y()->as_Constant(); + if (c != NULL) { + const_value = c->type()->as_IntConstant()->value(); + instr_value = ao->x(); + } + } + if (ao->op() == Bytecodes::_isub) { + assert(ao->y()->as_Constant(), "1 - x not supported, only x - 1 is valid!"); + if (const_value > min_jint) { + const_value = -const_value; + } else { + const_value = 0; + instr_value = x; + } + } + } + + update_bound(pushed, y, condition, instr_value, const_value); +} + +// Process If +void RangeCheckEliminator::process_if(IntegerStack &pushed, BlockBegin *block, If *cond) { + // Only if we are direct true / false successor and NOT both ! (even this may occur) + if ((cond->tsux() == block || cond->fsux() == block) && cond->tsux() != cond->fsux()) { + Instruction::Condition condition = cond->cond(); + if (cond->fsux() == block) { + condition = Instruction::negate(condition); + } + Value x = cond->x(); + Value y = cond->y(); + if (x->type()->as_IntType() && y->type()->as_IntType()) { + add_if_condition(pushed, y, x, condition); + add_if_condition(pushed, x, y, Instruction::mirror(condition)); + } + } +} + +// Process access indexed +void RangeCheckEliminator::process_access_indexed(BlockBegin *loop_header, BlockBegin *block, AccessIndexed *ai) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2) + ); + TRACE_RANGE_CHECK_ELIMINATION( + tty->print_cr("Access indexed: index=%d length=%d", ai->index()->id(), ai->length()->id()) + ); + + if (ai->check_flag(Instruction::NeedsRangeCheckFlag)) { + Bound *index_bound = get_bound(ai->index()); + if (!index_bound->has_lower() || !index_bound->has_upper()) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Index instruction %d has no lower and/or no upper bound!", ai->index()->id()) + ); + return; + } + + Bound *array_bound; + if (ai->length()) { + array_bound = get_bound(ai->length()); + } else { + array_bound = get_bound(ai->array()); + } + + if (in_array_bound(index_bound, ai->array()) || + (index_bound && array_bound && index_bound->is_smaller(array_bound) && !index_bound->lower_instr() && index_bound->lower() >= 0)) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Bounds check for instruction %d in block B%d can be fully eliminated!", ai->id(), ai->block()->block_id()) + ); + + remove_range_check(ai); + } else if (_optimistic && loop_header) { + assert(ai->array(), "Array must not be null!"); + assert(ai->index(), "Index must not be null!"); + + // Array instruction + Instruction *array_instr = ai->array(); + if (!loop_invariant(loop_header, array_instr)) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Array %d is not loop invariant to header B%d", ai->array()->id(), loop_header->block_id()) + ); + return; + } + + // Lower instruction + Value index_instr = ai->index(); + Value lower_instr = index_bound->lower_instr(); + if (!loop_invariant(loop_header, lower_instr)) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Lower instruction %d not loop invariant!", lower_instr->id()) + ); + return; + } + if (!lower_instr && index_bound->lower() < 0) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Lower bound smaller than 0 (%d)!", index_bound->lower()) + ); + return; + } + + // Upper instruction + Value upper_instr = index_bound->upper_instr(); + if (!loop_invariant(loop_header, upper_instr)) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Upper instruction %d not loop invariant!", upper_instr->id()) + ); + return; + } + + // Length instruction + Value length_instr = ai->length(); + if (!loop_invariant(loop_header, length_instr)) { + // Generate length instruction yourself! + length_instr = NULL; + } + + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("LOOP INVARIANT access indexed %d found in block B%d!", ai->id(), ai->block()->block_id()) + ); + + BlockBegin *pred_block = loop_header->dominator(); + assert(pred_block != NULL, "Every loop header has a dominator!"); + BlockEnd *pred_block_end = pred_block->end(); + Instruction *insert_position = pred_block_end->prev(); + ValueStack *state = pred_block_end->state_before(); + if (pred_block_end->as_Goto() && state == NULL) state = pred_block_end->state(); + assert(state, "State must not be null"); + + // Add deoptimization to dominator of loop header + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Inserting deopt at bci %d in block B%d!", state->bci(), insert_position->block()->block_id()) + ); + + if (!is_ok_for_deoptimization(insert_position, array_instr, length_instr, lower_instr, index_bound->lower(), upper_instr, index_bound->upper())) { + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Could not eliminate because of static analysis!") + ); + return; + } + + insert_deoptimization(state, insert_position, array_instr, length_instr, lower_instr, index_bound->lower(), upper_instr, index_bound->upper(), ai); + + // Finally remove the range check! + remove_range_check(ai); + } + } +} + +void RangeCheckEliminator::remove_range_check(AccessIndexed *ai) { + ai->set_flag(Instruction::NeedsRangeCheckFlag, false); + // no range check, no need for the length instruction anymore + ai->clear_length(); + + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(ai->dominator_depth()*2); + tty->print_cr("Range check for instruction %d eliminated!", ai->id()); + ); + + ASSERT_RANGE_CHECK_ELIMINATION( + Value array_length = ai->length(); + if (!array_length) { + array_length = ai->array(); + assert(array_length->type()->as_ObjectType(), "Has to be object type!"); + } + int cur_constant = -1; + Value cur_value = array_length; + if (cur_value->type()->as_IntConstant()) { + cur_constant += cur_value->type()->as_IntConstant()->value(); + cur_value = NULL; + } + Bound *new_index_bound = new Bound(0, NULL, cur_constant, cur_value); + add_assertions(new_index_bound, ai->index(), ai); + ); +} + +// Calculate bounds for instruction in this block and children blocks in the dominator tree +void RangeCheckEliminator::calc_bounds(BlockBegin *block, BlockBegin *loop_header) { + // Ensures a valid loop_header + assert(!loop_header || loop_header->is_set(BlockBegin::linear_scan_loop_header_flag), "Loop header has to be real !"); + + // Tracing output + TRACE_RANGE_CHECK_ELIMINATION( + tty->fill_to(block->dominator_depth()*2); + tty->print_cr("Block B%d", block->block_id()); + ); + + // Pushed stack for conditions + IntegerStack pushed; + // Process If + BlockBegin *parent = block->dominator(); + if (parent != NULL) { + If *cond = parent->end()->as_If(); + if (cond != NULL) { + process_if(pushed, block, cond); + } + } + + // Interate over current block + InstructionList arrays; + AccessIndexedList accessIndexed; + Instruction *cur = block; + + while (cur) { + // Ensure cur wasn't inserted during the elimination + if (cur->id() < this->_bounds.length()) { + // Process only if it is an access indexed instruction + AccessIndexed *ai = cur->as_AccessIndexed(); + if (ai != NULL) { + process_access_indexed(loop_header, block, ai); + accessIndexed.append(ai); + if (!arrays.contains(ai->array())) { + arrays.append(ai->array()); + } + Bound *b = get_bound(ai->index()); + if (!b->lower_instr()) { + // Lower bound is constant + update_bound(pushed, ai->index(), Instruction::geq, NULL, 0); + } + if (!b->has_upper()) { + if (ai->length() && ai->length()->type()->as_IntConstant()) { + int value = ai->length()->type()->as_IntConstant()->value(); + update_bound(pushed, ai->index(), Instruction::lss, NULL, value); + } else { + // Has no upper bound + Instruction *instr = ai->length(); + if (instr != NULL) instr = ai->array(); + update_bound(pushed, ai->index(), Instruction::lss, instr, 0); + } + } + } + } + cur = cur->next(); + } + + // Output current condition stack + TRACE_RANGE_CHECK_ELIMINATION(dump_condition_stack(block)); + + // Do in block motion of range checks + in_block_motion(block, accessIndexed, arrays); + + // Call all dominated blocks + for (int i=0; idominates()->length(); i++) { + BlockBegin *next = block->dominates()->at(i); + if (!next->is_set(BlockBegin::donot_eliminate_range_checks)) { + // if current block is a loop header and: + // - next block belongs to the same loop + // or + // - next block belongs to an inner loop + // then current block is the loop header for next block + if (block->is_set(BlockBegin::linear_scan_loop_header_flag) && (block->loop_index() == next->loop_index() || next->loop_depth() > block->loop_depth())) { + calc_bounds(next, block); + } else { + calc_bounds(next, loop_header); + } + } + } + + // Reset stack + for (int i=0; ipop(); + } +} + +#ifndef PRODUCT +// Dump condition stack +void RangeCheckEliminator::dump_condition_stack(BlockBegin *block) { + for (int i=0; i<_ir->linear_scan_order()->length(); i++) { + BlockBegin *cur_block = _ir->linear_scan_order()->at(i); + Instruction *instr = cur_block; + for_each_phi_fun(cur_block, phi, + BoundStack *bound_stack = _bounds.at(phi->id()); + if (bound_stack && bound_stack->length() > 0) { + Bound *bound = bound_stack->top(); + if ((bound->has_lower() || bound->has_upper()) && (bound->lower_instr() != phi || bound->upper_instr() != phi || bound->lower() != 0 || bound->upper() != 0)) { + TRACE_RANGE_CHECK_ELIMINATION(tty->fill_to(2*block->dominator_depth()); + tty->print("i%d", phi->id()); + tty->print(": "); + bound->print(); + tty->print_cr(""); + ); + } + }); + + while (!instr->as_BlockEnd()) { + if (instr->id() < _bounds.length()) { + BoundStack *bound_stack = _bounds.at(instr->id()); + if (bound_stack && bound_stack->length() > 0) { + Bound *bound = bound_stack->top(); + if ((bound->has_lower() || bound->has_upper()) && (bound->lower_instr() != instr || bound->upper_instr() != instr || bound->lower() != 0 || bound->upper() != 0)) { + TRACE_RANGE_CHECK_ELIMINATION(tty->fill_to(2*block->dominator_depth()); + tty->print("i%d", instr->id()); + tty->print(": "); + bound->print(); + tty->print_cr(""); + ); + } + } + } + instr = instr->next(); + } + } +} +#endif + +// Verification or the IR +RangeCheckEliminator::Verification::Verification(IR *ir) : _used(BlockBegin::number_of_blocks(), false) { + this->_ir = ir; + ir->iterate_linear_scan_order(this); +} + +// Verify this block +void RangeCheckEliminator::Verification::block_do(BlockBegin *block) { + If *cond = block->end()->as_If(); + // Watch out: tsux and fsux can be the same! + if (block->number_of_sux() > 1) { + for (int i=0; inumber_of_sux(); i++) { + BlockBegin *sux = block->sux_at(i); + BlockBegin *pred = NULL; + for (int j=0; jnumber_of_preds(); j++) { + BlockBegin *cur = sux->pred_at(j); + assert(cur != NULL, "Predecessor must not be null"); + if (!pred) { + pred = cur; + } + assert(cur == pred, "Block must not have more than one predecessor if its predecessor has more than one successor"); + } + assert(sux->number_of_preds() >= 1, "Block must have at least one predecessor"); + assert(sux->pred_at(0) == block, "Wrong successor"); + } + } + + BlockBegin *dominator = block->dominator(); + if (dominator) { + assert(block != _ir->start(), "Start block must not have a dominator!"); + assert(can_reach(dominator, block), "Dominator can't reach his block !"); + assert(can_reach(_ir->start(), dominator), "Dominator is unreachable !"); + assert(!can_reach(_ir->start(), block, dominator), "Wrong dominator ! Block can be reached anyway !"); + BlockList *all_blocks = _ir->linear_scan_order(); + for (int i=0; ilength(); i++) { + BlockBegin *cur = all_blocks->at(i); + if (cur != dominator && cur != block) { + assert(can_reach(dominator, block, cur), "There has to be another dominator!"); + } + } + } else { + assert(block == _ir->start(), "Only start block must not have a dominator"); + } + + if (block->is_set(BlockBegin::linear_scan_loop_header_flag)) { + int loop_index = block->loop_index(); + BlockList *all_blocks = _ir->linear_scan_order(); + assert(block->number_of_preds() >= 1, "Block must have at least one predecessor"); + assert(!block->is_set(BlockBegin::exception_entry_flag), "Loop header must not be exception handler!"); + // Sometimes, the backbranch comes from an exception handler. In + // this case, loop indexes/loop depths may not appear correct. + bool loop_through_xhandler = false; + for (int i = 0; i < block->number_of_exception_handlers(); i++) { + BlockBegin *xhandler = block->exception_handler_at(i); + for (int j = 0; j < block->number_of_preds(); j++) { + if (dominates(xhandler, block->pred_at(j)) || xhandler == block->pred_at(j)) { + loop_through_xhandler = true; + } + } + } + + for (int i=0; inumber_of_sux(); i++) { + BlockBegin *sux = block->sux_at(i); + assert(sux->loop_depth() != block->loop_depth() || sux->loop_index() == block->loop_index() || loop_through_xhandler, "Loop index has to be same"); + assert(sux->loop_depth() == block->loop_depth() || sux->loop_index() != block->loop_index(), "Loop index has to be different"); + } + + for (int i=0; ilength(); i++) { + BlockBegin *cur = all_blocks->at(i); + if (cur->loop_index() == loop_index && cur != block) { + assert(dominates(block->dominator(), cur), "Dominator of loop header must dominate all loop blocks"); + } + } + } + + Instruction *cur = block; + while (cur) { + assert(cur->block() == block, "Block begin has to be set correctly!"); + cur = cur->next(); + } +} + +// Loop header must dominate all loop blocks +bool RangeCheckEliminator::Verification::dominates(BlockBegin *dominator, BlockBegin *block) { + BlockBegin *cur = block->dominator(); + while (cur && cur != dominator) { + cur = cur->dominator(); + } + return cur == dominator; +} + +// Try to reach Block end beginning in Block start and not using Block dont_use +bool RangeCheckEliminator::Verification::can_reach(BlockBegin *start, BlockBegin *end, BlockBegin *dont_use /* = NULL */) { + if (start == end) return start != dont_use; + // Simple BSF from start to end + // BlockBeginList _current; + for (int i=0; i<_used.length(); i++) { + _used[i] = false; + } + _current.truncate(0); + _successors.truncate(0); + if (start != dont_use) { + _current.push(start); + _used[start->block_id()] = true; + } + + // BlockBeginList _successors; + while (_current.length() > 0) { + BlockBegin *cur = _current.pop(); + // Add exception handlers to list + for (int i=0; inumber_of_exception_handlers(); i++) { + BlockBegin *xhandler = cur->exception_handler_at(i); + _successors.push(xhandler); + // Add exception handlers of _successors to list + for (int j=0; jnumber_of_exception_handlers(); j++) { + BlockBegin *sux_xhandler = xhandler->exception_handler_at(j); + _successors.push(sux_xhandler); + } + } + // Add normal _successors to list + for (int i=0; inumber_of_sux(); i++) { + BlockBegin *sux = cur->sux_at(i); + _successors.push(sux); + // Add exception handlers of _successors to list + for (int j=0; jnumber_of_exception_handlers(); j++) { + BlockBegin *xhandler = sux->exception_handler_at(j); + _successors.push(xhandler); + } + } + for (int i=0; i<_successors.length(); i++) { + BlockBegin *sux = _successors[i]; + assert(sux != NULL, "Successor must not be NULL!"); + if (sux == end) { + return true; + } + if (sux != dont_use && !_used[sux->block_id()]) { + _used[sux->block_id()] = true; + _current.push(sux); + } + } + _successors.truncate(0); + } + + return false; +} + +// Bound +RangeCheckEliminator::Bound::~Bound() { +} + +// Bound constructor +RangeCheckEliminator::Bound::Bound() { + init(); + this->_lower = min_jint; + this->_upper = max_jint; + this->_lower_instr = NULL; + this->_upper_instr = NULL; +} + +// Bound constructor +RangeCheckEliminator::Bound::Bound(int lower, Value lower_instr, int upper, Value upper_instr) { + init(); + assert(!lower_instr || !lower_instr->as_Constant() || !lower_instr->type()->as_IntConstant(), "Must not be constant!"); + assert(!upper_instr || !upper_instr->as_Constant() || !upper_instr->type()->as_IntConstant(), "Must not be constant!"); + this->_lower = lower; + this->_upper = upper; + this->_lower_instr = lower_instr; + this->_upper_instr = upper_instr; +} + +// Bound constructor +RangeCheckEliminator::Bound::Bound(Instruction::Condition cond, Value v, int constant) { + assert(!v || (v->type() && (v->type()->as_IntType() || v->type()->as_ObjectType())), "Type must be array or integer!"); + assert(!v || !v->as_Constant() || !v->type()->as_IntConstant(), "Must not be constant!"); + + init(); + if (cond == Instruction::eql) { + _lower = constant; + _lower_instr = v; + _upper = constant; + _upper_instr = v; + } else if (cond == Instruction::neq) { + _lower = min_jint; + _upper = max_jint; + _lower_instr = NULL; + _upper_instr = NULL; + if (v == NULL) { + if (constant == min_jint) { + _lower++; + } + if (constant == max_jint) { + _upper--; + } + } + } else if (cond == Instruction::geq) { + _lower = constant; + _lower_instr = v; + _upper = max_jint; + _upper_instr = NULL; + } else if (cond == Instruction::leq) { + _lower = min_jint; + _lower_instr = NULL; + _upper = constant; + _upper_instr = v; + } else { + ShouldNotReachHere(); + } +} + +// Set lower +void RangeCheckEliminator::Bound::set_lower(int value, Value v) { + assert(!v || !v->as_Constant() || !v->type()->as_IntConstant(), "Must not be constant!"); + this->_lower = value; + this->_lower_instr = v; +} + +// Set upper +void RangeCheckEliminator::Bound::set_upper(int value, Value v) { + assert(!v || !v->as_Constant() || !v->type()->as_IntConstant(), "Must not be constant!"); + this->_upper = value; + this->_upper_instr = v; +} + +// Add constant -> no overflow may occur +void RangeCheckEliminator::Bound::add_constant(int value) { + this->_lower += value; + this->_upper += value; +} + +// Init +void RangeCheckEliminator::Bound::init() { +} + +// or +void RangeCheckEliminator::Bound::or_op(Bound *b) { + // Watch out, bound is not guaranteed not to overflow! + // Update lower bound + if (_lower_instr != b->_lower_instr || (_lower_instr && _lower != b->_lower)) { + _lower_instr = NULL; + _lower = min_jint; + } else { + _lower = MIN2(_lower, b->_lower); + } + // Update upper bound + if (_upper_instr != b->_upper_instr || (_upper_instr && _upper != b->_upper)) { + _upper_instr = NULL; + _upper = max_jint; + } else { + _upper = MAX2(_upper, b->_upper); + } +} + +// and +void RangeCheckEliminator::Bound::and_op(Bound *b) { + // Update lower bound + if (_lower_instr == b->_lower_instr) { + _lower = MAX2(_lower, b->_lower); + } + if (b->has_lower()) { + bool set = true; + if (_lower_instr != NULL && b->_lower_instr != NULL) { + set = (_lower_instr->dominator_depth() > b->_lower_instr->dominator_depth()); + } + if (set) { + _lower = b->_lower; + _lower_instr = b->_lower_instr; + } + } + // Update upper bound + if (_upper_instr == b->_upper_instr) { + _upper = MIN2(_upper, b->_upper); + } + if (b->has_upper()) { + bool set = true; + if (_upper_instr != NULL && b->_upper_instr != NULL) { + set = (_upper_instr->dominator_depth() > b->_upper_instr->dominator_depth()); + } + if (set) { + _upper = b->_upper; + _upper_instr = b->_upper_instr; + } + } +} + +// has_upper +bool RangeCheckEliminator::Bound::has_upper() { + return _upper_instr != NULL || _upper < max_jint; +} + +// is_smaller +bool RangeCheckEliminator::Bound::is_smaller(Bound *b) { + if (b->_lower_instr != _upper_instr) { + return false; + } + return _upper < b->_lower; +} + +// has_lower +bool RangeCheckEliminator::Bound::has_lower() { + return _lower_instr != NULL || _lower > min_jint; +} + +// in_array_bound +bool RangeCheckEliminator::in_array_bound(Bound *bound, Value array){ + if (!bound) return false; + assert(array != NULL, "Must not be null!"); + assert(bound != NULL, "Must not be null!"); + if (bound->lower() >=0 && bound->lower_instr() == NULL && bound->upper() < 0 && bound->upper_instr() != NULL) { + ArrayLength *len = bound->upper_instr()->as_ArrayLength(); + if (bound->upper_instr() == array || (len != NULL && len->array() == array)) { + return true; + } + } + return false; +} + +// remove_lower +void RangeCheckEliminator::Bound::remove_lower() { + _lower = min_jint; + _lower_instr = NULL; +} + +// remove_upper +void RangeCheckEliminator::Bound::remove_upper() { + _upper = max_jint; + _upper_instr = NULL; +} + +// upper +int RangeCheckEliminator::Bound::upper() { + return _upper; +} + +// lower +int RangeCheckEliminator::Bound::lower() { + return _lower; +} + +// upper_instr +Value RangeCheckEliminator::Bound::upper_instr() { + return _upper_instr; +} + +// lower_instr +Value RangeCheckEliminator::Bound::lower_instr() { + return _lower_instr; +} + +// print +void RangeCheckEliminator::Bound::print() { + tty->print(""); + if (this->_lower_instr || this->_lower != min_jint) { + if (this->_lower_instr) { + tty->print("i%d", this->_lower_instr->id()); + if (this->_lower > 0) { + tty->print("+%d", _lower); + } + if (this->_lower < 0) { + tty->print("%d", _lower); + } + } else { + tty->print("%d", _lower); + } + tty->print(" <= "); + } + tty->print("x"); + if (this->_upper_instr || this->_upper != max_jint) { + tty->print(" <= "); + if (this->_upper_instr) { + tty->print("i%d", this->_upper_instr->id()); + if (this->_upper > 0) { + tty->print("+%d", _upper); + } + if (this->_upper < 0) { + tty->print("%d", _upper); + } + } else { + tty->print("%d", _upper); + } + } +} + +// Copy +RangeCheckEliminator::Bound *RangeCheckEliminator::Bound::copy() { + Bound *b = new Bound(); + b->_lower = _lower; + b->_lower_instr = _lower_instr; + b->_upper = _upper; + b->_upper_instr = _upper_instr; + return b; +} + +#ifdef ASSERT +// Add assertion +void RangeCheckEliminator::Bound::add_assertion(Instruction *instruction, Instruction *position, int i, Value instr, Instruction::Condition cond) { + Instruction *result = position; + Instruction *compare_with = NULL; + ValueStack *state = position->state_before(); + if (position->as_BlockEnd() && !position->as_Goto()) { + state = position->as_BlockEnd()->state_before(); + } + Instruction *instruction_before = position->prev(); + if (position->as_Return() && Compilation::current()->method()->is_synchronized() && instruction_before->as_MonitorExit()) { + instruction_before = instruction_before->prev(); + } + result = instruction_before; + // Load constant only if needed + Constant *constant = NULL; + if (i != 0 || !instr) { + constant = new Constant(new IntConstant(i)); + NOT_PRODUCT(constant->set_printable_bci(position->printable_bci())); + result = result->insert_after(constant); + compare_with = constant; + } + + if (instr) { + assert(instr->type()->as_ObjectType() || instr->type()->as_IntType(), "Type must be array or integer!"); + compare_with = instr; + // Load array length if necessary + Instruction *op = instr; + if (instr->type()->as_ObjectType()) { + assert(state, "must not be null"); + ArrayLength *length = new ArrayLength(instr, state->copy()); + NOT_PRODUCT(length->set_printable_bci(position->printable_bci())); + length->set_exception_state(length->state_before()); + result = result->insert_after(length); + op = length; + compare_with = length; + } + // Add operation only if necessary + if (constant) { + ArithmeticOp *ao = new ArithmeticOp(Bytecodes::_iadd, constant, op, false, NULL); + NOT_PRODUCT(ao->set_printable_bci(position->printable_bci())); + result = result->insert_after(ao); + compare_with = ao; + // TODO: Check that add operation does not overflow! + } + } + assert(compare_with != NULL, "You have to compare with something!"); + assert(instruction != NULL, "Instruction must not be null!"); + + if (instruction->type()->as_ObjectType()) { + // Load array length if necessary + Instruction *op = instruction; + assert(state, "must not be null"); + ArrayLength *length = new ArrayLength(instruction, state->copy()); + length->set_exception_state(length->state_before()); + NOT_PRODUCT(length->set_printable_bci(position->printable_bci())); + result = result->insert_after(length); + instruction = length; + } + + Assert *assert = new Assert(instruction, cond, false, compare_with); + NOT_PRODUCT(assert->set_printable_bci(position->printable_bci())); + result->insert_after(assert); +} + +// Add assertions +void RangeCheckEliminator::add_assertions(Bound *bound, Instruction *instruction, Instruction *position) { + // Add lower bound assertion + if (bound->has_lower()) { + bound->add_assertion(instruction, position, bound->lower(), bound->lower_instr(), Instruction::geq); + } + // Add upper bound assertion + if (bound->has_upper()) { + bound->add_assertion(instruction, position, bound->upper(), bound->upper_instr(), Instruction::leq); + } +} +#endif + diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp new file mode 100644 index 00000000000..af6d9d94815 --- /dev/null +++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp @@ -0,0 +1,241 @@ +/* + * 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_C1_C1_RANGECHECKELIMINATION_HPP +#define SHARE_VM_C1_C1_RANGECHECKELIMINATION_HPP + +#include "c1/c1_Instruction.hpp" + +// Base class for range check elimination +class RangeCheckElimination : AllStatic { +public: + static void eliminate(IR *ir); +}; + +// Implementation +class RangeCheckEliminator VALUE_OBJ_CLASS_SPEC { +private: + int _number_of_instructions; + bool _optimistic; // Insert predicates and deoptimize when they fail + IR *_ir; + + define_array(BlockBeginArray, BlockBegin*) + define_stack(BlockBeginList, BlockBeginArray) + define_stack(IntegerStack, intArray) + define_array(IntegerMap, IntegerStack*) + + class Verification : public _ValueObj /*VALUE_OBJ_CLASS_SPEC*/, public BlockClosure { + private: + IR *_ir; + boolArray _used; + BlockBeginList _current; + BlockBeginList _successors; + + public: + Verification(IR *ir); + virtual void block_do(BlockBegin *block); + bool can_reach(BlockBegin *start, BlockBegin *end, BlockBegin *dont_use = NULL); + bool dominates(BlockBegin *dominator, BlockBegin *block); + }; + +public: + // Bounds for an instruction in the form x + c which c integer + // constant and x another instruction + class Bound : public CompilationResourceObj { + private: + int _upper; + Value _upper_instr; + int _lower; + Value _lower_instr; + + public: + Bound(); + Bound(Value v); + Bound(Instruction::Condition cond, Value v, int constant = 0); + Bound(int lower, Value lower_instr, int upper, Value upper_instr); + ~Bound(); + +#ifdef ASSERT + void add_assertion(Instruction *instruction, Instruction *position, int i, Value instr, Instruction::Condition cond); +#endif + int upper(); + Value upper_instr(); + int lower(); + Value lower_instr(); + void print(); + bool check_no_overflow(int const_value); + void or_op(Bound *b); + void and_op(Bound *b); + bool has_upper(); + bool has_lower(); + void set_upper(int upper, Value upper_instr); + void set_lower(int lower, Value lower_instr); + bool is_smaller(Bound *b); + void remove_upper(); + void remove_lower(); + void add_constant(int value); + Bound *copy(); + + private: + void init(); + }; + + + class Visitor : public InstructionVisitor { + private: + Bound *_bound; + RangeCheckEliminator *_rce; + + public: + void set_range_check_eliminator(RangeCheckEliminator *rce) { _rce = rce; } + Bound *bound() const { return _bound; } + void clear_bound() { _bound = NULL; } + + protected: + // visitor functions + void do_Constant (Constant* x); + void do_IfOp (IfOp* x); + void do_LogicOp (LogicOp* x); + void do_ArithmeticOp (ArithmeticOp* x); + void do_Phi (Phi* x); + + void do_StoreField (StoreField* x) { /* nothing to do */ }; + void do_StoreIndexed (StoreIndexed* x) { /* nothing to do */ }; + void do_MonitorEnter (MonitorEnter* x) { /* nothing to do */ }; + void do_MonitorExit (MonitorExit* x) { /* nothing to do */ }; + void do_Invoke (Invoke* x) { /* nothing to do */ }; + void do_UnsafePutRaw (UnsafePutRaw* x) { /* nothing to do */ }; + void do_UnsafePutObject(UnsafePutObject* x) { /* nothing to do */ }; + void do_Intrinsic (Intrinsic* x) { /* nothing to do */ }; + void do_Local (Local* x) { /* nothing to do */ }; + void do_LoadField (LoadField* x) { /* nothing to do */ }; + void do_ArrayLength (ArrayLength* x) { /* nothing to do */ }; + void do_LoadIndexed (LoadIndexed* x) { /* nothing to do */ }; + void do_NegateOp (NegateOp* x) { /* nothing to do */ }; + void do_ShiftOp (ShiftOp* x) { /* nothing to do */ }; + void do_CompareOp (CompareOp* x) { /* nothing to do */ }; + void do_Convert (Convert* x) { /* nothing to do */ }; + void do_NullCheck (NullCheck* x) { /* nothing to do */ }; + void do_TypeCast (TypeCast* x) { /* nothing to do */ }; + void do_NewInstance (NewInstance* x) { /* nothing to do */ }; + void do_NewTypeArray (NewTypeArray* x) { /* nothing to do */ }; + void do_NewObjectArray (NewObjectArray* x) { /* nothing to do */ }; + void do_NewMultiArray (NewMultiArray* x) { /* nothing to do */ }; + void do_CheckCast (CheckCast* x) { /* nothing to do */ }; + void do_InstanceOf (InstanceOf* x) { /* nothing to do */ }; + void do_BlockBegin (BlockBegin* x) { /* nothing to do */ }; + void do_Goto (Goto* x) { /* nothing to do */ }; + void do_If (If* x) { /* nothing to do */ }; + void do_IfInstanceOf (IfInstanceOf* x) { /* nothing to do */ }; + void do_TableSwitch (TableSwitch* x) { /* nothing to do */ }; + void do_LookupSwitch (LookupSwitch* x) { /* nothing to do */ }; + void do_Return (Return* x) { /* nothing to do */ }; + void do_Throw (Throw* x) { /* nothing to do */ }; + void do_Base (Base* x) { /* nothing to do */ }; + void do_OsrEntry (OsrEntry* x) { /* nothing to do */ }; + void do_ExceptionObject(ExceptionObject* x) { /* nothing to do */ }; + void do_RoundFP (RoundFP* x) { /* nothing to do */ }; + void do_UnsafeGetRaw (UnsafeGetRaw* x) { /* nothing to do */ }; + void do_UnsafeGetObject(UnsafeGetObject* x) { /* nothing to do */ }; + void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) { /* nothing to do */ }; + void do_UnsafePrefetchRead (UnsafePrefetchRead* x) { /* nothing to do */ }; + void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { /* nothing to do */ }; + void do_ProfileCall (ProfileCall* x) { /* nothing to do */ }; + void do_ProfileInvoke (ProfileInvoke* x) { /* nothing to do */ }; + void do_RuntimeCall (RuntimeCall* x) { /* nothing to do */ }; + void do_MemBar (MemBar* x) { /* nothing to do */ }; + void do_RangeCheckPredicate(RangeCheckPredicate* x) { /* nothing to do */ }; + void do_Assert (Assert* x) { /* nothing to do */ }; + }; + +#ifdef ASSERT + void add_assertions(Bound *bound, Instruction *instruction, Instruction *position); +#endif + + define_array(BoundArray, Bound *) + define_stack(BoundStack, BoundArray) + define_array(BoundMap, BoundStack *) + define_array(AccessIndexedArray, AccessIndexed *) + define_stack(AccessIndexedList, AccessIndexedArray) + define_array(InstructionArray, Instruction *) + define_stack(InstructionList, InstructionArray) + + class AccessIndexedInfo : public CompilationResourceObj { + public: + AccessIndexedList *_list; + int _min; + int _max; + }; + + define_array(AccessIndexedInfoArray, AccessIndexedInfo *) + BoundMap _bounds; // Mapping from Instruction's id to current bound + AccessIndexedInfoArray _access_indexed_info; // Mapping from Instruction's id to AccessIndexedInfo for in block motion + Visitor _visitor; + +public: + RangeCheckEliminator(IR *ir); + + IR *ir() const { return _ir; } + + // Pass over the dominator tree to identify blocks where there's an oppportunity for optimization + bool set_process_block_flags(BlockBegin *block); + // The core of the optimization work: pass over the dominator tree + // to propagate bound information, insert predicate out of loops, + // eliminate bound checks when possible and perform in block motion + void calc_bounds(BlockBegin *block, BlockBegin *loop_header); + // reorder bound checks within a block in order to eliminate some of them + void in_block_motion(BlockBegin *block, AccessIndexedList &accessIndexed, InstructionList &arrays); + + // update/access current bound + void update_bound(IntegerStack &pushed, Value v, Instruction::Condition cond, Value value, int constant); + void update_bound(IntegerStack &pushed, Value v, Bound *bound); + Bound *get_bound(Value v); + + bool loop_invariant(BlockBegin *loop_header, Instruction *instruction); // check for loop invariance + void add_access_indexed_info(InstructionList &indices, int i, Value instruction, AccessIndexed *ai); // record indexed access for in block motion + void remove_range_check(AccessIndexed *ai); // Mark this instructions as not needing a range check + void add_if_condition(IntegerStack &pushed, Value x, Value y, Instruction::Condition condition); // Update bound for an If + bool in_array_bound(Bound *bound, Value array); // Check whether bound is known to fall within array + + // helper functions to work with predicates + Instruction* insert_after(Instruction* insert_position, Instruction* instr, int bci); + Instruction* predicate(Instruction* left, Instruction::Condition cond, Instruction* right, ValueStack* state, Instruction *insert_position, int bci=-1); + Instruction* predicate_cmp_with_const(Instruction* instr, Instruction::Condition cond, int constant, ValueStack* state, Instruction *insert_position, int bci=1); + Instruction* predicate_add(Instruction* left, int left_const, Instruction::Condition cond, Instruction* right, ValueStack* state, Instruction *insert_position, int bci=-1); + Instruction* predicate_add_cmp_with_const(Instruction* left, int left_const, Instruction::Condition cond, int constant, ValueStack* state, Instruction *insert_position, int bci=-1); + + void insert_deoptimization(ValueStack *state, Instruction *insert_position, Instruction *array_instr, // Add predicate + Instruction *length_instruction, Instruction *lower_instr, int lower, + Instruction *upper_instr, int upper, AccessIndexed *ai); + bool is_ok_for_deoptimization(Instruction *insert_position, Instruction *array_instr, // Can we safely add a predicate? + Instruction *length_instr, Instruction *lower_instr, + int lower, Instruction *upper_instr, int upper); + void process_if(IntegerStack &pushed, BlockBegin *block, If *cond); // process If Instruction + void process_access_indexed(BlockBegin *loop_header, BlockBegin *block, AccessIndexed *ai); // process indexed access + + void dump_condition_stack(BlockBegin *cur_block); + static void print_statistics(); +}; + +#endif // SHARE_VM_C1_C1_RANGECHECKELIMINATION_HPP diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp index 3002c1304a1..e274076d06b 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp @@ -1330,6 +1330,50 @@ JRT_LEAF(int, Runtime1::is_instance_of(oopDesc* mirror, oopDesc* obj)) return (k != NULL && obj != NULL && obj->is_a(k)) ? 1 : 0; JRT_END +JRT_ENTRY(void, Runtime1::predicate_failed_trap(JavaThread* thread)) + ResourceMark rm; + + assert(!TieredCompilation, "incompatible with tiered compilation"); + + RegisterMap reg_map(thread, false); + frame runtime_frame = thread->last_frame(); + frame caller_frame = runtime_frame.sender(®_map); + + nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); + assert (nm != NULL, "no more nmethod?"); + nm->make_not_entrant(); + + methodHandle m(nm->method()); + MethodData* mdo = m->method_data(); + + if (mdo == NULL && !HAS_PENDING_EXCEPTION) { + // Build an MDO. Ignore errors like OutOfMemory; + // that simply means we won't have an MDO to update. + Method::build_interpreter_method_data(m, THREAD); + if (HAS_PENDING_EXCEPTION) { + assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here"); + CLEAR_PENDING_EXCEPTION; + } + mdo = m->method_data(); + } + + if (mdo != NULL) { + mdo->inc_trap_count(Deoptimization::Reason_none); + } + + if (TracePredicateFailedTraps) { + stringStream ss1, ss2; + vframeStream vfst(thread); + methodHandle inlinee = methodHandle(vfst.method()); + inlinee->print_short_name(&ss1); + m->print_short_name(&ss2); + tty->print_cr("Predicate failed trap in method %s at bci %d inlined in %s at pc %x", ss1.as_string(), vfst.bci(), ss2.as_string(), caller_frame.pc()); + } + + + Deoptimization::deoptimize_frame(thread, caller_frame.id()); + +JRT_END #ifndef PRODUCT void Runtime1::print_statistics() { diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.hpp b/hotspot/src/share/vm/c1/c1_Runtime1.hpp index 06ef147a9f1..9b12d26226e 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.hpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.hpp @@ -71,6 +71,7 @@ class StubAssembler; stub(g1_post_barrier_slow) \ stub(fpu2long_stub) \ stub(counter_overflow) \ + stub(predicate_failed_trap) \ last_entry(number_of_ids) #define DECLARE_STUB_ID(x) x ## _id , @@ -190,6 +191,8 @@ class Runtime1: public AllStatic { static void oop_arraycopy(HeapWord* src, HeapWord* dst, int length); static int is_instance_of(oopDesc* mirror, oopDesc* obj); + static void predicate_failed_trap(JavaThread* thread); + static void print_statistics() PRODUCT_RETURN; }; diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.cpp b/hotspot/src/share/vm/c1/c1_ValueMap.cpp index a759854102a..fb9b931e336 100644 --- a/hotspot/src/share/vm/c1/c1_ValueMap.cpp +++ b/hotspot/src/share/vm/c1/c1_ValueMap.cpp @@ -26,9 +26,9 @@ #include "c1/c1_Canonicalizer.hpp" #include "c1/c1_IR.hpp" #include "c1/c1_ValueMap.hpp" +#include "c1/c1_ValueStack.hpp" #include "utilities/bitMap.inline.hpp" - #ifndef PRODUCT int ValueMap::_number_of_finds = 0; @@ -192,10 +192,6 @@ Value ValueMap::find_insert(Value x) { && lf->field()->holder() == field->holder() \ && (all_offsets || lf->field()->offset() == field->offset()); -#define MUST_KILL_EXCEPTION(must_kill, entry, value) \ - assert(entry->nesting() < nesting(), "must not find bigger nesting than current"); \ - bool must_kill = (entry->nesting() == nesting() - 1); - void ValueMap::kill_memory() { GENERIC_KILL_VALUE(MUST_KILL_MEMORY); @@ -209,11 +205,6 @@ void ValueMap::kill_field(ciField* field, bool all_offsets) { GENERIC_KILL_VALUE(MUST_KILL_FIELD); } -void ValueMap::kill_exception() { - GENERIC_KILL_VALUE(MUST_KILL_EXCEPTION); -} - - void ValueMap::kill_map(ValueMap* map) { assert(is_global_value_numbering(), "only for global value numbering"); _killed_values.set_union(&map->_killed_values); @@ -274,6 +265,8 @@ class ShortLoopOptimizer : public ValueNumberingVisitor { GlobalValueNumbering* _gvn; BlockList _loop_blocks; bool _too_complicated_loop; + bool _has_field_store[T_ARRAY + 1]; + bool _has_indexed_store[T_ARRAY + 1]; // simplified access to methods of GlobalValueNumbering ValueMap* current_map() { return _gvn->current_map(); } @@ -281,8 +274,16 @@ class ShortLoopOptimizer : public ValueNumberingVisitor { // implementation for abstract methods of ValueNumberingVisitor void kill_memory() { _too_complicated_loop = true; } - void kill_field(ciField* field, bool all_offsets) { current_map()->kill_field(field, all_offsets); }; - void kill_array(ValueType* type) { current_map()->kill_array(type); }; + void kill_field(ciField* field, bool all_offsets) { + current_map()->kill_field(field, all_offsets); + assert(field->type()->basic_type() >= 0 && field->type()->basic_type() <= T_ARRAY, "Invalid type"); + _has_field_store[field->type()->basic_type()] = true; + } + void kill_array(ValueType* type) { + current_map()->kill_array(type); + BasicType basic_type = as_BasicType(type); assert(basic_type >= 0 && basic_type <= T_ARRAY, "Invalid type"); + _has_indexed_store[basic_type] = true; + } public: ShortLoopOptimizer(GlobalValueNumbering* gvn) @@ -290,11 +291,141 @@ class ShortLoopOptimizer : public ValueNumberingVisitor { , _loop_blocks(ValueMapMaxLoopSize) , _too_complicated_loop(false) { + for (int i=0; i<= T_ARRAY; i++){ + _has_field_store[i] = false; + _has_indexed_store[i] = false; + } + } + + bool has_field_store(BasicType type) { + assert(type >= 0 && type <= T_ARRAY, "Invalid type"); + return _has_field_store[type]; + } + + bool has_indexed_store(BasicType type) { + assert(type >= 0 && type <= T_ARRAY, "Invalid type"); + return _has_indexed_store[type]; } bool process(BlockBegin* loop_header); }; +class LoopInvariantCodeMotion : public StackObj { + private: + GlobalValueNumbering* _gvn; + ShortLoopOptimizer* _short_loop_optimizer; + Instruction* _insertion_point; + ValueStack * _state; + + void set_invariant(Value v) const { _gvn->set_processed(v); } + bool is_invariant(Value v) const { return _gvn->is_processed(v); } + + void process_block(BlockBegin* block); + + public: + LoopInvariantCodeMotion(ShortLoopOptimizer *slo, GlobalValueNumbering* gvn, BlockBegin* loop_header, BlockList* loop_blocks); +}; + +LoopInvariantCodeMotion::LoopInvariantCodeMotion(ShortLoopOptimizer *slo, GlobalValueNumbering* gvn, BlockBegin* loop_header, BlockList* loop_blocks) + : _gvn(gvn), _short_loop_optimizer(slo) { + + TRACE_VALUE_NUMBERING(tty->print_cr("using loop invariant code motion loop_header = %d", loop_header->block_id())); + TRACE_VALUE_NUMBERING(tty->print_cr("** loop invariant code motion for short loop B%d", loop_header->block_id())); + + BlockBegin* insertion_block = loop_header->dominator(); + if (insertion_block->number_of_preds() == 0) { + return; // only the entry block does not have a predecessor + } + + assert(insertion_block->end()->as_Base() == NULL, "cannot insert into entry block"); + _insertion_point = insertion_block->end()->prev(); + + BlockEnd *block_end = insertion_block->end(); + _state = block_end->state_before(); + + if (!_state) { + // If, TableSwitch and LookupSwitch always have state_before when + // loop invariant code motion happens.. + assert(block_end->as_Goto(), "Block has to be goto"); + _state = block_end->state(); + } + + // the loop_blocks are filled by going backward from the loop header, so this processing order is best + assert(loop_blocks->at(0) == loop_header, "loop header must be first loop block"); + process_block(loop_header); + for (int i = loop_blocks->length() - 1; i >= 1; i--) { + process_block(loop_blocks->at(i)); + } +} + +void LoopInvariantCodeMotion::process_block(BlockBegin* block) { + TRACE_VALUE_NUMBERING(tty->print_cr("processing block B%d", block->block_id())); + + Instruction* prev = block; + Instruction* cur = block->next(); + + while (cur != NULL) { + + // determine if cur instruction is loop invariant + // only selected instruction types are processed here + bool cur_invariant = false; + + if (cur->as_Constant() != NULL) { + cur_invariant = !cur->can_trap(); + } else if (cur->as_ArithmeticOp() != NULL || cur->as_LogicOp() != NULL || cur->as_ShiftOp() != NULL) { + assert(cur->as_Op2() != NULL, "must be Op2"); + Op2* op2 = (Op2*)cur; + cur_invariant = !op2->can_trap() && is_invariant(op2->x()) && is_invariant(op2->y()); + } else if (cur->as_LoadField() != NULL) { + LoadField* lf = (LoadField*)cur; + // deoptimizes on NullPointerException + cur_invariant = !lf->needs_patching() && !lf->field()->is_volatile() && !_short_loop_optimizer->has_field_store(lf->field()->type()->basic_type()) && is_invariant(lf->obj()); + } else if (cur->as_ArrayLength() != NULL) { + ArrayLength *length = cur->as_ArrayLength(); + cur_invariant = is_invariant(length->array()); + } else if (cur->as_LoadIndexed() != NULL) { + LoadIndexed *li = (LoadIndexed *)cur->as_LoadIndexed(); + cur_invariant = !_short_loop_optimizer->has_indexed_store(as_BasicType(cur->type())) && is_invariant(li->array()) && is_invariant(li->index()); + } + + if (cur_invariant) { + // perform value numbering and mark instruction as loop-invariant + _gvn->substitute(cur); + + if (cur->as_Constant() == NULL) { + // ensure that code for non-constant instructions is always generated + cur->pin(); + } + + // remove cur instruction from loop block and append it to block before loop + Instruction* next = cur->next(); + Instruction* in = _insertion_point->next(); + _insertion_point = _insertion_point->set_next(cur); + cur->set_next(in); + + // Deoptimize on exception + cur->set_flag(Instruction::DeoptimizeOnException, true); + + // Clear exception handlers + cur->set_exception_handlers(NULL); + + TRACE_VALUE_NUMBERING(tty->print_cr("Instruction %c%d is loop invariant", cur->type()->tchar(), cur->id())); + + if (cur->state_before() != NULL) { + cur->set_state_before(_state->copy()); + } + if (cur->exception_state() != NULL) { + cur->set_exception_state(_state->copy()); + } + + cur = prev->set_next(next); + + } else { + prev = cur; + cur = cur->next(); + } + } +} bool ShortLoopOptimizer::process(BlockBegin* loop_header) { TRACE_VALUE_NUMBERING(tty->print_cr("** loop header block")); @@ -316,6 +447,10 @@ bool ShortLoopOptimizer::process(BlockBegin* loop_header) { for (int j = block->number_of_preds() - 1; j >= 0; j--) { BlockBegin* pred = block->pred_at(j); + if (pred->is_set(BlockBegin::osr_entry_flag)) { + return false; + } + ValueMap* pred_map = value_map_of(pred); if (pred_map != NULL) { current_map()->kill_map(pred_map); @@ -336,6 +471,12 @@ bool ShortLoopOptimizer::process(BlockBegin* loop_header) { } } + bool optimistic = this->_gvn->compilation()->is_optimistic(); + + if (UseLoopInvariantCodeMotion && optimistic) { + LoopInvariantCodeMotion code_motion(this, _gvn, loop_header, &_loop_blocks); + } + TRACE_VALUE_NUMBERING(tty->print_cr("** loop successfully optimized")); return true; } @@ -344,11 +485,11 @@ bool ShortLoopOptimizer::process(BlockBegin* loop_header) { GlobalValueNumbering::GlobalValueNumbering(IR* ir) : _current_map(NULL) , _value_maps(ir->linear_scan_order()->length(), NULL) + , _compilation(ir->compilation()) { TRACE_VALUE_NUMBERING(tty->print_cr("****** start of global value numbering")); ShortLoopOptimizer short_loop_optimizer(this); - int subst_count = 0; BlockList* blocks = ir->linear_scan_order(); int num_blocks = blocks->length(); @@ -357,6 +498,12 @@ GlobalValueNumbering::GlobalValueNumbering(IR* ir) assert(start_block == ir->start() && start_block->number_of_preds() == 0 && start_block->dominator() == NULL, "must be start block"); assert(start_block->next()->as_Base() != NULL && start_block->next()->next() == NULL, "start block must not have instructions"); + // method parameters are not linked in instructions list, so process them separateley + for_each_state_value(start_block->state(), value, + assert(value->as_Local() != NULL, "only method parameters allowed"); + set_processed(value); + ); + // initial, empty value map with nesting 0 set_value_map_of(start_block, new ValueMap()); @@ -374,7 +521,7 @@ GlobalValueNumbering::GlobalValueNumbering(IR* ir) // create new value map with increased nesting _current_map = new ValueMap(value_map_of(dominator)); - if (num_preds == 1) { + if (num_preds == 1 && !block->is_set(BlockBegin::exception_entry_flag)) { assert(dominator == block->pred_at(0), "dominator must be equal to predecessor"); // nothing to do here @@ -403,36 +550,41 @@ GlobalValueNumbering::GlobalValueNumbering(IR* ir) } } - if (block->is_set(BlockBegin::exception_entry_flag)) { - current_map()->kill_exception(); - } + // phi functions are not linked in instructions list, so process them separateley + for_each_phi_fun(block, phi, + set_processed(phi); + ); TRACE_VALUE_NUMBERING(tty->print("value map before processing block: "); current_map()->print()); // visit all instructions of this block for (Value instr = block->next(); instr != NULL; instr = instr->next()) { - assert(!instr->has_subst(), "substitution already set"); - // check if instruction kills any values instr->visit(this); - - if (instr->hash() != 0) { - Value f = current_map()->find_insert(instr); - if (f != instr) { - assert(!f->has_subst(), "can't have a substitution"); - instr->set_subst(f); - subst_count++; - } - } + // perform actual value numbering + substitute(instr); } // remember value map for successors set_value_map_of(block, current_map()); } - if (subst_count != 0) { + if (_has_substitutions) { SubstitutionResolver resolver(ir); } TRACE_VALUE_NUMBERING(tty->print("****** end of global value numbering. "); ValueMap::print_statistics()); } + +void GlobalValueNumbering::substitute(Instruction* instr) { + assert(!instr->has_subst(), "substitution already set"); + Value subst = current_map()->find_insert(instr); + if (subst != instr) { + assert(!subst->has_subst(), "can't have a substitution"); + + TRACE_VALUE_NUMBERING(tty->print_cr("substitution for %d set to %d", instr->id(), subst->id())); + instr->set_subst(subst); + _has_substitutions = true; + } + set_processed(instr); +} diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.hpp b/hotspot/src/share/vm/c1/c1_ValueMap.hpp index 07dd9ddfb3d..c76ef46bef4 100644 --- a/hotspot/src/share/vm/c1/c1_ValueMap.hpp +++ b/hotspot/src/share/vm/c1/c1_ValueMap.hpp @@ -206,6 +206,8 @@ class ValueNumberingVisitor: public InstructionVisitor { void do_ProfileInvoke (ProfileInvoke* x) { /* nothing to do */ }; void do_RuntimeCall (RuntimeCall* x) { /* nothing to do */ }; void do_MemBar (MemBar* x) { /* nothing to do */ }; + void do_RangeCheckPredicate(RangeCheckPredicate* x) { /* nothing to do */ }; + void do_Assert (Assert* x) { /* nothing to do */ }; }; @@ -225,15 +227,22 @@ class ValueNumberingEffects: public ValueNumberingVisitor { class GlobalValueNumbering: public ValueNumberingVisitor { private: + Compilation* _compilation; // compilation data ValueMap* _current_map; // value map of current block ValueMapArray _value_maps; // list of value maps for all blocks + ValueSet _processed_values; // marker for instructions that were already processed + bool _has_substitutions; // set to true when substitutions must be resolved public: // accessors + Compilation* compilation() const { return _compilation; } ValueMap* current_map() { return _current_map; } ValueMap* value_map_of(BlockBegin* block) { return _value_maps.at(block->linear_scan_number()); } void set_value_map_of(BlockBegin* block, ValueMap* map) { assert(value_map_of(block) == NULL, ""); _value_maps.at_put(block->linear_scan_number(), map); } + bool is_processed(Value v) { return _processed_values.contains(v); } + void set_processed(Value v) { _processed_values.put(v); } + // implementation for abstract methods of ValueNumberingVisitor void kill_memory() { current_map()->kill_memory(); } void kill_field(ciField* field, bool all_offsets) { current_map()->kill_field(field, all_offsets); } @@ -241,6 +250,7 @@ class GlobalValueNumbering: public ValueNumberingVisitor { // main entry point that performs global value numbering GlobalValueNumbering(IR* ir); + void substitute(Instruction* instr); // substitute instruction if it is contained in current value map }; #endif // SHARE_VM_C1_C1_VALUEMAP_HPP diff --git a/hotspot/src/share/vm/c1/c1_globals.hpp b/hotspot/src/share/vm/c1/c1_globals.hpp index 16451f6d526..844880be256 100644 --- a/hotspot/src/share/vm/c1/c1_globals.hpp +++ b/hotspot/src/share/vm/c1/c1_globals.hpp @@ -119,6 +119,24 @@ develop(bool, UseGlobalValueNumbering, true, \ "Use Global Value Numbering (separate phase)") \ \ + product(bool, UseLoopInvariantCodeMotion, true, \ + "Simple loop invariant code motion for short loops during GVN") \ + \ + develop(bool, TracePredicateFailedTraps, false, \ + "trace runtime traps caused by predicate failure") \ + \ + develop(bool, StressLoopInvariantCodeMotion, false, \ + "stress loop invariant code motion") \ + \ + develop(bool, TraceRangeCheckElimination, false, \ + "Trace Range Check Elimination") \ + \ + develop(bool, AssertRangeCheckElimination, false, \ + "Assert Range Check Elimination") \ + \ + develop(bool, StressRangeCheckElimination, false, \ + "stress Range Check Elimination") \ + \ develop(bool, PrintValueNumbering, false, \ "Print Value Numbering") \ \ diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index 1b1e2d1cdd5..63207d082be 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -2166,6 +2166,9 @@ void CompileBroker::print_times() { comp->print_timers(); } tty->cr(); + tty->print_cr(" Total compiled methods : %6d methods", CompileBroker::_total_compile_count); + tty->print_cr(" Standard compilation : %6d methods", CompileBroker::_total_standard_compile_count); + tty->print_cr(" On stack replacement : %6d methods", CompileBroker::_total_osr_compile_count); int tcb = CompileBroker::_sum_osr_bytes_compiled + CompileBroker::_sum_standard_bytes_compiled; tty->print_cr(" Total compiled bytecodes : %6d bytes", tcb); tty->print_cr(" Standard compilation : %6d bytes", CompileBroker::_sum_standard_bytes_compiled); diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index e296c501ccb..78d158a86d6 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -2228,8 +2228,6 @@ void InstanceKlass::clean_implementors_list(BoolObjectClosure* is_alive) { } void InstanceKlass::clean_method_data(BoolObjectClosure* is_alive) { -#ifdef COMPILER2 - // Currently only used by C2. for (int m = 0; m < methods()->length(); m++) { MethodData* mdo = methods()->at(m)->method_data(); if (mdo != NULL) { @@ -2240,15 +2238,6 @@ void InstanceKlass::clean_method_data(BoolObjectClosure* is_alive) { } } } -#else -#ifdef ASSERT - // Verify that we haven't started to use MDOs for C1. - for (int m = 0; m < methods()->length(); m++) { - MethodData* mdo = methods()->at(m)->method_data(); - assert(mdo == NULL, "Didn't expect C1 to use MDOs"); - } -#endif // ASSERT -#endif // !COMPILER2 } diff --git a/hotspot/src/share/vm/oops/methodData.cpp b/hotspot/src/share/vm/oops/methodData.cpp index c9687fb32b6..e43b93bafc0 100644 --- a/hotspot/src/share/vm/oops/methodData.cpp +++ b/hotspot/src/share/vm/oops/methodData.cpp @@ -392,6 +392,9 @@ MethodData* MethodData::allocate(ClassLoaderData* loader_data, methodHandle meth } int MethodData::bytecode_cell_count(Bytecodes::Code code) { +#if defined(COMPILER1) && !defined(COMPILER2) + return no_profile_data; +#else switch (code) { case Bytecodes::_checkcast: case Bytecodes::_instanceof: @@ -438,6 +441,7 @@ int MethodData::bytecode_cell_count(Bytecodes::Code code) { return variable_cell_count; } return no_profile_data; +#endif } // Compute the size of the profiling information corresponding to @@ -509,6 +513,9 @@ int MethodData::compute_allocation_size_in_words(methodHandle method) { // the segment in bytes. int MethodData::initialize_data(BytecodeStream* stream, int data_index) { +#if defined(COMPILER1) && !defined(COMPILER2) + return 0; +#else int cell_count = -1; int tag = DataLayout::no_tag; DataLayout* data_layout = data_layout_at(data_index); @@ -587,6 +594,7 @@ int MethodData::initialize_data(BytecodeStream* stream, assert(!bytecode_has_profile(c), "agree w/ !BHP"); return 0; } +#endif } // Get the data at an arbitrary (sort of) data index. diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 9645f625a85..caf44b4b148 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -2515,7 +2515,7 @@ class CommandLineFlags { "disable locking assertions (for speed)") \ \ product(bool, RangeCheckElimination, true, \ - "Split loop iterations to eliminate range checks") \ + "Eliminate range checks") \ \ develop_pd(bool, UncommonNullCast, \ "track occurrences of null in casts; adjust compiler tactics") \ From 6132db352dc632d3db74d022db174f27a4a65948 Mon Sep 17 00:00:00 2001 From: Bharadwaj Yadavalli Date: Fri, 22 Mar 2013 07:58:55 -0700 Subject: [PATCH 02/52] 8009539: JVM crash when run lambda testng tests Ensure class pointer is non-null before dereferencing it to check if it is loaded. Reviewed-by: kvn --- hotspot/src/share/vm/opto/parse2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/opto/parse2.cpp b/hotspot/src/share/vm/opto/parse2.cpp index 9a14c9a58f9..73be6aae570 100644 --- a/hotspot/src/share/vm/opto/parse2.cpp +++ b/hotspot/src/share/vm/opto/parse2.cpp @@ -104,7 +104,8 @@ Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) { if (C->log() != NULL) C->log()->elem("observe that='!need_range_check'"); } - if (!arytype->klass()->is_loaded()) { + ciKlass * arytype_klass = arytype->klass(); + if ((arytype_klass != NULL) && (!arytype_klass->is_loaded())) { // Only fails for some -Xcomp runs // The class is unloaded. We have to run this bytecode in the interpreter. uncommon_trap(Deoptimization::Reason_unloaded, @@ -1385,6 +1386,7 @@ void Parse::do_one_bytecode() { if (TraceOptoParse) { tty->print(" @"); dump_bci(bci()); + tty->cr(); } #endif From 89120e782752b06fce36ec69737cf2f34f1c0cc2 Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Thu, 28 Mar 2013 10:27:28 +0100 Subject: [PATCH 03/52] 7014552: gc/lock/jni/jnilockXXX works too slow on 1-processor machine Keep a counter of how many times we were stalled by the GC locker, add a diagnostic flag which sets the limit. Reviewed-by: brutisso, ehelin, johnc --- .../gc_implementation/g1/g1CollectedHeap.cpp | 30 +++++++++++++++---- .../gc_implementation/g1/g1CollectedHeap.hpp | 9 ++++-- .../g1/g1CollectedHeap.inline.hpp | 7 +++-- .../parallelScavenge/parallelScavengeHeap.cpp | 6 ++++ .../src/share/vm/memory/collectorPolicy.cpp | 7 ++++- hotspot/src/share/vm/runtime/globals.hpp | 4 +++ 6 files changed, 51 insertions(+), 12 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 64647979045..780e330b4f8 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -854,7 +854,8 @@ HeapWord* G1CollectedHeap::allocate_new_tlab(size_t word_size) { assert(!isHumongous(word_size), "we do not allow humongous TLABs"); unsigned int dummy_gc_count_before; - return attempt_allocation(word_size, &dummy_gc_count_before); + int dummy_gclocker_retry_count = 0; + return attempt_allocation(word_size, &dummy_gc_count_before, &dummy_gclocker_retry_count); } HeapWord* @@ -863,14 +864,14 @@ G1CollectedHeap::mem_allocate(size_t word_size, assert_heap_not_locked_and_not_at_safepoint(); // Loop until the allocation is satisified, or unsatisfied after GC. - for (int try_count = 1; /* we'll return */; try_count += 1) { + for (int try_count = 1, gclocker_retry_count = 0; /* we'll return */; try_count += 1) { unsigned int gc_count_before; HeapWord* result = NULL; if (!isHumongous(word_size)) { - result = attempt_allocation(word_size, &gc_count_before); + result = attempt_allocation(word_size, &gc_count_before, &gclocker_retry_count); } else { - result = attempt_allocation_humongous(word_size, &gc_count_before); + result = attempt_allocation_humongous(word_size, &gc_count_before, &gclocker_retry_count); } if (result != NULL) { return result; @@ -894,6 +895,9 @@ G1CollectedHeap::mem_allocate(size_t word_size, } return result; } else { + if (gclocker_retry_count > GCLockerRetryAllocationCount) { + return NULL; + } assert(op.result() == NULL, "the result should be NULL if the VM op did not succeed"); } @@ -910,7 +914,8 @@ G1CollectedHeap::mem_allocate(size_t word_size, } HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size, - unsigned int *gc_count_before_ret) { + unsigned int *gc_count_before_ret, + int* gclocker_retry_count_ret) { // Make sure you read the note in attempt_allocation_humongous(). assert_heap_not_locked_and_not_at_safepoint(); @@ -986,10 +991,16 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size, return NULL; } } else { + if (*gclocker_retry_count_ret > GCLockerRetryAllocationCount) { + MutexLockerEx x(Heap_lock); + *gc_count_before_ret = total_collections(); + return NULL; + } // The GCLocker is either active or the GCLocker initiated // GC has not yet been performed. Stall until it is and // then retry the allocation. GC_locker::stall_until_clear(); + (*gclocker_retry_count_ret) += 1; } // We can reach here if we were unsuccessul in scheduling a @@ -1019,7 +1030,8 @@ HeapWord* G1CollectedHeap::attempt_allocation_slow(size_t word_size, } HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size, - unsigned int * gc_count_before_ret) { + unsigned int * gc_count_before_ret, + int* gclocker_retry_count_ret) { // The structure of this method has a lot of similarities to // attempt_allocation_slow(). The reason these two were not merged // into a single one is that such a method would require several "if @@ -1104,10 +1116,16 @@ HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size, return NULL; } } else { + if (*gclocker_retry_count_ret > GCLockerRetryAllocationCount) { + MutexLockerEx x(Heap_lock); + *gc_count_before_ret = total_collections(); + return NULL; + } // The GCLocker is either active or the GCLocker initiated // GC has not yet been performed. Stall until it is and // then retry the allocation. GC_locker::stall_until_clear(); + (*gclocker_retry_count_ret) += 1; } // We can reach here if we were unsuccessul in scheduling a diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index 7dc5bd83047..557daf85eea 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -559,18 +559,21 @@ protected: // the mutator alloc region without taking the Heap_lock. This // should only be used for non-humongous allocations. inline HeapWord* attempt_allocation(size_t word_size, - unsigned int* gc_count_before_ret); + unsigned int* gc_count_before_ret, + int* gclocker_retry_count_ret); // Second-level mutator allocation attempt: take the Heap_lock and // retry the allocation attempt, potentially scheduling a GC // pause. This should only be used for non-humongous allocations. HeapWord* attempt_allocation_slow(size_t word_size, - unsigned int* gc_count_before_ret); + unsigned int* gc_count_before_ret, + int* gclocker_retry_count_ret); // Takes the Heap_lock and attempts a humongous allocation. It can // potentially schedule a GC pause. HeapWord* attempt_allocation_humongous(size_t word_size, - unsigned int* gc_count_before_ret); + unsigned int* gc_count_before_ret, + int* gclocker_retry_count_ret); // Allocation attempt that should be called during safepoints (e.g., // at the end of a successful GC). expect_null_mutator_alloc_region diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp index 4f9c7726292..20eb1693c43 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp @@ -60,7 +60,8 @@ inline bool G1CollectedHeap::obj_in_cs(oop obj) { inline HeapWord* G1CollectedHeap::attempt_allocation(size_t word_size, - unsigned int* gc_count_before_ret) { + unsigned int* gc_count_before_ret, + int* gclocker_retry_count_ret) { assert_heap_not_locked_and_not_at_safepoint(); assert(!isHumongous(word_size), "attempt_allocation() should not " "be called for humongous allocation requests"); @@ -68,7 +69,9 @@ G1CollectedHeap::attempt_allocation(size_t word_size, HeapWord* result = _mutator_alloc_region.attempt_allocation(word_size, false /* bot_updates */); if (result == NULL) { - result = attempt_allocation_slow(word_size, gc_count_before_ret); + result = attempt_allocation_slow(word_size, + gc_count_before_ret, + gclocker_retry_count_ret); } assert_heap_not_locked(); if (result != NULL) { diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp index 0c39e69e1be..5d77e31b6c8 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp @@ -326,6 +326,7 @@ HeapWord* ParallelScavengeHeap::mem_allocate( uint loop_count = 0; uint gc_count = 0; + int gclocker_stalled_count = 0; while (result == NULL) { // We don't want to have multiple collections for a single filled generation. @@ -354,6 +355,10 @@ HeapWord* ParallelScavengeHeap::mem_allocate( return result; } + if (gclocker_stalled_count > GCLockerRetryAllocationCount) { + return NULL; + } + // Failed to allocate without a gc. if (GC_locker::is_active_and_needs_gc()) { // If this thread is not in a jni critical section, we stall @@ -366,6 +371,7 @@ HeapWord* ParallelScavengeHeap::mem_allocate( if (!jthr->in_critical()) { MutexUnlocker mul(Heap_lock); GC_locker::stall_until_clear(); + gclocker_stalled_count += 1; continue; } else { if (CheckJNICalls) { diff --git a/hotspot/src/share/vm/memory/collectorPolicy.cpp b/hotspot/src/share/vm/memory/collectorPolicy.cpp index d5eb387a04c..a2049597af7 100644 --- a/hotspot/src/share/vm/memory/collectorPolicy.cpp +++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp @@ -532,7 +532,7 @@ HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size, // Loop until the allocation is satisified, // or unsatisfied after GC. - for (int try_count = 1; /* return or throw */; try_count += 1) { + for (int try_count = 1, gclocker_stalled_count = 0; /* return or throw */; try_count += 1) { HandleMark hm; // discard any handles allocated in each iteration // First allocation attempt is lock-free. @@ -576,6 +576,10 @@ HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size, } } + if (gclocker_stalled_count > GCLockerRetryAllocationCount) { + return NULL; // we didn't get to do a GC and we didn't get any memory + } + // If this thread is not in a jni critical section, we stall // the requestor until the critical section has cleared and // GC allowed. When the critical section clears, a GC is @@ -587,6 +591,7 @@ HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size, MutexUnlocker mul(Heap_lock); // Wait for JNI critical section to be exited GC_locker::stall_until_clear(); + gclocker_stalled_count += 1; continue; } else { if (CheckJNICalls) { diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 9645f625a85..d59bc735ed7 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1402,6 +1402,10 @@ class CommandLineFlags { "How much the GC can expand the eden by while the GC locker " \ "is active (as a percentage)") \ \ + diagnostic(intx, GCLockerRetryAllocationCount, 2, \ + "Number of times to retry allocations when" \ + " blocked by the GC locker") \ + \ develop(bool, UseCMSAdaptiveFreeLists, true, \ "Use Adaptive Free Lists in the CMS generation") \ \ From bb5bd507d76bc669919979d66c95f3427cb10e1c Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Wed, 27 Mar 2013 19:21:18 +0100 Subject: [PATCH 04/52] 7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM Ergonomics now also takes available virtual memory into account when deciding for a heap size. The helper method to determine the maximum allocatable memory block now uses the appropriate OS specific calls to retrieve available virtual memory for the java process. In 32 bit environments this method now also searches for the maximum actually reservable amount of memory. Merge previously separate implementations for Linux/BSD/Solaris into a single method. Reviewed-by: jmasa, tamao --- hotspot/src/os/bsd/vm/os_bsd.cpp | 14 ----- hotspot/src/os/linux/vm/os_linux.cpp | 14 ----- hotspot/src/os/posix/vm/os_posix.cpp | 62 ++++++++++++++++++++++ hotspot/src/os/solaris/vm/os_solaris.cpp | 18 ------- hotspot/src/os/windows/vm/os_windows.cpp | 11 ++-- hotspot/src/share/vm/runtime/arguments.cpp | 21 +++++--- hotspot/src/share/vm/runtime/arguments.hpp | 3 ++ hotspot/src/share/vm/runtime/globals.hpp | 4 ++ hotspot/src/share/vm/runtime/os.hpp | 2 +- 9 files changed, 92 insertions(+), 57 deletions(-) diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index a09db37288f..d062b048a46 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -167,20 +167,6 @@ julong os::physical_memory() { return Bsd::physical_memory(); } -julong os::allocatable_physical_memory(julong size) { -#ifdef _LP64 - return size; -#else - julong result = MIN2(size, (julong)3800*M); - if (!is_allocatable(result)) { - // See comments under solaris for alignment considerations - julong reasonable_size = (julong)2*G - 2 * os::vm_page_size(); - result = MIN2(size, reasonable_size); - } - return result; -#endif // _LP64 -} - //////////////////////////////////////////////////////////////////////////////// // environment support diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 59cb59d6805..7e9250f3909 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -194,20 +194,6 @@ julong os::physical_memory() { return Linux::physical_memory(); } -julong os::allocatable_physical_memory(julong size) { -#ifdef _LP64 - return size; -#else - julong result = MIN2(size, (julong)3800*M); - if (!is_allocatable(result)) { - // See comments under solaris for alignment considerations - julong reasonable_size = (julong)2*G - 2 * os::vm_page_size(); - result = MIN2(size, reasonable_size); - } - return result; -#endif // _LP64 -} - //////////////////////////////////////////////////////////////////////////////// // environment support diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp index af75b3b362d..03302783688 100644 --- a/hotspot/src/os/posix/vm/os_posix.cpp +++ b/hotspot/src/os/posix/vm/os_posix.cpp @@ -188,4 +188,66 @@ void os::Posix::print_uname_info(outputStream* st) { st->cr(); } +bool os::has_allocatable_memory_limit(julong* limit) { + struct rlimit rlim; + int getrlimit_res = getrlimit(RLIMIT_AS, &rlim); + // if there was an error when calling getrlimit, assume that there is no limitation + // on virtual memory. + bool result; + if ((getrlimit_res != 0) || (rlim.rlim_cur == RLIM_INFINITY)) { + result = false; + } else { + *limit = (julong)rlim.rlim_cur; + result = true; + } +#ifdef _LP64 + return result; +#else + // arbitrary virtual space limit for 32 bit Unices found by testing. If + // getrlimit above returned a limit, bound it with this limit. Otherwise + // directly use it. + const julong max_virtual_limit = (julong)3800*M; + if (result) { + *limit = MIN2(*limit, max_virtual_limit); + } else { + *limit = max_virtual_limit; + } + // bound by actually allocatable memory. The algorithm uses two bounds, an + // upper and a lower limit. The upper limit is the current highest amount of + // memory that could not be allocated, the lower limit is the current highest + // amount of memory that could be allocated. + // The algorithm iteratively refines the result by halving the difference + // between these limits, updating either the upper limit (if that value could + // not be allocated) or the lower limit (if the that value could be allocated) + // until the difference between these limits is "small". + + // the minimum amount of memory we care about allocating. + const julong min_allocation_size = M; + + julong upper_limit = *limit; + + // first check a few trivial cases + if (is_allocatable(upper_limit) || (upper_limit <= min_allocation_size)) { + *limit = upper_limit; + } else if (!is_allocatable(min_allocation_size)) { + // we found that not even min_allocation_size is allocatable. Return it + // anyway. There is no point to search for a better value any more. + *limit = min_allocation_size; + } else { + // perform the binary search. + julong lower_limit = min_allocation_size; + while ((upper_limit - lower_limit) > min_allocation_size) { + julong temp_limit = ((upper_limit - lower_limit) / 2) + lower_limit; + temp_limit = align_size_down_(temp_limit, min_allocation_size); + if (is_allocatable(temp_limit)) { + lower_limit = temp_limit; + } else { + upper_limit = temp_limit; + } + } + *limit = lower_limit; + } + return true; +#endif +} diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index bdd78ad0218..5570195bb31 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -476,24 +476,6 @@ julong os::physical_memory() { return Solaris::physical_memory(); } -julong os::allocatable_physical_memory(julong size) { -#ifdef _LP64 - return size; -#else - julong result = MIN2(size, (julong)3835*M); - if (!is_allocatable(result)) { - // Memory allocations will be aligned but the alignment - // is not known at this point. Alignments will - // be at most to LargePageSizeInBytes. Protect - // allocations from alignments up to illegal - // values. If at this point 2G is illegal. - julong reasonable_size = (julong)2*G - 2 * LargePageSizeInBytes; - result = MIN2(size, reasonable_size); - } - return result; -#endif -} - static hrtime_t first_hrtime = 0; static const hrtime_t hrtime_hz = 1000*1000*1000; const int LOCK_BUSY = 1; diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 4a99a1b3975..2b111029c4c 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -686,12 +686,17 @@ julong os::physical_memory() { return win32::physical_memory(); } -julong os::allocatable_physical_memory(julong size) { +bool os::has_allocatable_memory_limit(julong* limit) { + MEMORYSTATUSEX ms; + ms.dwLength = sizeof(ms); + GlobalMemoryStatusEx(&ms); #ifdef _LP64 - return size; + *limit = (julong)ms.ullAvailVirtual; + return true; #else // Limit to 1400m because of the 2gb address space wall - return MIN2(size, (julong)1400*M); + *limit = MIN2((julong)1400*M, (julong)ms.ullAvailVirtual); + return true; #endif } diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 7fccf4be754..b662e5ae1a5 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1552,6 +1552,15 @@ void Arguments::set_g1_gc_flags() { } } +julong Arguments::limit_by_allocatable_memory(julong limit) { + julong max_allocatable; + julong result = limit; + if (os::has_allocatable_memory_limit(&max_allocatable)) { + result = MIN2(result, max_allocatable / MaxVirtMemFraction); + } + return result; +} + void Arguments::set_heap_size() { if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) { // Deprecated flag @@ -1590,12 +1599,12 @@ void Arguments::set_heap_size() { } reasonable_max = MIN2(reasonable_max, max_coop_heap); } - reasonable_max = os::allocatable_physical_memory(reasonable_max); + reasonable_max = limit_by_allocatable_memory(reasonable_max); if (!FLAG_IS_DEFAULT(InitialHeapSize)) { // An initial heap size was specified on the command line, // so be sure that the maximum size is consistent. Done - // after call to allocatable_physical_memory because that + // after call to limit_by_allocatable_memory because that // method might reduce the allocation size. reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize); } @@ -1615,14 +1624,14 @@ void Arguments::set_heap_size() { reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize); - reasonable_minimum = os::allocatable_physical_memory(reasonable_minimum); + reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum); julong reasonable_initial = phys_mem / InitialRAMFraction; reasonable_initial = MAX2(reasonable_initial, reasonable_minimum); reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize); - reasonable_initial = os::allocatable_physical_memory(reasonable_initial); + reasonable_initial = limit_by_allocatable_memory(reasonable_initial); if (PrintGCDetails && Verbose) { // Cannot use gclog_or_tty yet. @@ -2608,9 +2617,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, initHeapSize = MIN2(total_memory / (julong)2, total_memory - (julong)160*M); - // Make sure that if we have a lot of memory we cap the 32 bit - // process space. The 64bit VM version of this function is a nop. - initHeapSize = os::allocatable_physical_memory(initHeapSize); + initHeapSize = limit_by_allocatable_memory(initHeapSize); if (FLAG_IS_DEFAULT(MaxHeapSize)) { FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize); diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp index d75fc9a82bd..0a4350ee3c5 100644 --- a/hotspot/src/share/vm/runtime/arguments.hpp +++ b/hotspot/src/share/vm/runtime/arguments.hpp @@ -312,6 +312,9 @@ class Arguments : AllStatic { static void set_use_compressed_oops(); static void set_ergonomics_flags(); static void set_shared_spaces_flags(); + // limits the given memory size by the maximum amount of memory this process is + // currently allowed to allocate or reserve. + static julong limit_by_allocatable_memory(julong size); // Setup heap size static void set_heap_size(); // Based on automatic selection criteria, should the diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index d59bc735ed7..edfbcb9c2a7 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1962,6 +1962,10 @@ class CommandLineFlags { product(uintx, InitialRAMFraction, 64, \ "Fraction (1/n) of real memory used for initial heap size") \ \ + develop(uintx, MaxVirtMemFraction, 2, \ + "Maximum fraction (1/n) of virtual memory used for ergonomically" \ + "determining maximum heap size") \ + \ product(bool, UseAutoGCSelectPolicy, false, \ "Use automatic collection selection policy") \ \ diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index d061a0848c6..9bcf0c53174 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -184,7 +184,7 @@ class os: AllStatic { } static julong available_memory(); static julong physical_memory(); - static julong allocatable_physical_memory(julong size); + static bool has_allocatable_memory_limit(julong* limit); static bool is_server_class_machine(); // number of CPUs From 9c89e6d28aa8b723084f23efe4fe245f9874deda Mon Sep 17 00:00:00 2001 From: John Cuthbertson Date: Fri, 29 Mar 2013 13:49:37 -0700 Subject: [PATCH 05/52] 8010463: G1: Crashes with -UseTLAB and heap verification Some parts of the G1 heap can only be walked during a safepoint. Skip verifying these parts of the heap when verifying during JVM startup. Reviewed-by: brutisso, tschatzl --- .../gc_implementation/g1/g1CollectedHeap.cpp | 7 +-- hotspot/src/share/vm/memory/universe.cpp | 9 ---- hotspot/src/share/vm/runtime/init.cpp | 9 ---- hotspot/src/share/vm/runtime/thread.cpp | 11 +++-- .../gc/TestVerifyBeforeGCDuringStartup.java | 45 +++++++++++++++++++ 5 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 hotspot/test/gc/TestVerifyBeforeGCDuringStartup.java diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 780e330b4f8..610942585e7 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -3288,12 +3288,12 @@ void G1CollectedHeap::verify(bool silent) { void G1CollectedHeap::verify(bool silent, VerifyOption vo) { - if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) { + if (SafepointSynchronize::is_at_safepoint()) { if (!silent) { gclog_or_tty->print("Roots "); } VerifyRootsClosure rootsCl(vo); assert(Thread::current()->is_VM_thread(), - "Expected to be executed serially by the VM thread at this point"); + "Expected to be executed serially by the VM thread at this point"); CodeBlobToOopClosure blobsCl(&rootsCl, /*do_marking=*/ false); VerifyKlassClosure klassCl(this, &rootsCl); @@ -3378,7 +3378,8 @@ void G1CollectedHeap::verify(bool silent, } guarantee(!failures, "there should not have been any failures"); } else { - if (!silent) gclog_or_tty->print("(SKIPPING roots, heapRegions, remset) "); + if (!silent) + gclog_or_tty->print("(SKIPPING roots, heapRegionSets, heapRegions, remset) "); } } diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 79e092a3b19..d2bbf0175d2 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -953,15 +953,6 @@ void Universe::update_heap_info_at_gc() { void universe2_init() { EXCEPTION_MARK; Universe::genesis(CATCH); - // Although we'd like to verify here that the state of the heap - // is good, we can't because the main thread has not yet added - // itself to the threads list (so, using current interfaces - // we can't "fill" its TLAB), unless TLABs are disabled. - if (VerifyBeforeGC && !UseTLAB && - Universe::heap()->total_collections() >= VerifyGCStartAt) { - Universe::heap()->prepare_for_verify(); - Universe::verify(); // make sure we're starting with a clean slate - } } diff --git a/hotspot/src/share/vm/runtime/init.cpp b/hotspot/src/share/vm/runtime/init.cpp index 7ef17204bb2..62f295c7ec6 100644 --- a/hotspot/src/share/vm/runtime/init.cpp +++ b/hotspot/src/share/vm/runtime/init.cpp @@ -132,15 +132,6 @@ jint init_globals() { javaClasses_init(); // must happen after vtable initialization stubRoutines_init2(); // note: StubRoutines need 2-phase init - // Although we'd like to, we can't easily do a heap verify - // here because the main thread isn't yet a JavaThread, so - // its TLAB may not be made parseable from the usual interfaces. - if (VerifyBeforeGC && !UseTLAB && - Universe::heap()->total_collections() >= VerifyGCStartAt) { - Universe::heap()->prepare_for_verify(); - Universe::verify(); // make sure we're starting with a clean slate - } - // 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/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 322597fe4cc..577901a2861 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -3423,12 +3423,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(); - if (VerifyBeforeGC && - Universe::heap()->total_collections() >= VerifyGCStartAt) { - Universe::heap()->prepare_for_verify(); - Universe::verify(); // make sure we're starting with a clean slate - } - // Fully start NMT MemTracker::start(); @@ -3452,6 +3446,11 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { } assert (Universe::is_fully_initialized(), "not initialized"); + if (VerifyBeforeGC && VerifyGCStartAt == 0) { + Universe::heap()->prepare_for_verify(); + Universe::verify(); // make sure we're starting with a clean slate + } + EXCEPTION_MARK; // At this point, the Universe is initialized, but we have not executed diff --git a/hotspot/test/gc/TestVerifyBeforeGCDuringStartup.java b/hotspot/test/gc/TestVerifyBeforeGCDuringStartup.java new file mode 100644 index 00000000000..109e45e4bd9 --- /dev/null +++ b/hotspot/test/gc/TestVerifyBeforeGCDuringStartup.java @@ -0,0 +1,45 @@ +/* + * 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. + */ + +/* @test TestVerifyBeforeGCDuringStartup.java + * @key gc + * @bug 8010463 + * @summary Simple test run with -XX:+VerifyBeforeGC -XX:-UseTLAB to verify 8010463 + * @library /testlibrary + */ + +import com.oracle.java.testlibrary.OutputAnalyzer; +import com.oracle.java.testlibrary.ProcessTools; + +public class TestVerifyBeforeGCDuringStartup { + public static void main(String args[]) throws Exception { + ProcessBuilder pb = + ProcessTools.createJavaProcessBuilder(System.getProperty("test.vm.opts"), + "-XX:-UseTLAB", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+VerifyBeforeGC", "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("[Verifying"); + output.shouldHaveExitValue(0); + } +} From d67e393dd60d0afcd8cf992a7de182615fccd0d7 Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Sat, 23 Mar 2013 09:16:37 +0100 Subject: [PATCH 06/52] 8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1" Reviewed-by: brutisso, sla, ctornqvi --- .../ClassMetaspaceSizeInJmapHeap.java | 6 +- .../java/testlibrary/JDKToolLauncher.java | 114 ++++++++++++++++++ 2 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java diff --git a/hotspot/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java b/hotspot/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java index 37a5f3a4c2c..b3258466a2d 100644 --- a/hotspot/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java +++ b/hotspot/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java @@ -39,8 +39,10 @@ public class ClassMetaspaceSizeInJmapHeap { public static void main(String[] args) throws Exception { String pid = Integer.toString(ProcessTools.getProcessId()); - ProcessBuilder pb = new ProcessBuilder(); - pb.command(JDKToolFinder.getJDKTool("jmap"), "-heap", pid); + JDKToolLauncher jmap = JDKToolLauncher.create("jmap") + .addToolArg("-heap") + .addToolArg(pid); + ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); File out = new File("ClassMetaspaceSizeInJmapHeap.stdout.txt"); pb.redirectOutput(out); diff --git a/hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java b/hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java new file mode 100644 index 00000000000..0f0c0a49d33 --- /dev/null +++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java @@ -0,0 +1,114 @@ +/* + * 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. + */ + +package com.oracle.java.testlibrary; + +import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; + +import com.oracle.java.testlibrary.JDKToolFinder; +import com.oracle.java.testlibrary.ProcessTools; + +/** + * A utility for constructing command lines for starting JDK tool processes. + * + * The JDKToolLauncher can in particular be combined with a + * java.lang.ProcessBuilder to easily run a JDK tool. For example, the + * following code run {@code jmap -heap} against a process with GC logging + * turned on for the {@code jmap} process: + * + *
+ * {@code
+ * JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
+ *                                       .addVMArg("-XX:+PrintGC");
+ *                                       .addVMArg("-XX:+PrintGCDetails")
+ *                                       .addToolArg("-heap")
+ *                                       .addToolArg(pid);
+ * ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
+ * Process p = pb.start();
+ * }
+ * 
+ */ +public class JDKToolLauncher { + private final String executable; + private final List vmArgs = new ArrayList(); + private final List toolArgs = new ArrayList(); + + private JDKToolLauncher(String tool) { + executable = JDKToolFinder.getJDKTool(tool); + vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs())); + } + + /** + * Creates a new JDKToolLauncher for the specified tool. + * + * @param tool The name of the tool + * @return A new JDKToolLauncher + */ + public static JDKToolLauncher create(String tool) { + return new JDKToolLauncher(tool); + } + + /** + * Adds an argument to the JVM running the tool. + * + * The JVM arguments are passed to the underlying JVM running the tool. + * Arguments will automatically be prepended with "-J". + * + * Any platform specific arguments required for running the tool are + * automatically added. + * + * + * @param arg The argument to VM running the tool + * @return The JDKToolLauncher instance + */ + public JDKToolLauncher addVMArg(String arg) { + vmArgs.add("-J" + arg); + return this; + } + + /** + * Adds an argument to the tool. + * + * @param arg The argument to the tool + * @return The JDKToolLauncher instance + */ + public JDKToolLauncher addToolArg(String arg) { + toolArgs.add(arg); + return this; + } + + /** + * Returns the command that can be used for running the tool. + * + * @return An array whose elements are the arguments of the command. + */ + public String[] getCommand() { + List command = new ArrayList(); + command.add(executable); + command.addAll(vmArgs); + command.addAll(toolArgs); + return command.toArray(new String[command.size()]); + } +} From 981e9c35c9371cf9eff83445c7027df69ed86aae Mon Sep 17 00:00:00 2001 From: Morris Meyer Date: Sat, 23 Mar 2013 06:22:07 -0700 Subject: [PATCH 07/52] 8009026: [parfait] Null pointer deference in hotspot/src/share/vm/code/nmethod.cpp Add guarantee() to nmethod constructor and checks to ensure CodeCache has space before allocation Reviewed-by: kvn --- hotspot/src/share/vm/code/codeCache.hpp | 5 +++ hotspot/src/share/vm/code/nmethod.cpp | 54 ++++++++++++++----------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/hotspot/src/share/vm/code/codeCache.hpp b/hotspot/src/share/vm/code/codeCache.hpp index 92ce241b938..e19aec61b79 100644 --- a/hotspot/src/share/vm/code/codeCache.hpp +++ b/hotspot/src/share/vm/code/codeCache.hpp @@ -156,6 +156,11 @@ class CodeCache : AllStatic { static address low_bound() { return (address) _heap->low_boundary(); } static address high_bound() { return (address) _heap->high_boundary(); } + static bool has_space(int size) { + // Always leave some room in the CodeCache for I2C/C2I adapters + return largest_free_block() > (CodeCacheMinimumFreeSpace + size); + } + // Profiling static address first_address(); // first address used for CodeBlobs static address last_address(); // last address used for CodeBlobs diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 157136edc0d..55a2c05f5ff 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -486,7 +486,6 @@ void nmethod::init_defaults() { #endif // def HAVE_DTRACE_H } - nmethod* nmethod::new_native_nmethod(methodHandle method, int compile_id, CodeBuffer *code_buffer, @@ -502,17 +501,19 @@ nmethod* nmethod::new_native_nmethod(methodHandle method, { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); int native_nmethod_size = allocation_size(code_buffer, sizeof(nmethod)); - CodeOffsets offsets; - offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); - offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); - nm = new (native_nmethod_size) - nmethod(method(), native_nmethod_size, compile_id, &offsets, - code_buffer, frame_size, - basic_lock_owner_sp_offset, basic_lock_sp_offset, - oop_maps); - NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_native_nmethod(nm)); - if (PrintAssembly && nm != NULL) - Disassembler::decode(nm); + if (CodeCache::has_space(native_nmethod_size)) { + CodeOffsets offsets; + offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); + offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); + nm = new (native_nmethod_size) nmethod(method(), native_nmethod_size, + compile_id, &offsets, + code_buffer, frame_size, + basic_lock_owner_sp_offset, + basic_lock_sp_offset, oop_maps); + NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_native_nmethod(nm)); + if (PrintAssembly && nm != NULL) + Disassembler::decode(nm); + } } // verify nmethod debug_only(if (nm) nm->verify();) // might block @@ -537,16 +538,19 @@ nmethod* nmethod::new_dtrace_nmethod(methodHandle method, { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); int nmethod_size = allocation_size(code_buffer, sizeof(nmethod)); - CodeOffsets offsets; - offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); - offsets.set_value(CodeOffsets::Dtrace_trap, trap_offset); - offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); + if (CodeCache::has_space(nmethod_size)) { + CodeOffsets offsets; + offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); + offsets.set_value(CodeOffsets::Dtrace_trap, trap_offset); + offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); - nm = new (nmethod_size) nmethod(method(), nmethod_size, &offsets, code_buffer, frame_size); + nm = new (nmethod_size) nmethod(method(), nmethod_size, + &offsets, code_buffer, frame_size); - NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_nmethod(nm)); - if (PrintAssembly && nm != NULL) - Disassembler::decode(nm); + NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_nmethod(nm)); + if (PrintAssembly && nm != NULL) + Disassembler::decode(nm); + } } // verify nmethod debug_only(if (nm) nm->verify();) // might block @@ -587,7 +591,8 @@ nmethod* nmethod::new_nmethod(methodHandle method, + round_to(handler_table->size_in_bytes(), oopSize) + round_to(nul_chk_table->size_in_bytes(), oopSize) + round_to(debug_info->data_size() , oopSize); - nm = new (nmethod_size) + if (CodeCache::has_space(nmethod_size)) { + nm = new (nmethod_size) nmethod(method(), nmethod_size, compile_id, entry_bci, offsets, orig_pc_offset, debug_info, dependencies, code_buffer, frame_size, oop_maps, @@ -595,6 +600,7 @@ nmethod* nmethod::new_nmethod(methodHandle method, nul_chk_table, compiler, comp_level); + } if (nm != NULL) { // To make dependency checking during class loading fast, record // the nmethod dependencies in the classes it is dependent on. @@ -793,9 +799,9 @@ nmethod::nmethod( #endif // def HAVE_DTRACE_H void* nmethod::operator new(size_t size, int nmethod_size) { - // Always leave some room in the CodeCache for I2C/C2I adapters - if (CodeCache::largest_free_block() < CodeCacheMinimumFreeSpace) return NULL; - return CodeCache::allocate(nmethod_size); + void* alloc = CodeCache::allocate(nmethod_size); + guarantee(alloc != NULL, "CodeCache should have enough space"); + return alloc; } From 6964a690ed9a23d4c0692da2dfbced46e1436355 Mon Sep 17 00:00:00 2001 From: Christian Thalinger Date: Mon, 25 Mar 2013 17:13:26 -0700 Subject: [PATCH 08/52] 7198429: need checked categorization of caller-sensitive methods in the JDK Reviewed-by: kvn, jrose --- hotspot/src/share/vm/ci/ciMethod.cpp | 11 + hotspot/src/share/vm/ci/ciMethod.hpp | 8 +- .../share/vm/classfile/classFileParser.cpp | 11 +- .../share/vm/classfile/classFileParser.hpp | 1 + .../share/vm/classfile/classLoaderData.cpp | 7 + .../share/vm/classfile/classLoaderData.hpp | 1 + .../src/share/vm/classfile/javaClasses.hpp | 15 +- .../share/vm/classfile/systemDictionary.cpp | 11 + .../share/vm/classfile/systemDictionary.hpp | 9 +- hotspot/src/share/vm/classfile/vmSymbols.hpp | 8 +- hotspot/src/share/vm/oops/method.cpp | 32 ++- hotspot/src/share/vm/oops/method.hpp | 33 ++- hotspot/src/share/vm/opto/library_call.cpp | 160 ++++------- hotspot/src/share/vm/prims/jvm.cpp | 67 ++++- hotspot/src/share/vm/prims/methodHandles.cpp | 25 +- hotspot/src/share/vm/prims/unsafe.cpp | 269 ++++++++++-------- hotspot/src/share/vm/runtime/vframe.cpp | 49 ++-- hotspot/src/share/vm/runtime/vframe.hpp | 1 + 18 files changed, 413 insertions(+), 305 deletions(-) diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp index 0fa11470c94..646de740f8f 100644 --- a/hotspot/src/share/vm/ci/ciMethod.cpp +++ b/hotspot/src/share/vm/ci/ciMethod.cpp @@ -790,6 +790,17 @@ int ciMethod::scale_count(int count, float prof_factor) { return count; } + +// ------------------------------------------------------------------ +// ciMethod::is_special_get_caller_class_method +// +bool ciMethod::is_ignored_by_security_stack_walk() const { + check_is_loaded(); + VM_ENTRY_MARK; + return get_Method()->is_ignored_by_security_stack_walk(); +} + + // ------------------------------------------------------------------ // invokedynamic support diff --git a/hotspot/src/share/vm/ci/ciMethod.hpp b/hotspot/src/share/vm/ci/ciMethod.hpp index c98f2c0dccf..cbef39b3cdc 100644 --- a/hotspot/src/share/vm/ci/ciMethod.hpp +++ b/hotspot/src/share/vm/ci/ciMethod.hpp @@ -166,8 +166,9 @@ class ciMethod : public ciMetadata { // Code size for inlining decisions. int code_size_for_inlining(); - bool force_inline() { return get_Method()->force_inline(); } - bool dont_inline() { return get_Method()->dont_inline(); } + bool caller_sensitive() { return get_Method()->caller_sensitive(); } + bool force_inline() { return get_Method()->force_inline(); } + bool dont_inline() { return get_Method()->dont_inline(); } int comp_level(); int highest_osr_comp_level(); @@ -264,6 +265,9 @@ class ciMethod : public ciMetadata { int instructions_size(); int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC + // Stack walking support + bool is_ignored_by_security_stack_walk() const; + // JSR 292 support bool is_method_handle_intrinsic() const; bool is_compiled_lambda_form() const; diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 9f2a9f419a4..d1d8a692b50 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -1735,9 +1735,14 @@ ClassFileParser::AnnotationCollector::annotation_index(ClassLoaderData* loader_d Symbol* name) { vmSymbols::SID sid = vmSymbols::find_sid(name); // Privileged code can use all annotations. Other code silently drops some. - bool privileged = loader_data->is_the_null_class_loader_data() || - loader_data->is_anonymous(); + const bool privileged = loader_data->is_the_null_class_loader_data() || + loader_data->is_ext_class_loader_data() || + loader_data->is_anonymous(); switch (sid) { + case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_reflect_CallerSensitive_signature): + if (_location != _in_method) break; // only allow for methods + if (!privileged) break; // only allow in privileged code + return _method_CallerSensitive; case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_ForceInline_signature): if (_location != _in_method) break; // only allow for methods if (!privileged) break; // only allow in privileged code @@ -1775,6 +1780,8 @@ ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() { } void ClassFileParser::MethodAnnotationCollector::apply_to(methodHandle m) { + if (has_annotation(_method_CallerSensitive)) + m->set_caller_sensitive(true); if (has_annotation(_method_ForceInline)) m->set_force_inline(true); if (has_annotation(_method_DontInline)) diff --git a/hotspot/src/share/vm/classfile/classFileParser.hpp b/hotspot/src/share/vm/classfile/classFileParser.hpp index 0fd8830463d..3d6046935d5 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.hpp +++ b/hotspot/src/share/vm/classfile/classFileParser.hpp @@ -119,6 +119,7 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC { enum Location { _in_field, _in_method, _in_class }; enum ID { _unknown = 0, + _method_CallerSensitive, _method_ForceInline, _method_DontInline, _method_LambdaForm_Compiled, diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index f74f8f1ce13..b680574d952 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -321,6 +321,13 @@ ClassLoaderData::~ClassLoaderData() { } } +/** + * Returns true if this class loader data is for the extension class loader. + */ +bool ClassLoaderData::is_ext_class_loader_data() const { + return SystemDictionary::is_ext_class_loader(class_loader()); +} + Metaspace* ClassLoaderData::metaspace_non_null() { assert(!DumpSharedSpaces, "wrong metaspace!"); // If the metaspace has not been allocated, create a new one. Might want diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp index 8fbf454fed6..6c8906b26b7 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp @@ -191,6 +191,7 @@ class ClassLoaderData : public CHeapObj { bool is_the_null_class_loader_data() const { return this == _the_null_class_loader_data; } + bool is_ext_class_loader_data() const; // The Metaspace is created lazily so may be NULL. This // method will allocate a Metaspace if needed. diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 478509d5c66..ac0f15e2cee 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -1050,15 +1050,16 @@ class java_lang_invoke_MemberName: AllStatic { // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): enum { - MN_IS_METHOD = 0x00010000, // method (not constructor) - MN_IS_CONSTRUCTOR = 0x00020000, // constructor - MN_IS_FIELD = 0x00040000, // field - MN_IS_TYPE = 0x00080000, // nested type + MN_IS_METHOD = 0x00010000, // method (not constructor) + MN_IS_CONSTRUCTOR = 0x00020000, // constructor + MN_IS_FIELD = 0x00040000, // field + MN_IS_TYPE = 0x00080000, // nested type + MN_CALLER_SENSITIVE = 0x00100000, // @CallerSensitive annotation detected MN_REFERENCE_KIND_SHIFT = 24, // refKind - MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT, + MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT, // The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers: - MN_SEARCH_SUPERCLASSES = 0x00100000, // walk super classes - MN_SEARCH_INTERFACES = 0x00200000 // walk implemented interfaces + MN_SEARCH_SUPERCLASSES = 0x00100000, // walk super classes + MN_SEARCH_INTERFACES = 0x00200000 // walk implemented interfaces }; // Accessors for code generation: diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index edd3107062b..b4e4cd38bbf 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -146,6 +146,17 @@ bool SystemDictionary::is_parallelDefine(Handle class_loader) { } return false; } + +/** + * Returns true if the passed class loader is the extension class loader. + */ +bool SystemDictionary::is_ext_class_loader(Handle class_loader) { + if (class_loader.is_null()) { + return false; + } + return (class_loader->klass()->name() == vmSymbols::sun_misc_Launcher_ExtClassLoader()); +} + // ---------------------------------------------------------------------------- // Resolving of classes diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp index d282fedfb4d..2fd8c5d9757 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp @@ -106,6 +106,7 @@ class SymbolPropertyTable; do_klass(ThreadDeath_klass, java_lang_ThreadDeath, Pre ) \ do_klass(Exception_klass, java_lang_Exception, Pre ) \ do_klass(RuntimeException_klass, java_lang_RuntimeException, Pre ) \ + do_klass(SecurityManager_klass, java_lang_SecurityManager, Pre ) \ do_klass(ProtectionDomain_klass, java_security_ProtectionDomain, Pre ) \ do_klass(AccessControlContext_klass, java_security_AccessControlContext, Pre ) \ do_klass(ClassNotFoundException_klass, java_lang_ClassNotFoundException, Pre ) \ @@ -138,13 +139,14 @@ class SymbolPropertyTable; /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \ /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \ /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \ - do_klass(lambda_MagicLambdaImpl_klass, java_lang_invoke_MagicLambdaImpl, Opt ) \ + do_klass(lambda_MagicLambdaImpl_klass, java_lang_invoke_MagicLambdaImpl, Opt ) \ do_klass(reflect_MagicAccessorImpl_klass, sun_reflect_MagicAccessorImpl, Opt ) \ do_klass(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \ do_klass(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \ do_klass(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt ) \ do_klass(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15 ) \ do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15 ) \ + do_klass(reflect_CallerSensitive_klass, sun_reflect_CallerSensitive, Opt ) \ \ /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \ do_klass(MethodHandle_klass, java_lang_invoke_MethodHandle, Pre_JSR292 ) \ @@ -628,12 +630,15 @@ private: static bool is_parallelCapable(Handle class_loader); static bool is_parallelDefine(Handle class_loader); +public: + static bool is_ext_class_loader(Handle class_loader); + +private: static Klass* find_shared_class(Symbol* class_name); // Setup link to hierarchy static void add_to_hierarchy(instanceKlassHandle k, TRAPS); -private: // We pass in the hashtable index so we can calculate it outside of // the SystemDictionary_lock. diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index f28f6d4884b..1e66346eec5 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -91,6 +91,7 @@ template(java_lang_StringBuffer, "java/lang/StringBuffer") \ template(java_lang_StringBuilder, "java/lang/StringBuilder") \ template(java_lang_CharSequence, "java/lang/CharSequence") \ + template(java_lang_SecurityManager, "java/lang/SecurityManager") \ template(java_security_AccessControlContext, "java/security/AccessControlContext") \ template(java_security_ProtectionDomain, "java/security/ProtectionDomain") \ template(java_io_OutputStream, "java/io/OutputStream") \ @@ -211,6 +212,8 @@ template(sun_reflect_SerializationConstructorAccessorImpl, "sun/reflect/SerializationConstructorAccessorImpl") \ template(sun_reflect_DelegatingClassLoader, "sun/reflect/DelegatingClassLoader") \ template(sun_reflect_Reflection, "sun/reflect/Reflection") \ + template(sun_reflect_CallerSensitive, "sun/reflect/CallerSensitive") \ + template(sun_reflect_CallerSensitive_signature, "Lsun/reflect/CallerSensitive;") \ template(checkedExceptions_name, "checkedExceptions") \ template(clazz_name, "clazz") \ template(exceptionTypes_name, "exceptionTypes") \ @@ -343,6 +346,7 @@ template(contextClassLoader_name, "contextClassLoader") \ template(inheritedAccessControlContext_name, "inheritedAccessControlContext") \ template(isPrivileged_name, "isPrivileged") \ + template(getClassContext_name, "getClassContext") \ template(wait_name, "wait") \ template(checkPackageAccess_name, "checkPackageAccess") \ template(stackSize_name, "stackSize") \ @@ -463,6 +467,7 @@ template(void_classloader_signature, "()Ljava/lang/ClassLoader;") \ template(void_object_signature, "()Ljava/lang/Object;") \ template(void_class_signature, "()Ljava/lang/Class;") \ + template(void_class_array_signature, "()[Ljava/lang/Class;") \ template(void_string_signature, "()Ljava/lang/String;") \ template(object_array_object_signature, "([Ljava/lang/Object;)Ljava/lang/Object;") \ template(object_object_array_object_signature, "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;")\ @@ -705,9 +710,8 @@ do_intrinsic(_getLength, java_lang_reflect_Array, getLength_name, object_int_signature, F_SN) \ do_name( getLength_name, "getLength") \ \ - do_intrinsic(_getCallerClass, sun_reflect_Reflection, getCallerClass_name, getCallerClass_signature, F_SN) \ + do_intrinsic(_getCallerClass, sun_reflect_Reflection, getCallerClass_name, void_class_signature, F_SN) \ do_name( getCallerClass_name, "getCallerClass") \ - do_signature(getCallerClass_signature, "(I)Ljava/lang/Class;") \ \ do_intrinsic(_newArray, java_lang_reflect_Array, newArray_name, newArray_signature, F_SN) \ do_name( newArray_name, "newArray") \ diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index 11ddd21f1f6..650076d8044 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -967,6 +967,32 @@ bool Method::should_not_be_cached() const { return false; } + +/** + * Returns true if this is one of the specially treated methods for + * security related stack walks (like Reflection.getCallerClass). + */ +bool Method::is_ignored_by_security_stack_walk() const { + const bool use_new_reflection = JDK_Version::is_gte_jdk14x_version() && UseNewReflection; + + assert(intrinsic_id() != vmIntrinsics::_invoke || Universe::reflect_invoke_cache()->is_same_method((Method*)this), "sanity"); + if (intrinsic_id() == vmIntrinsics::_invoke) { + // This is Method.invoke() -- ignore it + return true; + } + if (use_new_reflection && + method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) { + // This is an auxilary frame -- ignore it + return true; + } + if (is_method_handle_intrinsic() || is_compiled_lambda_form()) { + // This is an internal adapter frame for method handles -- ignore it + return true; + } + return false; +} + + // Constant pool structure for invoke methods: enum { _imcp_invoke_name = 1, // utf8: 'invokeExact', etc. @@ -1178,13 +1204,13 @@ vmSymbols::SID Method::klass_id_for_intrinsics(Klass* holder) { // because we are not loading from core libraries // exception: the AES intrinsics come from lib/ext/sunjce_provider.jar // which does not use the class default class loader so we check for its loader here - if ((InstanceKlass::cast(holder)->class_loader() != NULL) && - InstanceKlass::cast(holder)->class_loader()->klass()->name() != vmSymbols::sun_misc_Launcher_ExtClassLoader()) { + InstanceKlass* ik = InstanceKlass::cast(holder); + if ((ik->class_loader() != NULL) && !SystemDictionary::is_ext_class_loader(ik->class_loader())) { return vmSymbols::NO_SID; // regardless of name, no intrinsics here } // see if the klass name is well-known: - Symbol* klass_name = InstanceKlass::cast(holder)->name(); + Symbol* klass_name = ik->name(); return vmSymbols::find_sid(klass_name); } diff --git a/hotspot/src/share/vm/oops/method.hpp b/hotspot/src/share/vm/oops/method.hpp index 0c6203fc624..ea92383d1c2 100644 --- a/hotspot/src/share/vm/oops/method.hpp +++ b/hotspot/src/share/vm/oops/method.hpp @@ -118,11 +118,12 @@ class Method : public Metadata { #endif u2 _method_size; // size of this object u1 _intrinsic_id; // vmSymbols::intrinsic_id (0 == _none) - u1 _jfr_towrite : 1, // Flags - _force_inline : 1, - _hidden : 1, - _dont_inline : 1, - : 4; + u1 _jfr_towrite : 1, // Flags + _caller_sensitive : 1, + _force_inline : 1, + _hidden : 1, + _dont_inline : 1, + : 3; u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting u2 _number_of_breakpoints; // fullspeed debugging support InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations @@ -618,6 +619,9 @@ class Method : public Metadata { // Reflection support bool is_overridden_in(Klass* k) const; + // Stack walking support + bool is_ignored_by_security_stack_walk() const; + // JSR 292 support bool is_method_handle_intrinsic() const; // MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id) bool is_compiled_lambda_form() const; // intrinsic_id() == vmIntrinsics::_compiledLambdaForm @@ -705,15 +709,16 @@ class Method : public Metadata { void init_intrinsic_id(); // updates from _none if a match static vmSymbols::SID klass_id_for_intrinsics(Klass* holder); - bool jfr_towrite() { return _jfr_towrite; } - void set_jfr_towrite(bool towrite) { _jfr_towrite = towrite; } - - bool force_inline() { return _force_inline; } - void set_force_inline(bool x) { _force_inline = x; } - bool dont_inline() { return _dont_inline; } - void set_dont_inline(bool x) { _dont_inline = x; } - bool is_hidden() { return _hidden; } - void set_hidden(bool x) { _hidden = x; } + bool jfr_towrite() { return _jfr_towrite; } + void set_jfr_towrite(bool x) { _jfr_towrite = x; } + bool caller_sensitive() { return _caller_sensitive; } + void set_caller_sensitive(bool x) { _caller_sensitive = x; } + bool force_inline() { return _force_inline; } + void set_force_inline(bool x) { _force_inline = x; } + bool dont_inline() { return _dont_inline; } + void set_dont_inline(bool x) { _dont_inline = x; } + bool is_hidden() { return _hidden; } + void set_hidden(bool x) { _hidden = x; } ConstMethod::MethodType method_type() const { return _constMethod->method_type(); } diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index cdcb9417760..1f4b58ebbbb 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -231,7 +231,6 @@ class LibraryCallKit : public GraphKit { void copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, bool is_array, bool card_mark); bool inline_native_clone(bool is_virtual); bool inline_native_Reflection_getCallerClass(); - bool is_method_invoke_or_aux_frame(JVMState* jvms); // Helper function for inlining native object hash method bool inline_native_hashcode(bool is_virtual, bool is_static); bool inline_native_getClass(); @@ -393,7 +392,7 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) { case vmIntrinsics::_getCallerClass: if (!UseNewReflection) return NULL; if (!InlineReflectionGetCallerClass) return NULL; - if (!JDK_Version::is_gte_jdk14x_version()) return NULL; + if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) return NULL; break; case vmIntrinsics::_bitCount_i: @@ -3872,13 +3871,13 @@ bool LibraryCallKit::inline_native_getClass() { } //-----------------inline_native_Reflection_getCallerClass--------------------- -// public static native Class sun.reflect.Reflection.getCallerClass(int realFramesToSkip); +// public static native Class sun.reflect.Reflection.getCallerClass(); // // In the presence of deep enough inlining, getCallerClass() becomes a no-op. // -// NOTE that this code must perform the same logic as -// vframeStream::security_get_caller_frame in that it must skip -// Method.invoke() and auxiliary frames. +// NOTE: This code must perform the same logic as JVM_GetCallerClass +// in that it must skip particular security frames and checks for +// caller sensitive methods. bool LibraryCallKit::inline_native_Reflection_getCallerClass() { #ifndef PRODUCT if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { @@ -3886,35 +3885,6 @@ bool LibraryCallKit::inline_native_Reflection_getCallerClass() { } #endif - Node* caller_depth_node = argument(0); - - // The depth value must be a constant in order for the runtime call - // to be eliminated. - const TypeInt* caller_depth_type = _gvn.type(caller_depth_node)->isa_int(); - if (caller_depth_type == NULL || !caller_depth_type->is_con()) { -#ifndef PRODUCT - if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { - tty->print_cr(" Bailing out because caller depth was not a constant"); - } -#endif - return false; - } - // Note that the JVM state at this point does not include the - // getCallerClass() frame which we are trying to inline. The - // semantics of getCallerClass(), however, are that the "first" - // frame is the getCallerClass() frame, so we subtract one from the - // requested depth before continuing. We don't inline requests of - // getCallerClass(0). - int caller_depth = caller_depth_type->get_con() - 1; - if (caller_depth < 0) { -#ifndef PRODUCT - if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { - tty->print_cr(" Bailing out because caller depth was %d", caller_depth); - } -#endif - return false; - } - if (!jvms()->has_method()) { #ifndef PRODUCT if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { @@ -3923,95 +3893,67 @@ bool LibraryCallKit::inline_native_Reflection_getCallerClass() { #endif return false; } - int _depth = jvms()->depth(); // cache call chain depth // Walk back up the JVM state to find the caller at the required - // depth. NOTE that this code must perform the same logic as - // vframeStream::security_get_caller_frame in that it must skip - // Method.invoke() and auxiliary frames. Note also that depth is - // 1-based (1 is the bottom of the inlining). - int inlining_depth = _depth; - JVMState* caller_jvms = NULL; + // depth. + JVMState* caller_jvms = jvms(); - if (inlining_depth > 0) { - caller_jvms = jvms(); - assert(caller_jvms = jvms()->of_depth(inlining_depth), "inlining_depth == our depth"); - do { - // The following if-tests should be performed in this order - if (is_method_invoke_or_aux_frame(caller_jvms)) { - // Skip a Method.invoke() or auxiliary frame - } else if (caller_depth > 0) { - // Skip real frame - --caller_depth; - } else { - // We're done: reached desired caller after skipping. - break; - } - caller_jvms = caller_jvms->caller(); - --inlining_depth; - } while (inlining_depth > 0); - } - - if (inlining_depth == 0) { + // Cf. JVM_GetCallerClass + // NOTE: Start the loop at depth 1 because the current JVM state does + // not include the Reflection.getCallerClass() frame. + for (int n = 1; caller_jvms != NULL; caller_jvms = caller_jvms->caller(), n++) { + ciMethod* m = caller_jvms->method(); + switch (n) { + case 0: + fatal("current JVM state does not include the Reflection.getCallerClass frame"); + break; + case 1: + // Frame 0 and 1 must be caller sensitive (see JVM_GetCallerClass). + if (!m->caller_sensitive()) { #ifndef PRODUCT - if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { - tty->print_cr(" Bailing out because caller depth (%d) exceeded inlining depth (%d)", caller_depth_type->get_con(), _depth); - tty->print_cr(" JVM state at this point:"); - for (int i = _depth; i >= 1; i--) { - ciMethod* m = jvms()->of_depth(i)->method(); - tty->print_cr(" %d) %s.%s", i, m->holder()->name()->as_utf8(), m->name()->as_utf8()); - } - } + if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { + tty->print_cr(" Bailing out: CallerSensitive annotation expected at frame %d", n); + } #endif - return false; // Reached end of inlining + return false; // bail-out; let JVM_GetCallerClass do the work + } + break; + default: + if (!m->is_ignored_by_security_stack_walk()) { + // We have reached the desired frame; return the holder class. + // Acquire method holder as java.lang.Class and push as constant. + ciInstanceKlass* caller_klass = caller_jvms->method()->holder(); + ciInstance* caller_mirror = caller_klass->java_mirror(); + set_result(makecon(TypeInstPtr::make(caller_mirror))); + +#ifndef PRODUCT + if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { + tty->print_cr(" Succeeded: caller = %d) %s.%s, JVMS depth = %d", n, caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), jvms()->depth()); + tty->print_cr(" JVM state at this point:"); + for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) { + ciMethod* m = jvms()->of_depth(i)->method(); + tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8()); + } + } +#endif + return true; + } + break; + } } - // Acquire method holder as java.lang.Class - ciInstanceKlass* caller_klass = caller_jvms->method()->holder(); - ciInstance* caller_mirror = caller_klass->java_mirror(); - - // Push this as a constant - set_result(makecon(TypeInstPtr::make(caller_mirror))); - #ifndef PRODUCT if ((PrintIntrinsics || PrintInlining || PrintOptoInlining) && Verbose) { - tty->print_cr(" Succeeded: caller = %s.%s, caller depth = %d, depth = %d", caller_klass->name()->as_utf8(), caller_jvms->method()->name()->as_utf8(), caller_depth_type->get_con(), _depth); + tty->print_cr(" Bailing out because caller depth exceeded inlining depth = %d", jvms()->depth()); tty->print_cr(" JVM state at this point:"); - for (int i = _depth; i >= 1; i--) { + for (int i = jvms()->depth(), n = 1; i >= 1; i--, n++) { ciMethod* m = jvms()->of_depth(i)->method(); - tty->print_cr(" %d) %s.%s", i, m->holder()->name()->as_utf8(), m->name()->as_utf8()); + tty->print_cr(" %d) %s.%s", n, m->holder()->name()->as_utf8(), m->name()->as_utf8()); } } #endif - return true; -} -// Helper routine for above -bool LibraryCallKit::is_method_invoke_or_aux_frame(JVMState* jvms) { - ciMethod* method = jvms->method(); - - // Is this the Method.invoke method itself? - if (method->intrinsic_id() == vmIntrinsics::_invoke) - return true; - - // Is this a helper, defined somewhere underneath MethodAccessorImpl. - ciKlass* k = method->holder(); - if (k->is_instance_klass()) { - ciInstanceKlass* ik = k->as_instance_klass(); - for (; ik != NULL; ik = ik->super()) { - if (ik->name() == ciSymbol::sun_reflect_MethodAccessorImpl() && - ik == env()->find_system_klass(ik->name())) { - return true; - } - } - } - else if (method->is_method_handle_intrinsic() || - method->is_compiled_lambda_form()) { - // This is an internal adapter frame from the MethodHandleCompiler -- skip it - return true; - } - - return false; + return false; // bail-out; let JVM_GetCallerClass do the work } bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index 1c277b76ccc..e5d94c532fd 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -30,6 +30,7 @@ #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "gc_interface/collectedHeap.inline.hpp" +#include "interpreter/bytecode.hpp" #include "memory/oopFactory.hpp" #include "memory/universe.inline.hpp" #include "oops/fieldStreams.hpp" @@ -665,8 +666,51 @@ JVM_END JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth)) JVMWrapper("JVM_GetCallerClass"); - Klass* k = thread->security_get_caller_class(depth); - return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, k->java_mirror()); + + // Pre-JDK 8 and early builds of JDK 8 don't have a CallerSensitive annotation. + if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) { + Klass* k = thread->security_get_caller_class(depth); + return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, k->java_mirror()); + } else { + // Basic handshaking with Java_sun_reflect_Reflection_getCallerClass + assert(depth == -1, "wrong handshake depth"); + } + + // Getting the class of the caller frame. + // + // The call stack at this point looks something like this: + // + // [0] [ @CallerSensitive public sun.reflect.Reflection.getCallerClass ] + // [1] [ @CallerSensitive API.method ] + // [.] [ (skipped intermediate frames) ] + // [n] [ caller ] + vframeStream vfst(thread); + // Cf. LibraryCallKit::inline_native_Reflection_getCallerClass + for (int n = 0; !vfst.at_end(); vfst.security_next(), n++) { + Method* m = vfst.method(); + assert(m != NULL, "sanity"); + switch (n) { + case 0: + // This must only be called from Reflection.getCallerClass + if (m->intrinsic_id() != vmIntrinsics::_getCallerClass) { + THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetCallerClass must only be called from Reflection.getCallerClass"); + } + // fall-through + case 1: + // Frame 0 and 1 must be caller sensitive. + if (!m->caller_sensitive()) { + THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), err_msg("CallerSensitive annotation expected at frame %d", n)); + } + break; + default: + if (!m->is_ignored_by_security_stack_walk()) { + // We have reached the desired frame; return the holder class. + return (jclass) JNIHandles::make_local(env, m->method_holder()->java_mirror()); + } + break; + } + } + return NULL; JVM_END @@ -3160,11 +3204,24 @@ JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env)) KlassLink* first = NULL; KlassLink* last = NULL; int depth = 0; + vframeStream vfst(thread); - for(vframeStream vfst(thread); !vfst.at_end(); vfst.security_get_caller_frame(1)) { + if (SystemDictionary::reflect_CallerSensitive_klass() != NULL) { + // This must only be called from SecurityManager.getClassContext + Method* m = vfst.method(); + if (!(m->method_holder() == SystemDictionary::SecurityManager_klass() && + m->name() == vmSymbols::getClassContext_name() && + m->signature() == vmSymbols::void_class_array_signature())) { + THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetClassContext must only be called from SecurityManager.getClassContext"); + } + } + + // Collect method holders + for (; !vfst.at_end(); vfst.security_next()) { + Method* m = vfst.method(); // Native frames are not returned - if (!vfst.method()->is_native()) { - Klass* holder = vfst.method()->method_holder(); + if (!m->is_ignored_by_security_stack_walk() && !m->is_native()) { + Klass* holder = m->method_holder(); assert(holder->is_klass(), "just checking"); depth++; KlassLink* l = new KlassLink(KlassHandle(thread, holder)); diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp index c3b58796723..54881388bd1 100644 --- a/hotspot/src/share/vm/prims/methodHandles.cpp +++ b/hotspot/src/share/vm/prims/methodHandles.cpp @@ -105,14 +105,15 @@ void MethodHandles::set_enabled(bool z) { // import java_lang_invoke_MemberName.* enum { - IS_METHOD = java_lang_invoke_MemberName::MN_IS_METHOD, - IS_CONSTRUCTOR = java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR, - IS_FIELD = java_lang_invoke_MemberName::MN_IS_FIELD, - IS_TYPE = java_lang_invoke_MemberName::MN_IS_TYPE, + IS_METHOD = java_lang_invoke_MemberName::MN_IS_METHOD, + IS_CONSTRUCTOR = java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR, + IS_FIELD = java_lang_invoke_MemberName::MN_IS_FIELD, + IS_TYPE = java_lang_invoke_MemberName::MN_IS_TYPE, + CALLER_SENSITIVE = java_lang_invoke_MemberName::MN_CALLER_SENSITIVE, REFERENCE_KIND_SHIFT = java_lang_invoke_MemberName::MN_REFERENCE_KIND_SHIFT, REFERENCE_KIND_MASK = java_lang_invoke_MemberName::MN_REFERENCE_KIND_MASK, - SEARCH_SUPERCLASSES = java_lang_invoke_MemberName::MN_SEARCH_SUPERCLASSES, - SEARCH_INTERFACES = java_lang_invoke_MemberName::MN_SEARCH_INTERFACES, + SEARCH_SUPERCLASSES = java_lang_invoke_MemberName::MN_SEARCH_SUPERCLASSES, + SEARCH_INTERFACES = java_lang_invoke_MemberName::MN_SEARCH_INTERFACES, ALL_KINDS = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE }; @@ -207,10 +208,15 @@ oop MethodHandles::init_method_MemberName(oop mname_oop, Method* m, bool do_disp vmindex = m->vtable_index(); } - java_lang_invoke_MemberName::set_flags(mname_oop, flags); + // @CallerSensitive annotation detected + if (m->caller_sensitive()) { + flags |= CALLER_SENSITIVE; + } + + java_lang_invoke_MemberName::set_flags( mname_oop, flags); java_lang_invoke_MemberName::set_vmtarget(mname_oop, m); - java_lang_invoke_MemberName::set_vmindex(mname_oop, vmindex); // vtable/itable index - java_lang_invoke_MemberName::set_clazz(mname_oop, receiver_limit->java_mirror()); + java_lang_invoke_MemberName::set_vmindex( mname_oop, vmindex); // vtable/itable index + java_lang_invoke_MemberName::set_clazz( mname_oop, receiver_limit->java_mirror()); // Note: name and type can be lazily computed by resolve_MemberName, // if Java code needs them as resolved String and MethodType objects. // The clazz must be eagerly stored, because it provides a GC @@ -940,6 +946,7 @@ JVM_END template(java_lang_invoke_MemberName,MN_IS_CONSTRUCTOR) \ template(java_lang_invoke_MemberName,MN_IS_FIELD) \ template(java_lang_invoke_MemberName,MN_IS_TYPE) \ + template(java_lang_invoke_MemberName,MN_CALLER_SENSITIVE) \ template(java_lang_invoke_MemberName,MN_SEARCH_SUPERCLASSES) \ template(java_lang_invoke_MemberName,MN_SEARCH_INTERFACES) \ template(java_lang_invoke_MemberName,MN_REFERENCE_KIND_SHIFT) \ diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 18252c15453..243570b1813 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -868,7 +868,7 @@ static inline void throw_new(JNIEnv *env, const char *ename) { env->ThrowNew(cls, msg); } -static jclass Unsafe_DefineClass(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) { +static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) { { // Code lifted from JDK 1.3 ClassLoader.c @@ -939,6 +939,15 @@ static jclass Unsafe_DefineClass(JNIEnv *env, jstring name, jbyteArray data, int } +UNSAFE_ENTRY(jclass, Unsafe_DefineClass(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd)) + UnsafeWrapper("Unsafe_DefineClass"); + { + ThreadToNativeFromVM ttnfv(thread); + return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd); + } +UNSAFE_END + + UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length)) UnsafeWrapper("Unsafe_DefineClass"); { @@ -949,20 +958,11 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na jobject loader = (caller == NULL) ? NULL : JVM_GetClassLoader(env, caller); jobject pd = (caller == NULL) ? NULL : JVM_GetProtectionDomain(env, caller); - return Unsafe_DefineClass(env, name, data, offset, length, loader, pd); + return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd); } UNSAFE_END -UNSAFE_ENTRY(jclass, Unsafe_DefineClass1(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd)) - UnsafeWrapper("Unsafe_DefineClass"); - { - ThreadToNativeFromVM ttnfv(thread); - - return Unsafe_DefineClass(env, name, data, offset, length, loader, pd); - } -UNSAFE_END - #define DAC_Args CLS"[B["OBJ // define a class but do not make it known to the class loader or system dictionary // - host_class: supplies context for linkage, access control, protection domain, and class loader @@ -1323,7 +1323,7 @@ UNSAFE_END #define THR LANG"Throwable;" #define DC0_Args LANG"String;[BII" -#define DC1_Args DC0_Args LANG"ClassLoader;" "Ljava/security/ProtectionDomain;" +#define DC_Args DC0_Args LANG"ClassLoader;" "Ljava/security/ProtectionDomain;" #define CC (char*) /*cast a literal from (const char*)*/ #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f) @@ -1352,10 +1352,8 @@ UNSAFE_END -// %%% These are temporarily supported until the SDK sources -// contain the necessarily updated Unsafe.java. +// These are the methods for 1.4.0 static JNINativeMethod methods_140[] = { - {CC"getObject", CC"("OBJ"I)"OBJ"", FN_PTR(Unsafe_GetObject140)}, {CC"putObject", CC"("OBJ"I"OBJ")V", FN_PTR(Unsafe_SetObject140)}, @@ -1381,12 +1379,10 @@ static JNINativeMethod methods_140[] = { {CC"allocateMemory", CC"(J)"ADR, FN_PTR(Unsafe_AllocateMemory)}, {CC"reallocateMemory", CC"("ADR"J)"ADR, FN_PTR(Unsafe_ReallocateMemory)}, -// {CC"setMemory", CC"("ADR"JB)V", FN_PTR(Unsafe_SetMemory)}, -// {CC"copyMemory", CC"("ADR ADR"J)V", FN_PTR(Unsafe_CopyMemory)}, {CC"freeMemory", CC"("ADR")V", FN_PTR(Unsafe_FreeMemory)}, - {CC"fieldOffset", CC"("FLD")I", FN_PTR(Unsafe_FieldOffset)}, //deprecated - {CC"staticFieldBase", CC"("CLS")"OBJ, FN_PTR(Unsafe_StaticFieldBaseFromClass)}, //deprecated + {CC"fieldOffset", CC"("FLD")I", FN_PTR(Unsafe_FieldOffset)}, + {CC"staticFieldBase", CC"("CLS")"OBJ, FN_PTR(Unsafe_StaticFieldBaseFromClass)}, {CC"ensureClassInitialized",CC"("CLS")V", FN_PTR(Unsafe_EnsureClassInitialized)}, {CC"arrayBaseOffset", CC"("CLS")I", FN_PTR(Unsafe_ArrayBaseOffset)}, {CC"arrayIndexScale", CC"("CLS")I", FN_PTR(Unsafe_ArrayIndexScale)}, @@ -1394,16 +1390,15 @@ static JNINativeMethod methods_140[] = { {CC"pageSize", CC"()I", FN_PTR(Unsafe_PageSize)}, {CC"defineClass", CC"("DC0_Args")"CLS, FN_PTR(Unsafe_DefineClass0)}, - {CC"defineClass", CC"("DC1_Args")"CLS, FN_PTR(Unsafe_DefineClass1)}, + {CC"defineClass", CC"("DC_Args")"CLS, FN_PTR(Unsafe_DefineClass)}, {CC"allocateInstance", CC"("CLS")"OBJ, FN_PTR(Unsafe_AllocateInstance)}, {CC"monitorEnter", CC"("OBJ")V", FN_PTR(Unsafe_MonitorEnter)}, {CC"monitorExit", CC"("OBJ")V", FN_PTR(Unsafe_MonitorExit)}, {CC"throwException", CC"("THR")V", FN_PTR(Unsafe_ThrowException)} }; -// These are the old methods prior to the JSR 166 changes in 1.5.0 +// These are the methods prior to the JSR 166 changes in 1.5.0 static JNINativeMethod methods_141[] = { - {CC"getObject", CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObject)}, {CC"putObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObject)}, @@ -1429,8 +1424,6 @@ static JNINativeMethod methods_141[] = { {CC"allocateMemory", CC"(J)"ADR, FN_PTR(Unsafe_AllocateMemory)}, {CC"reallocateMemory", CC"("ADR"J)"ADR, FN_PTR(Unsafe_ReallocateMemory)}, -// {CC"setMemory", CC"("ADR"JB)V", FN_PTR(Unsafe_SetMemory)}, -// {CC"copyMemory", CC"("ADR ADR"J)V", FN_PTR(Unsafe_CopyMemory)}, {CC"freeMemory", CC"("ADR")V", FN_PTR(Unsafe_FreeMemory)}, {CC"objectFieldOffset", CC"("FLD")J", FN_PTR(Unsafe_ObjectFieldOffset)}, @@ -1443,7 +1436,7 @@ static JNINativeMethod methods_141[] = { {CC"pageSize", CC"()I", FN_PTR(Unsafe_PageSize)}, {CC"defineClass", CC"("DC0_Args")"CLS, FN_PTR(Unsafe_DefineClass0)}, - {CC"defineClass", CC"("DC1_Args")"CLS, FN_PTR(Unsafe_DefineClass1)}, + {CC"defineClass", CC"("DC_Args")"CLS, FN_PTR(Unsafe_DefineClass)}, {CC"allocateInstance", CC"("CLS")"OBJ, FN_PTR(Unsafe_AllocateInstance)}, {CC"monitorEnter", CC"("OBJ")V", FN_PTR(Unsafe_MonitorEnter)}, {CC"monitorExit", CC"("OBJ")V", FN_PTR(Unsafe_MonitorExit)}, @@ -1451,9 +1444,8 @@ static JNINativeMethod methods_141[] = { }; -// These are the old methods prior to the JSR 166 changes in 1.6.0 +// These are the methods prior to the JSR 166 changes in 1.6.0 static JNINativeMethod methods_15[] = { - {CC"getObject", CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObject)}, {CC"putObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObject)}, {CC"getObjectVolatile",CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObjectVolatile)}, @@ -1482,8 +1474,6 @@ static JNINativeMethod methods_15[] = { {CC"allocateMemory", CC"(J)"ADR, FN_PTR(Unsafe_AllocateMemory)}, {CC"reallocateMemory", CC"("ADR"J)"ADR, FN_PTR(Unsafe_ReallocateMemory)}, -// {CC"setMemory", CC"("ADR"JB)V", FN_PTR(Unsafe_SetMemory)}, -// {CC"copyMemory", CC"("ADR ADR"J)V", FN_PTR(Unsafe_CopyMemory)}, {CC"freeMemory", CC"("ADR")V", FN_PTR(Unsafe_FreeMemory)}, {CC"objectFieldOffset", CC"("FLD")J", FN_PTR(Unsafe_ObjectFieldOffset)}, @@ -1496,7 +1486,7 @@ static JNINativeMethod methods_15[] = { {CC"pageSize", CC"()I", FN_PTR(Unsafe_PageSize)}, {CC"defineClass", CC"("DC0_Args")"CLS, FN_PTR(Unsafe_DefineClass0)}, - {CC"defineClass", CC"("DC1_Args")"CLS, FN_PTR(Unsafe_DefineClass1)}, + {CC"defineClass", CC"("DC_Args")"CLS, FN_PTR(Unsafe_DefineClass)}, {CC"allocateInstance", CC"("CLS")"OBJ, FN_PTR(Unsafe_AllocateInstance)}, {CC"monitorEnter", CC"("OBJ")V", FN_PTR(Unsafe_MonitorEnter)}, {CC"monitorExit", CC"("OBJ")V", FN_PTR(Unsafe_MonitorExit)}, @@ -1509,15 +1499,13 @@ static JNINativeMethod methods_15[] = { }; -// These are the correct methods, moving forward: -static JNINativeMethod methods[] = { - +// These are the methods for 1.6.0 and 1.7.0 +static JNINativeMethod methods_16[] = { {CC"getObject", CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObject)}, {CC"putObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObject)}, {CC"getObjectVolatile",CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObjectVolatile)}, {CC"putObjectVolatile",CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObjectVolatile)}, - DECLARE_GETSETOOP(Boolean, Z), DECLARE_GETSETOOP(Byte, B), DECLARE_GETSETOOP(Short, S), @@ -1540,8 +1528,6 @@ static JNINativeMethod methods[] = { {CC"allocateMemory", CC"(J)"ADR, FN_PTR(Unsafe_AllocateMemory)}, {CC"reallocateMemory", CC"("ADR"J)"ADR, FN_PTR(Unsafe_ReallocateMemory)}, -// {CC"setMemory", CC"("ADR"JB)V", FN_PTR(Unsafe_SetMemory)}, -// {CC"copyMemory", CC"("ADR ADR"J)V", FN_PTR(Unsafe_CopyMemory)}, {CC"freeMemory", CC"("ADR")V", FN_PTR(Unsafe_FreeMemory)}, {CC"objectFieldOffset", CC"("FLD")J", FN_PTR(Unsafe_ObjectFieldOffset)}, @@ -1554,7 +1540,7 @@ static JNINativeMethod methods[] = { {CC"pageSize", CC"()I", FN_PTR(Unsafe_PageSize)}, {CC"defineClass", CC"("DC0_Args")"CLS, FN_PTR(Unsafe_DefineClass0)}, - {CC"defineClass", CC"("DC1_Args")"CLS, FN_PTR(Unsafe_DefineClass1)}, + {CC"defineClass", CC"("DC_Args")"CLS, FN_PTR(Unsafe_DefineClass)}, {CC"allocateInstance", CC"("CLS")"OBJ, FN_PTR(Unsafe_AllocateInstance)}, {CC"monitorEnter", CC"("OBJ")V", FN_PTR(Unsafe_MonitorEnter)}, {CC"monitorExit", CC"("OBJ")V", FN_PTR(Unsafe_MonitorExit)}, @@ -1566,23 +1552,68 @@ static JNINativeMethod methods[] = { {CC"putOrderedObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetOrderedObject)}, {CC"putOrderedInt", CC"("OBJ"JI)V", FN_PTR(Unsafe_SetOrderedInt)}, {CC"putOrderedLong", CC"("OBJ"JJ)V", FN_PTR(Unsafe_SetOrderedLong)}, - {CC"loadFence", CC"()V", FN_PTR(Unsafe_LoadFence)}, - {CC"storeFence", CC"()V", FN_PTR(Unsafe_StoreFence)}, - {CC"fullFence", CC"()V", FN_PTR(Unsafe_FullFence)}, {CC"park", CC"(ZJ)V", FN_PTR(Unsafe_Park)}, {CC"unpark", CC"("OBJ")V", FN_PTR(Unsafe_Unpark)} +}; -// {CC"getLoadAverage", CC"([DI)I", FN_PTR(Unsafe_Loadavg)}, +// These are the methods for 1.8.0 +static JNINativeMethod methods_18[] = { + {CC"getObject", CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObject)}, + {CC"putObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObject)}, + {CC"getObjectVolatile",CC"("OBJ"J)"OBJ"", FN_PTR(Unsafe_GetObjectVolatile)}, + {CC"putObjectVolatile",CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetObjectVolatile)}, -// {CC"prefetchRead", CC"("OBJ"J)V", FN_PTR(Unsafe_PrefetchRead)}, -// {CC"prefetchWrite", CC"("OBJ"J)V", FN_PTR(Unsafe_PrefetchWrite)} -// {CC"prefetchReadStatic", CC"("OBJ"J)V", FN_PTR(Unsafe_PrefetchRead)}, -// {CC"prefetchWriteStatic",CC"("OBJ"J)V", FN_PTR(Unsafe_PrefetchWrite)} + DECLARE_GETSETOOP(Boolean, Z), + DECLARE_GETSETOOP(Byte, B), + DECLARE_GETSETOOP(Short, S), + DECLARE_GETSETOOP(Char, C), + DECLARE_GETSETOOP(Int, I), + DECLARE_GETSETOOP(Long, J), + DECLARE_GETSETOOP(Float, F), + DECLARE_GETSETOOP(Double, D), + DECLARE_GETSETNATIVE(Byte, B), + DECLARE_GETSETNATIVE(Short, S), + DECLARE_GETSETNATIVE(Char, C), + DECLARE_GETSETNATIVE(Int, I), + DECLARE_GETSETNATIVE(Long, J), + DECLARE_GETSETNATIVE(Float, F), + DECLARE_GETSETNATIVE(Double, D), + + {CC"getAddress", CC"("ADR")"ADR, FN_PTR(Unsafe_GetNativeAddress)}, + {CC"putAddress", CC"("ADR""ADR")V", FN_PTR(Unsafe_SetNativeAddress)}, + + {CC"allocateMemory", CC"(J)"ADR, FN_PTR(Unsafe_AllocateMemory)}, + {CC"reallocateMemory", CC"("ADR"J)"ADR, FN_PTR(Unsafe_ReallocateMemory)}, + {CC"freeMemory", CC"("ADR")V", FN_PTR(Unsafe_FreeMemory)}, + + {CC"objectFieldOffset", CC"("FLD")J", FN_PTR(Unsafe_ObjectFieldOffset)}, + {CC"staticFieldOffset", CC"("FLD")J", FN_PTR(Unsafe_StaticFieldOffset)}, + {CC"staticFieldBase", CC"("FLD")"OBJ, FN_PTR(Unsafe_StaticFieldBaseFromField)}, + {CC"ensureClassInitialized",CC"("CLS")V", FN_PTR(Unsafe_EnsureClassInitialized)}, + {CC"arrayBaseOffset", CC"("CLS")I", FN_PTR(Unsafe_ArrayBaseOffset)}, + {CC"arrayIndexScale", CC"("CLS")I", FN_PTR(Unsafe_ArrayIndexScale)}, + {CC"addressSize", CC"()I", FN_PTR(Unsafe_AddressSize)}, + {CC"pageSize", CC"()I", FN_PTR(Unsafe_PageSize)}, + + {CC"defineClass", CC"("DC_Args")"CLS, FN_PTR(Unsafe_DefineClass)}, + {CC"allocateInstance", CC"("CLS")"OBJ, FN_PTR(Unsafe_AllocateInstance)}, + {CC"monitorEnter", CC"("OBJ")V", FN_PTR(Unsafe_MonitorEnter)}, + {CC"monitorExit", CC"("OBJ")V", FN_PTR(Unsafe_MonitorExit)}, + {CC"tryMonitorEnter", CC"("OBJ")Z", FN_PTR(Unsafe_TryMonitorEnter)}, + {CC"throwException", CC"("THR")V", FN_PTR(Unsafe_ThrowException)}, + {CC"compareAndSwapObject", CC"("OBJ"J"OBJ""OBJ")Z", FN_PTR(Unsafe_CompareAndSwapObject)}, + {CC"compareAndSwapInt", CC"("OBJ"J""I""I"")Z", FN_PTR(Unsafe_CompareAndSwapInt)}, + {CC"compareAndSwapLong", CC"("OBJ"J""J""J"")Z", FN_PTR(Unsafe_CompareAndSwapLong)}, + {CC"putOrderedObject", CC"("OBJ"J"OBJ")V", FN_PTR(Unsafe_SetOrderedObject)}, + {CC"putOrderedInt", CC"("OBJ"JI)V", FN_PTR(Unsafe_SetOrderedInt)}, + {CC"putOrderedLong", CC"("OBJ"JJ)V", FN_PTR(Unsafe_SetOrderedLong)}, + {CC"park", CC"(ZJ)V", FN_PTR(Unsafe_Park)}, + {CC"unpark", CC"("OBJ")V", FN_PTR(Unsafe_Unpark)} }; JNINativeMethod loadavg_method[] = { - {CC"getLoadAverage", CC"([DI)I", FN_PTR(Unsafe_Loadavg)} + {CC"getLoadAverage", CC"([DI)I", FN_PTR(Unsafe_Loadavg)} }; JNINativeMethod prefetch_methods[] = { @@ -1592,7 +1623,7 @@ JNINativeMethod prefetch_methods[] = { {CC"prefetchWriteStatic",CC"("OBJ"J)V", FN_PTR(Unsafe_PrefetchWrite)} }; -JNINativeMethod memcopy_methods[] = { +JNINativeMethod memcopy_methods_17[] = { {CC"copyMemory", CC"("OBJ"J"OBJ"JJ)V", FN_PTR(Unsafe_CopyMemory2)}, {CC"setMemory", CC"("OBJ"JJB)V", FN_PTR(Unsafe_SetMemory2)} }; @@ -1610,6 +1641,12 @@ JNINativeMethod lform_methods[] = { {CC"shouldBeInitialized",CC"("CLS")Z", FN_PTR(Unsafe_ShouldBeInitialized)}, }; +JNINativeMethod fence_methods[] = { + {CC"loadFence", CC"()V", FN_PTR(Unsafe_LoadFence)}, + {CC"storeFence", CC"()V", FN_PTR(Unsafe_StoreFence)}, + {CC"fullFence", CC"()V", FN_PTR(Unsafe_FullFence)}, +}; + #undef CC #undef FN_PTR @@ -1622,12 +1659,32 @@ JNINativeMethod lform_methods[] = { #undef MTH #undef THR #undef DC0_Args -#undef DC1_Args +#undef DC_Args #undef DECLARE_GETSETOOP #undef DECLARE_GETSETNATIVE +/** + * Helper method to register native methods. + */ +static bool register_natives(const char* message, JNIEnv* env, jclass clazz, const JNINativeMethod* methods, jint nMethods) { + int status = env->RegisterNatives(clazz, methods, nMethods); + if (status < 0 || env->ExceptionOccurred()) { + if (PrintMiscellaneous && (Verbose || WizardMode)) { + tty->print_cr("Unsafe: failed registering %s", message); + } + env->ExceptionClear(); + return false; + } else { + if (PrintMiscellaneous && (Verbose || WizardMode)) { + tty->print_cr("Unsafe: successfully registered %s", message); + } + return true; + } +} + + // This one function is exported, used by NativeLookup. // The Unsafe_xxx functions above are called only from the interpreter. // The optimizer looks at names and signatures to recognize @@ -1637,83 +1694,57 @@ JVM_ENTRY(void, JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls)) UnsafeWrapper("JVM_RegisterUnsafeMethods"); { ThreadToNativeFromVM ttnfv(thread); + + // Unsafe methods { - env->RegisterNatives(unsafecls, loadavg_method, sizeof(loadavg_method)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.6 Unsafe.loadavg not found."); - } - env->ExceptionClear(); - } - } - { - env->RegisterNatives(unsafecls, prefetch_methods, sizeof(prefetch_methods)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.6 Unsafe.prefetchRead/Write not found."); - } - env->ExceptionClear(); - } - } - { - env->RegisterNatives(unsafecls, memcopy_methods, sizeof(memcopy_methods)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.7 Unsafe.copyMemory not found."); - } - env->ExceptionClear(); - env->RegisterNatives(unsafecls, memcopy_methods_15, sizeof(memcopy_methods_15)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.5 Unsafe.copyMemory not found."); - } - env->ExceptionClear(); - } + bool success = false; + // We need to register the 1.6 methods first because the 1.8 methods would register fine on 1.7 and 1.6 + if (!success) { + success = register_natives("1.6 methods", env, unsafecls, methods_16, sizeof(methods_16)/sizeof(JNINativeMethod)); + } + if (!success) { + success = register_natives("1.8 methods", env, unsafecls, methods_18, sizeof(methods_18)/sizeof(JNINativeMethod)); + } + if (!success) { + success = register_natives("1.5 methods", env, unsafecls, methods_15, sizeof(methods_15)/sizeof(JNINativeMethod)); + } + if (!success) { + success = register_natives("1.4.1 methods", env, unsafecls, methods_141, sizeof(methods_141)/sizeof(JNINativeMethod)); + } + if (!success) { + success = register_natives("1.4.0 methods", env, unsafecls, methods_140, sizeof(methods_140)/sizeof(JNINativeMethod)); + } + guarantee(success, "register unsafe natives"); + } + + // Unsafe.getLoadAverage + register_natives("1.6 loadavg method", env, unsafecls, loadavg_method, sizeof(loadavg_method)/sizeof(JNINativeMethod)); + + // Prefetch methods + register_natives("1.6 prefetch methods", env, unsafecls, prefetch_methods, sizeof(prefetch_methods)/sizeof(JNINativeMethod)); + + // Memory copy methods + { + bool success = false; + if (!success) { + success = register_natives("1.7 memory copy methods", env, unsafecls, memcopy_methods_17, sizeof(memcopy_methods_17)/sizeof(JNINativeMethod)); + } + if (!success) { + success = register_natives("1.5 memory copy methods", env, unsafecls, memcopy_methods_15, sizeof(memcopy_methods_15)/sizeof(JNINativeMethod)); } } + + // Unsafe.defineAnonymousClass if (EnableInvokeDynamic) { - env->RegisterNatives(unsafecls, anonk_methods, sizeof(anonk_methods)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.7 Unsafe.defineClass (anonymous version) not found."); - } - env->ExceptionClear(); - } + register_natives("1.7 define anonymous class method", env, unsafecls, anonk_methods, sizeof(anonk_methods)/sizeof(JNINativeMethod)); } + + // Unsafe.shouldBeInitialized if (EnableInvokeDynamic) { - env->RegisterNatives(unsafecls, lform_methods, sizeof(lform_methods)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.7 LambdaForm support in Unsafe not found."); - } - env->ExceptionClear(); - } + register_natives("1.7 LambdaForm support", env, unsafecls, lform_methods, sizeof(lform_methods)/sizeof(JNINativeMethod)); } - int status = env->RegisterNatives(unsafecls, methods, sizeof(methods)/sizeof(JNINativeMethod)); - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.6 version of Unsafe not found."); - } - env->ExceptionClear(); - // %%% For now, be backward compatible with an older class: - status = env->RegisterNatives(unsafecls, methods_15, sizeof(methods_15)/sizeof(JNINativeMethod)); - } - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.5 version of Unsafe not found."); - } - env->ExceptionClear(); - // %%% For now, be backward compatible with an older class: - status = env->RegisterNatives(unsafecls, methods_141, sizeof(methods_141)/sizeof(JNINativeMethod)); - } - if (env->ExceptionOccurred()) { - if (PrintMiscellaneous && (Verbose || WizardMode)) { - tty->print_cr("Warning: SDK 1.4.1 version of Unsafe not found."); - } - env->ExceptionClear(); - // %%% For now, be backward compatible with an older class: - status = env->RegisterNatives(unsafecls, methods_140, sizeof(methods_140)/sizeof(JNINativeMethod)); - } - guarantee(status == 0, "register unsafe natives"); + + // Fence methods + register_natives("1.8 fence methods", env, unsafecls, fence_methods, sizeof(fence_methods)/sizeof(JNINativeMethod)); } JVM_END diff --git a/hotspot/src/share/vm/runtime/vframe.cpp b/hotspot/src/share/vm/runtime/vframe.cpp index bc9ca0a419d..1b05aaa79c1 100644 --- a/hotspot/src/share/vm/runtime/vframe.cpp +++ b/hotspot/src/share/vm/runtime/vframe.cpp @@ -391,40 +391,27 @@ vframeStream::vframeStream(JavaThread* thread, frame top_frame, // Step back n frames, skip any pseudo frames in between. // This function is used in Class.forName, Class.newInstance, Method.Invoke, // AccessController.doPrivileged. -// -// NOTE that in JDK 1.4 this has been exposed to Java as -// sun.reflect.Reflection.getCallerClass(), which can be inlined. -// Inlined versions must match this routine's logic. -// Native method prefixing logic does not need to match since -// the method names don't match and inlining will not occur. -// See, for example, -// Parse::inline_native_Reflection_getCallerClass in -// opto/library_call.cpp. void vframeStreamCommon::security_get_caller_frame(int depth) { - bool use_new_reflection = JDK_Version::is_gte_jdk14x_version() && UseNewReflection; - - while (!at_end()) { - if (Universe::reflect_invoke_cache()->is_same_method(method())) { - // This is Method.invoke() -- skip it - } else if (use_new_reflection && - method()->method_holder() - ->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) { - // This is an auxilary frame -- skip it - } else if (method()->is_method_handle_intrinsic() || - method()->is_compiled_lambda_form()) { - // This is an internal adapter frame for method handles -- skip it - } else { - // This is non-excluded frame, we need to count it against the depth - if (depth-- <= 0) { - // we have reached the desired depth, we are done - break; + assert(depth >= 0, err_msg("invalid depth: %d", depth)); + for (int n = 0; !at_end(); security_next()) { + if (!method()->is_ignored_by_security_stack_walk()) { + if (n == depth) { + // We have reached the desired depth; return. + return; } + n++; // this is a non-skipped frame; count it against the depth } - if (method()->is_prefixed_native()) { - skip_prefixed_method_and_wrappers(); - } else { - next(); - } + } + // NOTE: At this point there were not enough frames on the stack + // to walk to depth. Callers of this method have to check for at_end. +} + + +void vframeStreamCommon::security_next() { + if (method()->is_prefixed_native()) { + skip_prefixed_method_and_wrappers(); // calls next() + } else { + next(); } } diff --git a/hotspot/src/share/vm/runtime/vframe.hpp b/hotspot/src/share/vm/runtime/vframe.hpp index b6bf34fc940..2e7191c04b4 100644 --- a/hotspot/src/share/vm/runtime/vframe.hpp +++ b/hotspot/src/share/vm/runtime/vframe.hpp @@ -336,6 +336,7 @@ class vframeStreamCommon : StackObj { _frame = _frame.sender(&_reg_map); } while (!fill_from_frame()); } + void security_next(); bool at_end() const { return _mode == at_end_mode; } From 143a0039a3aaf5c44cac70e92c3963cb33190f01 Mon Sep 17 00:00:00 2001 From: Niclas Adlertz Date: Tue, 26 Mar 2013 10:05:33 +0100 Subject: [PATCH 09/52] 8010281: Remove code that is never executed Reviewed-by: kvn, roland --- hotspot/src/share/vm/opto/ifg.cpp | 44 +++---------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/hotspot/src/share/vm/opto/ifg.cpp b/hotspot/src/share/vm/opto/ifg.cpp index 44828fa6ab8..c40265214dc 100644 --- a/hotspot/src/share/vm/opto/ifg.cpp +++ b/hotspot/src/share/vm/opto/ifg.cpp @@ -37,8 +37,6 @@ #include "opto/memnode.hpp" #include "opto/opcodes.hpp" -#define EXACT_PRESSURE 1 - //============================================================================= //------------------------------IFG-------------------------------------------- PhaseIFG::PhaseIFG( Arena *arena ) : Phase(Interference_Graph), _arena(arena) { @@ -445,23 +443,15 @@ static void lower_pressure( LRG *lrg, uint where, Block *b, uint *pressure, uint pressure[1] -= lrg->reg_pressure(); if( pressure[1] == (uint)FLOATPRESSURE ) { hrp_index[1] = where; -#ifdef EXACT_PRESSURE - if( pressure[1] > b->_freg_pressure ) - b->_freg_pressure = pressure[1]+1; -#else - b->_freg_pressure = (uint)FLOATPRESSURE+1; -#endif + if( pressure[1] > b->_freg_pressure ) + b->_freg_pressure = pressure[1]+1; } } else if( lrg->mask().overlap(*Matcher::idealreg2regmask[Op_RegI]) ) { pressure[0] -= lrg->reg_pressure(); if( pressure[0] == (uint)INTPRESSURE ) { hrp_index[0] = where; -#ifdef EXACT_PRESSURE - if( pressure[0] > b->_reg_pressure ) - b->_reg_pressure = pressure[0]+1; -#else - b->_reg_pressure = (uint)INTPRESSURE+1; -#endif + if( pressure[0] > b->_reg_pressure ) + b->_reg_pressure = pressure[0]+1; } } } @@ -526,17 +516,13 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { if (lrg.mask().is_UP() && lrg.mask_size()) { if (lrg._is_float || lrg._is_vector) { // Count float pressure pressure[1] += lrg.reg_pressure(); -#ifdef EXACT_PRESSURE if( pressure[1] > b->_freg_pressure ) b->_freg_pressure = pressure[1]; -#endif // Count int pressure, but do not count the SP, flags } else if( lrgs(lidx).mask().overlap(*Matcher::idealreg2regmask[Op_RegI]) ) { pressure[0] += lrg.reg_pressure(); -#ifdef EXACT_PRESSURE if( pressure[0] > b->_reg_pressure ) b->_reg_pressure = pressure[0]; -#endif } } } @@ -589,30 +575,20 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { RegMask itmp = lrgs(r).mask(); itmp.AND(*Matcher::idealreg2regmask[Op_RegI]); int iregs = itmp.Size(); -#ifdef EXACT_PRESSURE if( pressure[0]+iregs > b->_reg_pressure ) b->_reg_pressure = pressure[0]+iregs; -#endif if( pressure[0] <= (uint)INTPRESSURE && pressure[0]+iregs > (uint)INTPRESSURE ) { -#ifndef EXACT_PRESSURE - b->_reg_pressure = (uint)INTPRESSURE+1; -#endif hrp_index[0] = j-1; } // Count the float-only registers RegMask ftmp = lrgs(r).mask(); ftmp.AND(*Matcher::idealreg2regmask[Op_RegD]); int fregs = ftmp.Size(); -#ifdef EXACT_PRESSURE if( pressure[1]+fregs > b->_freg_pressure ) b->_freg_pressure = pressure[1]+fregs; -#endif if( pressure[1] <= (uint)FLOATPRESSURE && pressure[1]+fregs > (uint)FLOATPRESSURE ) { -#ifndef EXACT_PRESSURE - b->_freg_pressure = (uint)FLOATPRESSURE+1; -#endif hrp_index[1] = j-1; } } @@ -769,16 +745,12 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { if (lrg.mask().is_UP() && lrg.mask_size()) { if (lrg._is_float || lrg._is_vector) { pressure[1] += lrg.reg_pressure(); -#ifdef EXACT_PRESSURE if( pressure[1] > b->_freg_pressure ) b->_freg_pressure = pressure[1]; -#endif } else if( lrg.mask().overlap(*Matcher::idealreg2regmask[Op_RegI]) ) { pressure[0] += lrg.reg_pressure(); -#ifdef EXACT_PRESSURE if( pressure[0] > b->_reg_pressure ) b->_reg_pressure = pressure[0]; -#endif } } assert( pressure[0] == count_int_pressure (&liveout), "" ); @@ -794,21 +766,13 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { // the whole block is high pressure. if( pressure[0] > (uint)INTPRESSURE ) { hrp_index[0] = 0; -#ifdef EXACT_PRESSURE if( pressure[0] > b->_reg_pressure ) b->_reg_pressure = pressure[0]; -#else - b->_reg_pressure = (uint)INTPRESSURE+1; -#endif } if( pressure[1] > (uint)FLOATPRESSURE ) { hrp_index[1] = 0; -#ifdef EXACT_PRESSURE if( pressure[1] > b->_freg_pressure ) b->_freg_pressure = pressure[1]; -#else - b->_freg_pressure = (uint)FLOATPRESSURE+1; -#endif } // Compute high pressure indice; avoid landing in the middle of projnodes From 848ccdbdfebe031209871c1d0fcfed652c76a347 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Tue, 26 Mar 2013 12:55:26 -0700 Subject: [PATCH 10/52] 8004640: C2 assert failure in memnode.cpp: NULL+offs not RAW address Always transform AddP nodes in IdealKit by calling _gvn.transform(). Reviewed-by: roland, twisti --- hotspot/src/share/vm/opto/graphKit.cpp | 1 - hotspot/src/share/vm/opto/idealKit.cpp | 28 +++--------- hotspot/src/share/vm/opto/idealKit.hpp | 13 +++--- hotspot/src/share/vm/opto/loopnode.cpp | 12 +++--- hotspot/src/share/vm/opto/phaseX.cpp | 59 ++++++++++++++------------ 5 files changed, 48 insertions(+), 65 deletions(-) diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp index cd329a211a9..028020f51de 100644 --- a/hotspot/src/share/vm/opto/graphKit.cpp +++ b/hotspot/src/share/vm/opto/graphKit.cpp @@ -3445,7 +3445,6 @@ void GraphKit::sync_kit(IdealKit& ideal) { void GraphKit::final_sync(IdealKit& ideal) { // Final sync IdealKit and graphKit. - __ drain_delay_transform(); sync_kit(ideal); } diff --git a/hotspot/src/share/vm/opto/idealKit.cpp b/hotspot/src/share/vm/opto/idealKit.cpp index 986f2e178ec..90eff2bb5d7 100644 --- a/hotspot/src/share/vm/opto/idealKit.cpp +++ b/hotspot/src/share/vm/opto/idealKit.cpp @@ -48,9 +48,9 @@ IdealKit::IdealKit(GraphKit* gkit, bool delay_all_transforms, bool has_declarati _cvstate = NULL; // We can go memory state free or else we need the entire memory state assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split"); + assert(!_gvn.is_IterGVN(), "IdealKit can't be used during Optimize phase"); int init_size = 5; _pending_cvstates = new (C->node_arena()) GrowableArray(C->node_arena(), init_size, 0, 0); - _delay_transform = new (C->node_arena()) GrowableArray(C->node_arena(), init_size, 0, 0); DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray(C->node_arena(), init_size, 0, 0)); if (!has_declarations) { declarations_done(); @@ -296,19 +296,16 @@ Node* IdealKit::transform(Node* n) { return delay_transform(n); } else { n = gvn().transform(n); - if (!gvn().is_IterGVN()) { - C->record_for_igvn(n); - } + C->record_for_igvn(n); return n; } } //-----------------------------delay_transform----------------------------------- Node* IdealKit::delay_transform(Node* n) { - if (!gvn().is_IterGVN() || !gvn().is_IterGVN()->delay_transform()) { - gvn().set_type(n, n->bottom_type()); - } - _delay_transform->push(n); + // Delay transform until IterativeGVN + gvn().set_type(n, n->bottom_type()); + C->record_for_igvn(n); return n; } @@ -332,17 +329,6 @@ void IdealKit::clear(Node* m) { for (uint i = 0; i < m->req(); i++) m->set_req(i, NULL); } -//-----------------------------drain_delay_transform---------------------------- -void IdealKit::drain_delay_transform() { - while (_delay_transform->length() > 0) { - Node* n = _delay_transform->pop(); - gvn().transform(n); - if (!gvn().is_IterGVN()) { - C->record_for_igvn(n); - } - } -} - //-----------------------------IdealVariable---------------------------- IdealVariable::IdealVariable(IdealKit &k) { k.declare(this); @@ -351,9 +337,7 @@ IdealVariable::IdealVariable(IdealKit &k) { Node* IdealKit::memory(uint alias_idx) { MergeMemNode* mem = merged_memory(); Node* p = mem->memory_at(alias_idx); - if (!gvn().is_IterGVN() || !gvn().is_IterGVN()->delay_transform()) { - _gvn.set_type(p, Type::MEMORY); // must be mapped - } + _gvn.set_type(p, Type::MEMORY); // must be mapped return p; } diff --git a/hotspot/src/share/vm/opto/idealKit.hpp b/hotspot/src/share/vm/opto/idealKit.hpp index 15e4274db7c..16833c0cbfe 100644 --- a/hotspot/src/share/vm/opto/idealKit.hpp +++ b/hotspot/src/share/vm/opto/idealKit.hpp @@ -102,7 +102,6 @@ class IdealKit: public StackObj { Compile * const C; PhaseGVN &_gvn; GrowableArray* _pending_cvstates; // stack of cvstates - GrowableArray* _delay_transform; // delay invoking gvn.transform until drain Node* _cvstate; // current cvstate (control, memory and variables) uint _var_ct; // number of variables bool _delay_all_transforms; // flag forcing all transforms to be delayed @@ -121,7 +120,7 @@ class IdealKit: public StackObj { void clear(Node* m); // clear a cvstate void stop() { clear(_cvstate); } // clear current cvstate Node* delay_transform(Node* n); - Node* transform(Node* n); // gvn.transform or push node on delay list + Node* transform(Node* n); // gvn.transform or skip it Node* promote_to_phi(Node* n, Node* reg);// Promote "n" to a phi on region "reg" bool was_promoted_to_phi(Node* n, Node* reg) { return (n->is_Phi() && n->in(0) == reg); @@ -146,7 +145,6 @@ class IdealKit: public StackObj { IdealKit(GraphKit* gkit, bool delay_all_transforms = false, bool has_declarations = false); ~IdealKit() { stop(); - drain_delay_transform(); } void sync_kit(GraphKit* gkit); @@ -173,7 +171,6 @@ class IdealKit: public StackObj { void bind(Node* lab); void goto_(Node* lab, bool bind = false); void declarations_done(); - void drain_delay_transform(); Node* IfTrue(IfNode* iff) { return transform(new (C) IfTrueNode(iff)); } Node* IfFalse(IfNode* iff) { return transform(new (C) IfFalseNode(iff)); } @@ -198,7 +195,11 @@ class IdealKit: public StackObj { Node* thread() { return gvn().transform(new (C) ThreadLocalNode()); } // Pointers - Node* AddP(Node *base, Node *ptr, Node *off) { return transform(new (C) AddPNode(base, ptr, off)); } + + // Raw address should be transformed regardless 'delay_transform' flag + // to produce canonical form CastX2P(offset). + Node* AddP(Node *base, Node *ptr, Node *off) { return _gvn.transform(new (C) AddPNode(base, ptr, off)); } + Node* CmpP(Node* l, Node* r) { return transform(new (C) CmpPNode(l, r)); } #ifdef _LP64 Node* XorX(Node* l, Node* r) { return transform(new (C) XorLNode(l, r)); } @@ -208,8 +209,6 @@ class IdealKit: public StackObj { Node* URShiftX(Node* l, Node* r) { return transform(new (C) URShiftXNode(l, r)); } Node* ConX(jint k) { return (Node*)gvn().MakeConX(k); } Node* CastPX(Node* ctl, Node* p) { return transform(new (C) CastP2XNode(ctl, p)); } - // Add a fixed offset to a pointer - Node* basic_plus_adr(Node* base, Node* ptr, intptr_t offset); // Memory operations diff --git a/hotspot/src/share/vm/opto/loopnode.cpp b/hotspot/src/share/vm/opto/loopnode.cpp index 6812c62fae6..c323d02f842 100644 --- a/hotspot/src/share/vm/opto/loopnode.cpp +++ b/hotspot/src/share/vm/opto/loopnode.cpp @@ -2251,6 +2251,11 @@ void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool skip_loop_opts) return; } + // clear out the dead code after build_loop_late + while (_deadlist.size()) { + _igvn.remove_globally_dead_node(_deadlist.pop()); + } + if (stop_early) { assert(do_expensive_nodes, "why are we here?"); if (process_expensive_nodes()) { @@ -2260,9 +2265,7 @@ void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool skip_loop_opts) // nodes again. C->set_major_progress(); } - _igvn.optimize(); - return; } @@ -2273,11 +2276,6 @@ void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool skip_loop_opts) eliminate_useless_predicates(); } - // clear out the dead code - while(_deadlist.size()) { - _igvn.remove_globally_dead_node(_deadlist.pop()); - } - #ifndef PRODUCT C->verify_graph_edges(); if (_verify_me) { // Nested verify pass? diff --git a/hotspot/src/share/vm/opto/phaseX.cpp b/hotspot/src/share/vm/opto/phaseX.cpp index 85714c4e349..a8c979662d2 100644 --- a/hotspot/src/share/vm/opto/phaseX.cpp +++ b/hotspot/src/share/vm/opto/phaseX.cpp @@ -1166,31 +1166,30 @@ void PhaseIterGVN::remove_globally_dead_node( Node *dead ) { if (progress_state == PROCESS_INPUTS) { // After following inputs, continue to outputs _stack.set_index(PROCESS_OUTPUTS); - // Remove from iterative worklist - _worklist.remove(dead); if (!dead->is_Con()) { // Don't kill cons but uses bool recurse = false; // Remove from hash table _table.hash_delete( dead ); // Smash all inputs to 'dead', isolating him completely - for( uint i = 0; i < dead->req(); i++ ) { + for (uint i = 0; i < dead->req(); i++) { Node *in = dead->in(i); - if( in ) { // Points to something? - dead->set_req(i,NULL); // Kill the edge - if (in->outcnt() == 0 && in != C->top()) {// Made input go dead? + if (in != NULL && in != C->top()) { // Points to something? + int nrep = dead->replace_edge(in, NULL); // Kill edges + assert((nrep > 0), "sanity"); + if (in->outcnt() == 0) { // Made input go dead? _stack.push(in, PROCESS_INPUTS); // Recursively remove recurse = true; } else if (in->outcnt() == 1 && in->has_special_unique_user()) { _worklist.push(in->unique_out()); } else if (in->outcnt() <= 2 && dead->is_Phi()) { - if( in->Opcode() == Op_Region ) + if (in->Opcode() == Op_Region) { _worklist.push(in); - else if( in->is_Store() ) { + } else if (in->is_Store()) { DUIterator_Fast imax, i = in->fast_outs(imax); _worklist.push(in->fast_out(i)); i++; - if(in->outcnt() == 2) { + if (in->outcnt() == 2) { _worklist.push(in->fast_out(i)); i++; } @@ -1209,38 +1208,42 @@ void PhaseIterGVN::remove_globally_dead_node( Node *dead ) { } } } - } - } - C->record_dead_node(dead->_idx); - if (dead->is_macro()) { - C->remove_macro_node(dead); - } - if (dead->is_expensive()) { - C->remove_expensive_node(dead); - } - + } // if (in != NULL && in != C->top()) + } // for (uint i = 0; i < dead->req(); i++) if (recurse) { continue; } - } - // 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 - // as dead to be conservative about the dead node count at any - // given time. - } + } // if (!dead->is_Con()) + } // if (progress_state == PROCESS_INPUTS) // Aggressively kill globally dead uses // (Rather than pushing all the outs at once, we push one at a time, // plus the parent to resume later, because of the indefinite number // of edge deletions per loop trip.) if (dead->outcnt() > 0) { - // Recursively remove + // Recursively remove output edges _stack.push(dead->raw_out(0), PROCESS_INPUTS); } else { + // Finished disconnecting all input and output edges. _stack.pop(); + // Remove dead node from iterative worklist + _worklist.remove(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 + // as dead to be conservative about the dead node count at any + // given time. + if (!dead->is_Con()) { + C->record_dead_node(dead->_idx); + } + if (dead->is_macro()) { + C->remove_macro_node(dead); + } + if (dead->is_expensive()) { + C->remove_expensive_node(dead); + } } - } + } // while (_stack.is_nonempty()) } //------------------------------subsume_node----------------------------------- From 878c7e4cd0588df1a6ae148c59601b92c057648b Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 27 Mar 2013 08:19:50 -0400 Subject: [PATCH 11/52] 8009531: Crash when redefining class with annotated method Neglected to copy the annotations in clone_with_new_data when they were moved to ConstMethod. Reviewed-by: acorn, sspitsyn, dcubed --- hotspot/src/share/vm/oops/constMethod.cpp | 20 ++++++++++++++++++++ hotspot/src/share/vm/oops/constMethod.hpp | 3 +++ hotspot/src/share/vm/oops/method.cpp | 2 ++ 3 files changed, 25 insertions(+) diff --git a/hotspot/src/share/vm/oops/constMethod.cpp b/hotspot/src/share/vm/oops/constMethod.cpp index 98a29a2e1dc..1d0376a0b74 100644 --- a/hotspot/src/share/vm/oops/constMethod.cpp +++ b/hotspot/src/share/vm/oops/constMethod.cpp @@ -363,6 +363,26 @@ AnnotationArray** ConstMethod::default_annotations_addr() const { return (AnnotationArray**)constMethod_end() - offset; } +// copy annotations from 'cm' to 'this' +void ConstMethod::copy_annotations_from(ConstMethod* cm) { + if (cm->has_method_annotations()) { + assert(has_method_annotations(), "should be allocated already"); + set_method_annotations(cm->method_annotations()); + } + if (cm->has_parameter_annotations()) { + assert(has_parameter_annotations(), "should be allocated already"); + set_parameter_annotations(cm->parameter_annotations()); + } + if (cm->has_type_annotations()) { + assert(has_type_annotations(), "should be allocated already"); + set_type_annotations(cm->type_annotations()); + } + if (cm->has_default_annotations()) { + assert(has_default_annotations(), "should be allocated already"); + set_default_annotations(cm->default_annotations()); + } +} + // Printing void ConstMethod::print_on(outputStream* st) const { diff --git a/hotspot/src/share/vm/oops/constMethod.hpp b/hotspot/src/share/vm/oops/constMethod.hpp index 0c4212564b0..21df75bdec0 100644 --- a/hotspot/src/share/vm/oops/constMethod.hpp +++ b/hotspot/src/share/vm/oops/constMethod.hpp @@ -441,6 +441,9 @@ public: return has_default_annotations() ? default_annotations()->length() : 0; } + // Copy annotations from other ConstMethod + void copy_annotations_from(ConstMethod* cm); + // byte codes void set_code(address code) { if (code_size() > 0) { diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index 11ddd21f1f6..2e866bed195 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -1170,6 +1170,8 @@ methodHandle Method::clone_with_new_data(methodHandle m, u_char* new_code, int n newm->set_stackmap_data(stackmap_data); } + // copy annotations over to new method + newcm->copy_annotations_from(cm); return newm; } From 366b7e1c5ef84d6bcd026877414a0c1eb1dd52eb Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Wed, 27 Mar 2013 11:41:51 -0400 Subject: [PATCH 12/52] 8010833: Test7116786.java is failing on most configs after fix for 8010667 Update test to recognize that non-zero pad bytes for lookupswitch/tablewsitch opcodes are now valid. Reviewed-by: dcubed, twisti, kvn, coleenp, dholmes --- hotspot/test/runtime/7116786/Test7116786.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hotspot/test/runtime/7116786/Test7116786.java b/hotspot/test/runtime/7116786/Test7116786.java index 8c137ecdca0..b914019258e 100644 --- a/hotspot/test/runtime/7116786/Test7116786.java +++ b/hotspot/test/runtime/7116786/Test7116786.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -338,9 +338,12 @@ class VerifyErrorCases { "invalid constant pool index in ldc", "Invalid index in ldc"), - new Case("case58", "verifier.cpp", true, "verify_switch", + /* No longer a valid test case for bytecode version >= 51. Nonzero + * padding bytes are permitted with lookupswitch and tableswitch + * bytecodes as of JVMS 3d edition */ + new Case("case58", "verifier.cpp", false, "verify_switch", "bad switch padding", - "Nonzero padding byte in lookswitch or tableswitch"), + "Nonzero padding byte in lookupswitch or tableswitch"), new Case("case59", "verifier.cpp", true, "verify_switch", "tableswitch low is greater than high", From b79e2c6803d46d908f8de0a0edb3fd7ea19d2b83 Mon Sep 17 00:00:00 2001 From: Karen Kinnear Date: Wed, 27 Mar 2013 14:10:59 -0400 Subject: [PATCH 13/52] 8009731: Confusing error message for loader constraint violation Fix text, overwritten type and holder for resolved method Reviewed-by: coleenp, dcubed, minqi, dholmes --- .../share/vm/classfile/systemDictionary.cpp | 11 ++---- .../share/vm/classfile/systemDictionary.hpp | 4 +- .../src/share/vm/interpreter/linkResolver.cpp | 39 +++++++++++-------- hotspot/src/share/vm/oops/klassVtable.cpp | 10 +++-- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index edd3107062b..2f7c7c9553f 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -2185,10 +2185,9 @@ Symbol* SystemDictionary::find_resolution_error(constantPoolHandle pool, int whi // Make sure all class components (including arrays) in the given // signature will be resolved to the same class in both loaders. // Returns the name of the type that failed a loader constraint check, or -// NULL if no constraint failed. The returned C string needs cleaning up -// with a ResourceMark in the caller. No exception except OOME is thrown. +// NULL if no constraint failed. No exception except OOME is thrown. // Arrays are not added to the loader constraint table, their elements are. -char* SystemDictionary::check_signature_loaders(Symbol* signature, +Symbol* SystemDictionary::check_signature_loaders(Symbol* signature, Handle loader1, Handle loader2, bool is_method, TRAPS) { // Nothing to do if loaders are the same. @@ -2196,14 +2195,12 @@ char* SystemDictionary::check_signature_loaders(Symbol* signature, return NULL; } - ResourceMark rm(THREAD); SignatureStream sig_strm(signature, is_method); while (!sig_strm.is_done()) { if (sig_strm.is_object()) { - Symbol* s = sig_strm.as_symbol(CHECK_NULL); - Symbol* sig = s; + Symbol* sig = sig_strm.as_symbol(CHECK_NULL); if (!add_loader_constraint(sig, loader1, loader2, THREAD)) { - return sig->as_C_string(); + return sig; } } sig_strm.next(); diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp index d282fedfb4d..8810d35f627 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp @@ -483,8 +483,8 @@ public: // Check class loader constraints static bool add_loader_constraint(Symbol* name, Handle loader1, Handle loader2, TRAPS); - static char* check_signature_loaders(Symbol* signature, Handle loader1, - Handle loader2, bool is_method, TRAPS); + static Symbol* check_signature_loaders(Symbol* signature, Handle loader1, + Handle loader2, bool is_method, TRAPS); // JSR 292 // find a java.lang.invoke.MethodHandle.invoke* method for a given signature diff --git a/hotspot/src/share/vm/interpreter/linkResolver.cpp b/hotspot/src/share/vm/interpreter/linkResolver.cpp index f5639a55b4b..f4b67eeed39 100644 --- a/hotspot/src/share/vm/interpreter/linkResolver.cpp +++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp @@ -458,25 +458,27 @@ void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle res Handle class_loader (THREAD, resolved_method->method_holder()->class_loader()); { ResourceMark rm(THREAD); - char* failed_type_name = + Symbol* failed_type_symbol = SystemDictionary::check_signature_loaders(method_signature, loader, class_loader, true, CHECK); - if (failed_type_name != NULL) { + if (failed_type_symbol != NULL) { const char* msg = "loader constraint violation: when resolving method" " \"%s\" the class loader (instance of %s) of the current class, %s," - " and the class loader (instance of %s) for resolved class, %s, have" + " and the class loader (instance of %s) for the method's defining class, %s, have" " different Class objects for the type %s used in the signature"; char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature); const char* loader1 = SystemDictionary::loader_name(loader()); char* current = InstanceKlass::cast(current_klass())->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(class_loader()); - char* resolved = InstanceKlass::cast(resolved_klass())->name()->as_C_string(); + char* target = InstanceKlass::cast(resolved_method->method_holder()) + ->name()->as_C_string(); + char* failed_type_name = failed_type_symbol->as_C_string(); size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + - strlen(current) + strlen(loader2) + strlen(resolved) + - strlen(failed_type_name); + strlen(current) + strlen(loader2) + strlen(target) + + strlen(failed_type_name) + 1; char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, - resolved, failed_type_name); + target, failed_type_name); THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); } } @@ -520,26 +522,28 @@ void LinkResolver::resolve_interface_method(methodHandle& resolved_method, Handle class_loader (THREAD, resolved_method->method_holder()->class_loader()); { ResourceMark rm(THREAD); - char* failed_type_name = + Symbol* failed_type_symbol = SystemDictionary::check_signature_loaders(method_signature, loader, class_loader, true, CHECK); - if (failed_type_name != NULL) { + if (failed_type_symbol != NULL) { const char* msg = "loader constraint violation: when resolving " "interface method \"%s\" the class loader (instance of %s) of the " "current class, %s, and the class loader (instance of %s) for " - "resolved class, %s, have different Class objects for the type %s " + "the method's defining class, %s, have different Class objects for the type %s " "used in the signature"; char* sig = Method::name_and_sig_as_C_string(resolved_klass(),method_name,method_signature); const char* loader1 = SystemDictionary::loader_name(loader()); char* current = InstanceKlass::cast(current_klass())->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(class_loader()); - char* resolved = InstanceKlass::cast(resolved_klass())->name()->as_C_string(); + char* target = InstanceKlass::cast(resolved_method->method_holder()) + ->name()->as_C_string(); + char* failed_type_name = failed_type_symbol->as_C_string(); size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + - strlen(current) + strlen(loader2) + strlen(resolved) + - strlen(failed_type_name); + strlen(current) + strlen(loader2) + strlen(target) + + strlen(failed_type_name) + 1; char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, - resolved, failed_type_name); + target, failed_type_name); THROW_MSG(vmSymbols::java_lang_LinkageError(), buf); } } @@ -642,12 +646,12 @@ void LinkResolver::resolve_field(FieldAccessInfo& result, constantPoolHandle poo Symbol* signature_ref = pool->signature_ref_at(index); { ResourceMark rm(THREAD); - char* failed_type_name = + Symbol* failed_type_symbol = SystemDictionary::check_signature_loaders(signature_ref, ref_loader, sel_loader, false, CHECK); - if (failed_type_name != NULL) { + if (failed_type_symbol != NULL) { const char* msg = "loader constraint violation: when resolving field" " \"%s\" the class loader (instance of %s) of the referring class, " "%s, and the class loader (instance of %s) for the field's resolved " @@ -656,8 +660,9 @@ void LinkResolver::resolve_field(FieldAccessInfo& result, constantPoolHandle poo const char* loader1 = SystemDictionary::loader_name(ref_loader()); char* sel = InstanceKlass::cast(sel_klass())->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(sel_loader()); + char* failed_type_name = failed_type_symbol->as_C_string(); size_t buflen = strlen(msg) + strlen(field_name) + strlen(loader1) + - strlen(sel) + strlen(loader2) + strlen(failed_type_name); + strlen(sel) + strlen(loader2) + strlen(failed_type_name) + 1; char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); jio_snprintf(buf, buflen, msg, field_name, loader1, sel, loader2, failed_type_name); diff --git a/hotspot/src/share/vm/oops/klassVtable.cpp b/hotspot/src/share/vm/oops/klassVtable.cpp index 43036e75437..3f8609532fa 100644 --- a/hotspot/src/share/vm/oops/klassVtable.cpp +++ b/hotspot/src/share/vm/oops/klassVtable.cpp @@ -327,11 +327,11 @@ bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle tar if (target_loader() != super_loader()) { ResourceMark rm(THREAD); - char* failed_type_name = + Symbol* failed_type_symbol = SystemDictionary::check_signature_loaders(signature, target_loader, super_loader, true, CHECK_(false)); - if (failed_type_name != NULL) { + if (failed_type_symbol != NULL) { const char* msg = "loader constraint violation: when resolving " "overridden method \"%s\" the class loader (instance" " of %s) of the current class, %s, and its superclass loader " @@ -341,6 +341,7 @@ bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle tar const char* loader1 = SystemDictionary::loader_name(target_loader()); char* current = _klass->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(super_loader()); + char* failed_type_name = failed_type_symbol->as_C_string(); size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + strlen(current) + strlen(loader2) + strlen(failed_type_name); char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); @@ -787,12 +788,12 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Klass Handle method_holder_loader (THREAD, target->method_holder()->class_loader()); if (method_holder_loader() != interface_loader()) { ResourceMark rm(THREAD); - char* failed_type_name = + Symbol* failed_type_symbol = SystemDictionary::check_signature_loaders(method_signature, method_holder_loader, interface_loader, true, CHECK); - if (failed_type_name != NULL) { + if (failed_type_symbol != NULL) { const char* msg = "loader constraint violation in interface " "itable initialization: when resolving method \"%s\" the class" " loader (instance of %s) of the current class, %s, " @@ -804,6 +805,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Klass char* current = klass->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(interface_loader()); char* iface = InstanceKlass::cast(interf_h())->name()->as_C_string(); + char* failed_type_name = failed_type_symbol->as_C_string(); size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + strlen(current) + strlen(loader2) + strlen(iface) + strlen(failed_type_name); From 7363c58e3220d4aaba8f42968b0afb09453f9d20 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Wed, 27 Mar 2013 15:41:53 -0400 Subject: [PATCH 14/52] 8010474: [parfait] Undefined return value of the functions in hotspot/src/share/vm/services/memTracker.hpp Fixed functions that miss return values Reviewed-by: coleenp, acorn, kvn --- hotspot/src/share/vm/services/memTracker.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/services/memTracker.hpp b/hotspot/src/share/vm/services/memTracker.hpp index 934daf06ab9..ebcc41500d3 100644 --- a/hotspot/src/share/vm/services/memTracker.hpp +++ b/hotspot/src/share/vm/services/memTracker.hpp @@ -86,13 +86,13 @@ class MemTracker : AllStatic { static inline void set_autoShutdown(bool value) { } static void shutdown(ShutdownReason reason) { } - static inline bool shutdown_in_progress() { } + static inline bool shutdown_in_progress() { return false; } static bool print_memory_usage(BaselineOutputer& out, size_t unit, - bool summary_only = true) { } + bool summary_only = true) { return false; } static bool compare_memory_usage(BaselineOutputer& out, size_t unit, - bool summary_only = true) { } + bool summary_only = true) { return false; } - static bool wbtest_wait_for_data_merge() { } + static bool wbtest_wait_for_data_merge() { return false; } static inline void sync() { } static inline void thread_exiting(JavaThread* thread) { } From 76cc94fb9995252f4b00ed7f17e97f9d01db235c Mon Sep 17 00:00:00 2001 From: Yumin Qi Date: Wed, 27 Mar 2013 17:03:19 -0700 Subject: [PATCH 15/52] 2178143: JVM crashes if the number of bound CPUs changed during runtime Supply a new flag -XX:+AssumeMP to workaround the problem. With the flag is turned on, assume VM run on MP platform so is_MP() will return true that sync calls will not skip away. Reviewed-by: dholmes, acorn, dcubed, jmasa --- hotspot/src/share/vm/runtime/arguments.cpp | 7 +++++++ hotspot/src/share/vm/runtime/globals.hpp | 3 +++ hotspot/src/share/vm/runtime/os.hpp | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 91561005174..217d82798c9 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -3325,6 +3325,13 @@ jint Arguments::parse(const JavaVMInitArgs* args) { } check_deprecated_gcs(); check_deprecated_gc_flags(); + if (AssumeMP && !UseSerialGC) { + if (FLAG_IS_DEFAULT(ParallelGCThreads) && ParallelGCThreads == 1) { + warning("If the number of processors is expected to increase from one, then" + " you should configure the number of parallel GC threads appropriately" + " using -XX:ParallelGCThreads=N"); + } + } #else // INCLUDE_ALL_GCS assert(verify_serial_gc_flags(), "SerialGC unset"); #endif // INCLUDE_ALL_GCS diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index e73e5089bab..4f3fcbb369b 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -457,6 +457,9 @@ class CommandLineFlags { lp64_product(intx, ObjectAlignmentInBytes, 8, \ "Default object alignment in bytes, 8 is minimum") \ \ + product(bool, AssumeMP, false, \ + "Instruct the VM to assume multiple processors are available") \ + \ /* UseMembar is theoretically a temp flag used for memory barrier \ * removal testing. It was supposed to be removed before FCS but has \ * been re-added (see 6401008) */ \ diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index d061a0848c6..f5dc130545a 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -180,7 +180,7 @@ class os: AllStatic { // Interface for detecting multiprocessor system static inline bool is_MP() { assert(_processor_count > 0, "invalid processor count"); - return _processor_count > 1; + return _processor_count > 1 || AssumeMP; } static julong available_memory(); static julong physical_memory(); From cbe728a9bddbba068e930a8c4da59451e0aaebb2 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Sun, 31 Mar 2013 21:43:10 -0400 Subject: [PATCH 16/52] 8010723: fatal error: acquiring lock Metaspace allocation lock/5 out of order Avoid holding SystemDictionary_lock while calling Klass::remove_unshareable_info Reviewed-by: coleenp, acorn --- .../share/vm/classfile/systemDictionary.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index 2f7c7c9553f..fa1f8363812 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -816,13 +816,28 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, Handle cla // We didn't go as far as Klass::restore_unshareable_info(), // so nothing to clean up. } else { - MutexLocker mu(SystemDictionary_lock, THREAD); - Klass* kk = find_class(name, ik->class_loader_data()); + Klass *kk; + { + MutexLocker mu(SystemDictionary_lock, THREAD); + kk = find_class(name, ik->class_loader_data()); + } if (kk != NULL) { // No clean up is needed if the shared class has been entered // into system dictionary, as load_shared_class() won't be called // again. } else { + // This must be done outside of the SystemDictionary_lock to + // avoid deadlock. + // + // Note that Klass::restore_unshareable_info (called via + // load_instance_class above) is also called outside + // of SystemDictionary_lock. Other threads are blocked from + // loading this class because they are waiting on the + // SystemDictionary_lock until this thread removes + // the placeholder below. + // + // This need to be re-thought when parallel-capable non-boot + // classloaders are supported by CDS (today they're not). clean_up_shared_class(ik, class_loader, THREAD); } } From 388d803077fff7d75b5419f946078eda486abcf2 Mon Sep 17 00:00:00 2001 From: Peter Allwin Date: Thu, 28 Mar 2013 15:39:52 +0100 Subject: [PATCH 17/52] 8002118: WindbgDebuggerLocal should not try to load 64-bit debug libraries for 32-bit JVM Reviewed-by: sspitsyn, zgu --- .../jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java index fe7559d05fa..22957a27deb 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java @@ -572,9 +572,14 @@ public class WindbgDebuggerLocal extends DebuggerBase implements WindbgDebugger DTFWHome = sysRoot + File.separator + ".." + File.separator + "Program Files" + File.separator + "Debugging Tools For Windows"; searchList.add(DTFWHome); - searchList.add(DTFWHome + " (x86)"); - searchList.add(DTFWHome + " (x64)"); + // Only add the search path for the current CPU architecture: + String cpu = PlatformInfo.getCPU(); + if (cpu.equals("x86")) { + searchList.add(DTFWHome + " (x86)"); + } else if (cpu.equals("amd64")) { + searchList.add(DTFWHome + " (x64)"); + } // The last place to search is the system directory: searchList.add(sysRoot + File.separator + "system32"); } From f6b3e5b4950ba157c4fa03af1dd37d918cdabd8c Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Thu, 28 Mar 2013 19:13:22 -0700 Subject: [PATCH 18/52] 8011022: new hotspot build - hs25-b26 Reviewed-by: jcoomes --- hotspot/make/hotspot_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version index c6bad83dffd..03616715c5c 100644 --- a/hotspot/make/hotspot_version +++ b/hotspot/make/hotspot_version @@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013 HS_MAJOR_VER=25 HS_MINOR_VER=0 -HS_BUILD_NUMBER=25 +HS_BUILD_NUMBER=26 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 From 3c586e8f26743d2b7b1b859c8b9fb0cb6c274676 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Fri, 29 Mar 2013 17:25:27 +0100 Subject: [PATCH 19/52] 8010934: assert failure in c1_LinearScan.cpp: "asumption: non-Constant instructions have only virtual operands" Incorrect code to skip some ArrayLength instructions in LIRGenerator Reviewed-by: kvn --- hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 2 -- hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index a3970cb3f8f..84402a9ef0d 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -1872,8 +1872,6 @@ void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) { void LIRGenerator::do_ArrayLength(ArrayLength* x) { - if (x->use_count() == 0 && !x->can_trap()) return; - LIRItem array(x->array(), this); array.load_item(); LIR_Opr reg = rlock_result(x); diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp index 948f635c27f..40c448a39ed 100644 --- a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp +++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp @@ -645,7 +645,7 @@ Instruction* RangeCheckEliminator::predicate_add_cmp_with_const(Instruction* lef return predicate_add(left, left_const, cond, const_instr, state, insert_position); } -// Insert deoptimization, returns true if sucessful or false if range check should not be removed +// Insert deoptimization void RangeCheckEliminator::insert_deoptimization(ValueStack *state, Instruction *insert_position, Instruction *array_instr, Instruction *length_instr, Instruction *lower_instr, int lower, Instruction *upper_instr, int upper, AccessIndexed *ai) { assert(is_ok_for_deoptimization(insert_position, array_instr, length_instr, lower_instr, lower, upper_instr, upper), "should have been tested before"); bool upper_check = !(upper_instr && upper_instr->as_ArrayLength() && upper_instr->as_ArrayLength()->array() == array_instr); @@ -669,6 +669,9 @@ void RangeCheckEliminator::insert_deoptimization(ValueStack *state, Instruction } } + // No upper check required -> skip + if (!upper_check) return; + // We need to know length of array if (!length_instr) { // Load length if necessary @@ -680,9 +683,6 @@ void RangeCheckEliminator::insert_deoptimization(ValueStack *state, Instruction length_instr = length; } - // No upper check required -> skip - if (!upper_check) return; - if (!upper_instr) { // Compare for geq array.length insert_position = predicate_cmp_with_const(length_instr, Instruction::leq, upper, state, insert_position, bci); @@ -777,7 +777,7 @@ void RangeCheckEliminator::process_access_indexed(BlockBegin *loop_header, Block tty->fill_to(block->dominator_depth()*2) ); TRACE_RANGE_CHECK_ELIMINATION( - tty->print_cr("Access indexed: index=%d length=%d", ai->index()->id(), ai->length()->id()) + tty->print_cr("Access indexed: index=%d length=%d", ai->index()->id(), (ai->length() != NULL ? ai->length()->id() :-1 )) ); if (ai->check_flag(Instruction::NeedsRangeCheckFlag)) { From 214b7d9dcff30ed8485e1a3723c697d3b71ed632 Mon Sep 17 00:00:00 2001 From: Krystal Mo Date: Sat, 30 Mar 2013 08:01:05 -0700 Subject: [PATCH 20/52] 8011009: Use do-while(0) instead of while(0) in EC_TRACE and RC_TRACE* macros Improve EC_TRACE and RC_TRACE* to use the do-while(0) trick for statement-like macro Reviewed-by: sspitsyn, dcubed --- .../share/vm/prims/jvmtiEventController.cpp | 7 +- .../vm/prims/jvmtiRedefineClassesTrace.hpp | 77 ++++++++++--------- 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvmtiEventController.cpp b/hotspot/src/share/vm/prims/jvmtiEventController.cpp index 6b7b72b7ae6..cdec7d71f2d 100644 --- a/hotspot/src/share/vm/prims/jvmtiEventController.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEventController.cpp @@ -39,7 +39,12 @@ #include "runtime/vm_operations.hpp" #ifdef JVMTI_TRACE -#define EC_TRACE(out) if (JvmtiTrace::trace_event_controller()) { SafeResourceMark rm; tty->print_cr out; } while (0) +#define EC_TRACE(out) do { \ + if (JvmtiTrace::trace_event_controller()) { \ + SafeResourceMark rm; \ + tty->print_cr out; \ + } \ +} while (0) #else #define EC_TRACE(out) #endif /*JVMTI_TRACE */ diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp b/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp index 878d300f5f3..43174e49426 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp @@ -72,36 +72,6 @@ // 0x20000000 | 536870912 - unused // 0x40000000 | 1073741824 - unused // 0x80000000 | 2147483648 - unused -// -// Note: The ResourceMark is to cleanup resource allocated args. -// The "while (0)" is so we can use semi-colon at end of RC_TRACE(). -#define RC_TRACE(level, args) \ - if ((TraceRedefineClasses & level) != 0) { \ - ResourceMark rm; \ - tty->print("RedefineClasses-0x%x: ", level); \ - tty->print_cr args; \ - } while (0) - -#define RC_TRACE_NO_CR(level, args) \ - if ((TraceRedefineClasses & level) != 0) { \ - ResourceMark rm; \ - tty->print("RedefineClasses-0x%x: ", level); \ - tty->print args; \ - } while (0) - -#define RC_TRACE_WITH_THREAD(level, thread, args) \ - if ((TraceRedefineClasses & level) != 0) { \ - ResourceMark rm(thread); \ - tty->print("RedefineClasses-0x%x: ", level); \ - tty->print_cr args; \ - } while (0) - -#define RC_TRACE_MESG(args) \ - { \ - ResourceMark rm; \ - tty->print("RedefineClasses: "); \ - tty->print_cr args; \ - } while (0) // Macro for checking if TraceRedefineClasses has a specific bit // enabled. Returns true if the bit specified by level is set. @@ -120,16 +90,49 @@ #define RC_TRACE_IN_RANGE(low, high) \ (((TraceRedefineClasses & ((high << 1) - 1)) & ~(low - 1)) != 0) -// Timer support macros. Only do timer operations if timer tracing -// is enabled. The "while (0)" is so we can use semi-colon at end of -// the macro. -#define RC_TIMER_START(t) \ +// Note: The ResourceMark is to cleanup resource allocated args. +// The "do {...} while (0)" is so we can use semi-colon at end of RC_TRACE(). +#define RC_TRACE(level, args) do { \ + if (RC_TRACE_ENABLED(level)) { \ + ResourceMark rm; \ + tty->print("RedefineClasses-0x%x: ", level); \ + tty->print_cr args; \ + } \ +} while (0) + +#define RC_TRACE_NO_CR(level, args) do { \ + if (RC_TRACE_ENABLED(level)) { \ + ResourceMark rm; \ + tty->print("RedefineClasses-0x%x: ", level); \ + tty->print args; \ + } \ +} while (0) + +#define RC_TRACE_WITH_THREAD(level, thread, args) do { \ + if (RC_TRACE_ENABLED(level)) { \ + ResourceMark rm(thread); \ + tty->print("RedefineClasses-0x%x: ", level); \ + tty->print_cr args; \ + } \ +} while (0) + +#define RC_TRACE_MESG(args) do { \ + ResourceMark rm; \ + tty->print("RedefineClasses: "); \ + tty->print_cr args; \ +} while (0) + +// Timer support macros. Only do timer operations if timer tracing is enabled. +// The "do {...} while (0)" is so we can use semi-colon at end of the macro. +#define RC_TIMER_START(t) do { \ if (RC_TRACE_ENABLED(0x00000004)) { \ t.start(); \ - } while (0) -#define RC_TIMER_STOP(t) \ + } \ +} while (0) +#define RC_TIMER_STOP(t) do { \ if (RC_TRACE_ENABLED(0x00000004)) { \ t.stop(); \ - } while (0) + } \ +} while (0) #endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSESTRACE_HPP From ba2c11a93a0df87b8ac44ca9e72d8b8751c5b0cf Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Mon, 1 Apr 2013 14:05:41 -0700 Subject: [PATCH 21/52] 8011048: Possible reading from unmapped memory in UTF8::as_quoted_ascii() Pass utf_length parameter to UTF8::as_quoted_ascii() Reviewed-by: dcubed, minqi --- hotspot/src/share/vm/oops/symbol.cpp | 2 +- hotspot/src/share/vm/utilities/utf8.cpp | 8 +++++--- hotspot/src/share/vm/utilities/utf8.hpp | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hotspot/src/share/vm/oops/symbol.cpp b/hotspot/src/share/vm/oops/symbol.cpp index b3c71813bdb..253d0df887c 100644 --- a/hotspot/src/share/vm/oops/symbol.cpp +++ b/hotspot/src/share/vm/oops/symbol.cpp @@ -162,7 +162,7 @@ char* Symbol::as_quoted_ascii() const { const char *ptr = (const char *)&_body[0]; int quoted_length = UTF8::quoted_ascii_length(ptr, utf8_length()); char* result = NEW_RESOURCE_ARRAY(char, quoted_length + 1); - UTF8::as_quoted_ascii(ptr, result, quoted_length + 1); + UTF8::as_quoted_ascii(ptr, utf8_length(), result, quoted_length + 1); return result; } diff --git a/hotspot/src/share/vm/utilities/utf8.cpp b/hotspot/src/share/vm/utilities/utf8.cpp index da470b18cc0..8c013c9b30b 100644 --- a/hotspot/src/share/vm/utilities/utf8.cpp +++ b/hotspot/src/share/vm/utilities/utf8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -180,11 +180,12 @@ int UTF8::quoted_ascii_length(const char* utf8_str, int utf8_length) { } // converts a utf8 string to quoted ascii -void UTF8::as_quoted_ascii(const char* utf8_str, char* buf, int buflen) { +void UTF8::as_quoted_ascii(const char* utf8_str, int utf8_length, char* buf, int buflen) { const char *ptr = utf8_str; + const char *utf8_end = ptr + utf8_length; char* p = buf; char* end = buf + buflen; - while (*ptr != '\0') { + while (ptr < utf8_end) { jchar c; ptr = UTF8::next(ptr, &c); if (c >= 32 && c < 127) { @@ -196,6 +197,7 @@ void UTF8::as_quoted_ascii(const char* utf8_str, char* buf, int buflen) { p += 6; } } + assert(p < end, "sanity"); *p = '\0'; } diff --git a/hotspot/src/share/vm/utilities/utf8.hpp b/hotspot/src/share/vm/utilities/utf8.hpp index 69710fccec4..354941e6dc0 100644 --- a/hotspot/src/share/vm/utilities/utf8.hpp +++ b/hotspot/src/share/vm/utilities/utf8.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -45,7 +45,7 @@ class UTF8 : AllStatic { static int quoted_ascii_length(const char* utf8_str, int utf8_length); // converts a utf8 string to quoted ascii - static void as_quoted_ascii(const char* utf8_str, char* buf, int buflen); + static void as_quoted_ascii(const char* utf8_str, int utf8_length, char* buf, int buflen); // converts a quoted ascii string to utf8 string. returns the original // string unchanged if nothing needs to be done. From 5b838d4ce156211980428d26dcd83aeb4b6e8998 Mon Sep 17 00:00:00 2001 From: Nils Eliasson Date: Tue, 2 Apr 2013 09:30:07 +0200 Subject: [PATCH 22/52] 7034299: Faulty winsock initialization code Reviewed-by: dholmes, sla, ctornqvi --- hotspot/src/os/windows/vm/os_windows.cpp | 40 +++++++++--------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 4a99a1b3975..04953802064 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -3768,6 +3768,8 @@ extern "C" { } } +static jint initSock(); + // this is called _after_ the global arguments have been parsed jint os::init_2(void) { // Allocate a single page and mark it as readable for safepoint polling @@ -3898,6 +3900,10 @@ jint os::init_2(void) { if (!success) UseNUMAInterleaving = false; } + if (initSock() != JNI_OK) { + return JNI_ERR; + } + return JNI_OK; } @@ -4894,42 +4900,24 @@ LONG WINAPI os::win32::serialize_fault_filter(struct _EXCEPTION_POINTERS* e) { // We don't build a headless jre for Windows bool os::is_headless_jre() { return false; } - -typedef CRITICAL_SECTION mutex_t; -#define mutexInit(m) InitializeCriticalSection(m) -#define mutexDestroy(m) DeleteCriticalSection(m) -#define mutexLock(m) EnterCriticalSection(m) -#define mutexUnlock(m) LeaveCriticalSection(m) - -static bool sock_initialized = FALSE; -static mutex_t sockFnTableMutex; - -static void initSock() { +static jint initSock() { WSADATA wsadata; if (!os::WinSock2Dll::WinSock2Available()) { - jio_fprintf(stderr, "Could not load Winsock 2 (error: %d)\n", + jio_fprintf(stderr, "Could not load Winsock (error: %d)\n", ::GetLastError()); - return; + return JNI_ERR; } - if (sock_initialized == TRUE) return; - ::mutexInit(&sockFnTableMutex); - ::mutexLock(&sockFnTableMutex); - if (os::WinSock2Dll::WSAStartup(MAKEWORD(1,1), &wsadata) != 0) { - jio_fprintf(stderr, "Could not initialize Winsock\n"); + if (os::WinSock2Dll::WSAStartup(MAKEWORD(2,2), &wsadata) != 0) { + jio_fprintf(stderr, "Could not initialize Winsock (error: %d)\n", + ::GetLastError()); + return JNI_ERR; } - sock_initialized = TRUE; - ::mutexUnlock(&sockFnTableMutex); + return JNI_OK; } struct hostent* os::get_host_by_name(char* name) { - if (!sock_initialized) { - initSock(); - } - if (!os::WinSock2Dll::WinSock2Available()) { - return NULL; - } return (struct hostent*)os::WinSock2Dll::gethostbyname(name); } From 45cc7f61db5c9fe7d91134f6e070d42705bddc26 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 2 Apr 2013 10:03:02 +0200 Subject: [PATCH 23/52] 8005857: assert in GC_locker from PSOldGen::expand with -XX:+PrintGCDetails and Verbose Use GC_locker::is_active_and_needs_gc() instead of GC_locker::is_active() for providing information about the reason of heap expansion. Reviewed-by: jmasa, johnc --- .../share/vm/gc_implementation/parallelScavenge/psOldGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp index 48e3ebb45c5..2cb3b35e091 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp @@ -256,7 +256,7 @@ void PSOldGen::expand(size_t bytes) { } if (PrintGC && Verbose) { - if (success && GC_locker::is_active()) { + if (success && GC_locker::is_active_and_needs_gc()) { gclog_or_tty->print_cr("Garbage collection disabled, expanded heap instead"); } } From a4300aa98bcfeeca1ce5cf6b1b1111e93317f5cf Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Tue, 2 Apr 2013 11:28:33 +0200 Subject: [PATCH 24/52] 8009763: Add WB test for String.intern() Add convenience method in StringTable, add WhiteBox method and simple sanity test Reviewed-by: mgerdin, zgu --- .../src/share/vm/classfile/symbolTable.cpp | 11 +++- .../src/share/vm/classfile/symbolTable.hpp | 1 + hotspot/src/share/vm/prims/whitebox.cpp | 20 +++++++ hotspot/test/runtime/interned/SanityTest.java | 59 +++++++++++++++++++ .../whitebox/sun/hotspot/WhiteBox.java | 6 ++ 5 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 hotspot/test/runtime/interned/SanityTest.java diff --git a/hotspot/src/share/vm/classfile/symbolTable.cpp b/hotspot/src/share/vm/classfile/symbolTable.cpp index fc19dd55564..0f8da2d895e 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.cpp +++ b/hotspot/src/share/vm/classfile/symbolTable.cpp @@ -677,9 +677,14 @@ oop StringTable::lookup(Symbol* symbol) { ResourceMark rm; int length; jchar* chars = symbol->as_unicode(length); - unsigned int hashValue = hash_string(chars, length); - int index = the_table()->hash_to_index(hashValue); - return the_table()->lookup(index, chars, length, hashValue); + return lookup(chars, length); +} + + +oop StringTable::lookup(jchar* name, int len) { + unsigned int hash = hash_string(name, len); + int index = the_table()->hash_to_index(hash); + return the_table()->lookup(index, name, len, hash); } diff --git a/hotspot/src/share/vm/classfile/symbolTable.hpp b/hotspot/src/share/vm/classfile/symbolTable.hpp index 3eee99ddbc2..a2896382f63 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.hpp +++ b/hotspot/src/share/vm/classfile/symbolTable.hpp @@ -287,6 +287,7 @@ public: // Probing static oop lookup(Symbol* symbol); + static oop lookup(jchar* chars, int length); // Interning static oop intern(Symbol* symbol, TRAPS); diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index 4758210ee0c..9b3cd297f8a 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -254,6 +254,24 @@ WB_ENTRY(jint, WB_GetCompileQueuesSize(JNIEnv* env, jobject o)) CompileBroker::queue_size(CompLevel_full_profile) /* C1 */; WB_END +WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString)) + ResourceMark rm(THREAD); + int len; + jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len); + oop found_string = StringTable::the_table()->lookup(name, len); + if (found_string == NULL) { + return false; + } + return true; +WB_END + + +WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o)) + Universe::heap()->collector_policy()->set_should_clear_all_soft_refs(true); + Universe::heap()->collect(GCCause::_last_ditch_collection); +WB_END + + //Some convenience methods to deal with objects from java int WhiteBox::offset_for_field(const char* field_name, oop object, Symbol* signature_symbol) { @@ -343,6 +361,8 @@ static JNINativeMethod methods[] = { CC"(Ljava/lang/reflect/Method;)I", (void*)&WB_GetMethodCompilationLevel}, {CC"getCompileQueuesSize", CC"()I", (void*)&WB_GetCompileQueuesSize}, + {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, + {CC"fullGC", CC"()V", (void*)&WB_FullGC }, }; #undef CC diff --git a/hotspot/test/runtime/interned/SanityTest.java b/hotspot/test/runtime/interned/SanityTest.java new file mode 100644 index 00000000000..779d3fc78c6 --- /dev/null +++ b/hotspot/test/runtime/interned/SanityTest.java @@ -0,0 +1,59 @@ +/* + * 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. + */ + +/* + * @test SanityTest + * @summary Sanity check of String.intern() & GC + * @library /testlibrary /testlibrary/whitebox + * @build SanityTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI SanityTest + */ + +import java.util.*; +import sun.hotspot.WhiteBox; + + +public class SanityTest { + public static Object tmp; + public static void main(String... args) { + + WhiteBox wb = WhiteBox.getWhiteBox(); + StringBuilder sb = new StringBuilder(); + sb.append("1234x"); sb.append("x56789"); + String str = sb.toString(); + + if (wb.isInStringTable(str)) { + throw new RuntimeException("String " + str + " is already interned"); + } + str.intern(); + if (!wb.isInStringTable(str)) { + throw new RuntimeException("String " + str + " is not interned"); + } + str = sb.toString(); + wb.fullGC(); + if (wb.isInStringTable(str)) { + throw new RuntimeException("String " + str + " is in StringTable even after GC"); + } + } +} diff --git a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java index c9d23ef5fa5..d5d3ab525c5 100644 --- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java +++ b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java @@ -94,4 +94,10 @@ public class WhiteBox { public native int getMethodCompilationLevel(Method method); public native boolean setDontInlineMethod(Method method, boolean value); public native int getCompileQueuesSize(); + + //Intered strings + public native boolean isInStringTable(String str); + + // force Full GC + public native void fullGC(); } From 88f70d8026730483e0ae4e00e30fb00cce43ac63 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Wed, 3 Apr 2013 11:12:57 -0700 Subject: [PATCH 25/52] 8011102: Clear AVX registers after return from JNI call Execute vzeroupper instruction after JNI call and on exits in jit compiled code which use 256bit vectors. Reviewed-by: roland --- hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp | 21 +---- hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp | 44 ++++++++- hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp | 3 + .../src/cpu/x86/vm/sharedRuntime_x86_32.cpp | 3 + .../src/cpu/x86/vm/sharedRuntime_x86_64.cpp | 12 +-- .../src/cpu/x86/vm/stubGenerator_x86_32.cpp | 5 ++ .../src/cpu/x86/vm/stubGenerator_x86_64.cpp | 8 ++ .../cpu/x86/vm/templateInterpreter_x86_32.cpp | 18 +--- .../cpu/x86/vm/templateInterpreter_x86_64.cpp | 11 +-- hotspot/src/cpu/x86/vm/x86_32.ad | 90 ++++++++++++------- hotspot/src/cpu/x86/vm/x86_64.ad | 62 ++++++++++--- hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad | 18 ---- .../src/os_cpu/linux_x86/vm/linux_x86_64.ad | 18 ---- .../os_cpu/solaris_x86/vm/solaris_x86_64.ad | 29 ------ .../os_cpu/windows_x86/vm/windows_x86_64.ad | 23 +---- 15 files changed, 179 insertions(+), 186 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp index c568c6f4d3a..24e6694082e 100644 --- a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp +++ b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp @@ -1299,25 +1299,8 @@ address InterpreterGenerator::generate_native_entry(bool synchronized) { __ push(rdx); #endif // _LP64 - // Either restore the MXCSR register after returning from the JNI Call - // or verify that it wasn't changed. - if (VM_Version::supports_sse()) { - if (RestoreMXCSROnJNICalls) { - __ ldmxcsr(ExternalAddress(StubRoutines::addr_mxcsr_std())); - } - else if (CheckJNICalls ) { - __ call(RuntimeAddress(StubRoutines::x86::verify_mxcsr_entry())); - } - } - -#ifndef _LP64 - // Either restore the x87 floating pointer control word after returning - // from the JNI call or verify that it wasn't changed. - if (CheckJNICalls) { - __ call(RuntimeAddress(StubRoutines::x86::verify_fpu_cntrl_wrd_entry())); - } -#endif // _LP64 - + // Verify or restore cpu control state after JNI call + __ restore_cpu_control_state_after_jni(); // change thread state __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native_trans); diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index b64518a7bc1..98c93f99a0f 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -4765,6 +4765,31 @@ void MacroAssembler::verify_FPU(int stack_depth, const char* s) { pop_CPU_state(); } +void MacroAssembler::restore_cpu_control_state_after_jni() { + // Either restore the MXCSR register after returning from the JNI Call + // or verify that it wasn't changed (with -Xcheck:jni flag). + if (VM_Version::supports_sse()) { + if (RestoreMXCSROnJNICalls) { + ldmxcsr(ExternalAddress(StubRoutines::addr_mxcsr_std())); + } else if (CheckJNICalls) { + call(RuntimeAddress(StubRoutines::x86::verify_mxcsr_entry())); + } + } + if (VM_Version::supports_avx()) { + // Clear upper bits of YMM registers to avoid SSE <-> AVX transition penalty. + vzeroupper(); + } + +#ifndef _LP64 + // Either restore the x87 floating pointer control word after returning + // from the JNI call or verify that it wasn't changed. + if (CheckJNICalls) { + call(RuntimeAddress(StubRoutines::x86::verify_fpu_cntrl_wrd_entry())); + } +#endif // _LP64 +} + + void MacroAssembler::load_klass(Register dst, Register src) { #ifdef _LP64 if (UseCompressedKlassPointers) { @@ -5759,6 +5784,8 @@ void MacroAssembler::string_compare(Register str1, Register str2, addptr(result, stride2); subl(cnt2, stride2); jccb(Assembler::notZero, COMPARE_WIDE_VECTORS_LOOP); + // clean upper bits of YMM registers + vzeroupper(); // compare wide vectors tail bind(COMPARE_WIDE_TAIL); @@ -5772,6 +5799,8 @@ void MacroAssembler::string_compare(Register str1, Register str2, // Identifies the mismatching (higher or lower)16-bytes in the 32-byte vectors. bind(VECTOR_NOT_EQUAL); + // clean upper bits of YMM registers + vzeroupper(); lea(str1, Address(str1, result, scale)); lea(str2, Address(str2, result, scale)); jmp(COMPARE_16_CHARS); @@ -6028,6 +6057,10 @@ void MacroAssembler::char_arrays_equals(bool is_array_equ, Register ary1, Regist // That's it bind(DONE); + if (UseAVX >= 2) { + // clean upper bits of YMM registers + vzeroupper(); + } } void MacroAssembler::generate_fill(BasicType t, bool aligned, @@ -6157,6 +6190,10 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned, vmovdqu(Address(to, 0), xtmp); addptr(to, 32); subl(count, 8 << shift); + + BIND(L_check_fill_8_bytes); + // clean upper bits of YMM registers + vzeroupper(); } else { // Fill 32-byte chunks pshufd(xtmp, xtmp, 0); @@ -6180,8 +6217,9 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned, addptr(to, 32); subl(count, 8 << shift); jcc(Assembler::greaterEqual, L_fill_32_bytes_loop); + + BIND(L_check_fill_8_bytes); } - BIND(L_check_fill_8_bytes); addl(count, 8 << shift); jccb(Assembler::zero, L_exit); jmpb(L_fill_8_bytes); @@ -6316,6 +6354,10 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, jccb(Assembler::lessEqual, L_copy_16_chars); bind(L_copy_16_chars_exit); + if (UseAVX >= 2) { + // clean upper bits of YMM registers + vzeroupper(); + } subptr(len, 8); jccb(Assembler::greater, L_copy_8_chars_exit); diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp index 9500f3164fa..e9f409dc500 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp @@ -582,6 +582,9 @@ class MacroAssembler: public Assembler { // only if +VerifyFPU void verify_FPU(int stack_depth, const char* s = "illegal FPU state"); + // Verify or restore cpu control state after JNI call + void restore_cpu_control_state_after_jni(); + // prints msg, dumps registers and stops execution void stop(const char* msg); diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp index dc705421ca9..0fce7952a70 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp @@ -2065,6 +2065,9 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ call(RuntimeAddress(native_func)); + // Verify or restore cpu control state after JNI call + __ restore_cpu_control_state_after_jni(); + // WARNING - on Windows Java Natives use pascal calling convention and pop the // arguments off of the stack. We could just re-adjust the stack pointer here // and continue to do SP relative addressing but we instead switch to FP diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp index 50255eeef0e..db20c1f2388 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp @@ -2315,16 +2315,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, __ call(RuntimeAddress(native_func)); - // Either restore the MXCSR register after returning from the JNI Call - // or verify that it wasn't changed. - if (RestoreMXCSROnJNICalls) { - __ ldmxcsr(ExternalAddress(StubRoutines::x86::mxcsr_std())); - - } - else if (CheckJNICalls ) { - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::x86::verify_mxcsr_entry()))); - } - + // Verify or restore cpu control state after JNI call + __ restore_cpu_control_state_after_jni(); // Unpack native results. switch (ret_type) { diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp index e56bb2266d0..f3a91d03c99 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp @@ -835,6 +835,11 @@ class StubGenerator: public StubCodeGenerator { __ BIND(L_copy_64_bytes); __ subl(qword_count, 8); __ jcc(Assembler::greaterEqual, L_copy_64_bytes_loop); + + if (UseUnalignedLoadStores && (UseAVX >= 2)) { + // clean upper bits of YMM registers + __ vzeroupper(); + } __ addl(qword_count, 8); __ jccb(Assembler::zero, L_exit); // diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp index c6b94e243bc..ace545383d7 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp @@ -1331,6 +1331,10 @@ class StubGenerator: public StubCodeGenerator { } __ addptr(qword_count, 4); __ BIND(L_end); + if (UseAVX >= 2) { + // clean upper bits of YMM registers + __ vzeroupper(); + } } else { // Copy 32-bytes per iteration __ BIND(L_loop); @@ -1404,6 +1408,10 @@ class StubGenerator: public StubCodeGenerator { } __ subptr(qword_count, 4); __ BIND(L_end); + if (UseAVX >= 2) { + // clean upper bits of YMM registers + __ vzeroupper(); + } } else { // Copy 32-bytes per iteration __ BIND(L_loop); diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp index 5df98394cf5..fb13a44045a 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp @@ -1080,22 +1080,8 @@ address InterpreterGenerator::generate_native_entry(bool synchronized) { // result potentially in rdx:rax or ST0 - // Either restore the MXCSR register after returning from the JNI Call - // or verify that it wasn't changed. - if (VM_Version::supports_sse()) { - if (RestoreMXCSROnJNICalls) { - __ ldmxcsr(ExternalAddress(StubRoutines::addr_mxcsr_std())); - } - else if (CheckJNICalls ) { - __ call(RuntimeAddress(StubRoutines::x86::verify_mxcsr_entry())); - } - } - - // Either restore the x87 floating pointer control word after returning - // from the JNI call or verify that it wasn't changed. - if (CheckJNICalls) { - __ call(RuntimeAddress(StubRoutines::x86::verify_fpu_cntrl_wrd_entry())); - } + // Verify or restore cpu control state after JNI call + __ restore_cpu_control_state_after_jni(); // save potential result in ST(0) & rdx:rax // (if result handler is the T_FLOAT or T_DOUBLE handler, result must be in ST0 - diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp index c446cb3c9b1..6b3f7b6ba26 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp @@ -1079,15 +1079,8 @@ address InterpreterGenerator::generate_native_entry(bool synchronized) { __ call(rax); // result potentially in rax or xmm0 - // Depending on runtime options, either restore the MXCSR - // register after returning from the JNI Call or verify that - // it wasn't changed during -Xcheck:jni. - if (RestoreMXCSROnJNICalls) { - __ ldmxcsr(ExternalAddress(StubRoutines::x86::mxcsr_std())); - } - else if (CheckJNICalls) { - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::x86::verify_mxcsr_entry()))); - } + // Verify or restore cpu control state after JNI call + __ restore_cpu_control_state_after_jni(); // NOTE: The order of these pushes is known to frame::interpreter_frame_result // in order to extract the result of a method call. If the order of these diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad index 6ceb50cee84..67f33d3ba27 100644 --- a/hotspot/src/cpu/x86/vm/x86_32.ad +++ b/hotspot/src/cpu/x86/vm/x86_32.ad @@ -228,10 +228,16 @@ static jlong *float_signflip_pool = double_quadword(&fp_signmask_pool[3*2], CON static jlong *double_signflip_pool = double_quadword(&fp_signmask_pool[4*2], CONST64(0x8000000000000000), CONST64(0x8000000000000000)); // Offset hacking within calls. -static int pre_call_FPU_size() { - if (Compile::current()->in_24_bit_fp_mode()) - return 6; // fldcw - return 0; +static int pre_call_resets_size() { + int size = 0; + Compile* C = Compile::current(); + if (C->in_24_bit_fp_mode()) { + size += 6; // fldcw + } + if (C->max_vector_size() > 16) { + size += 3; // vzeroupper + } + return size; } static int preserve_SP_size() { @@ -242,21 +248,21 @@ static int preserve_SP_size() { // from the start of the call to the point where the return address // will point. int MachCallStaticJavaNode::ret_addr_offset() { - int offset = 5 + pre_call_FPU_size(); // 5 bytes from start of call to where return address points + int offset = 5 + pre_call_resets_size(); // 5 bytes from start of call to where return address points if (_method_handle_invoke) offset += preserve_SP_size(); return offset; } int MachCallDynamicJavaNode::ret_addr_offset() { - return 10 + pre_call_FPU_size(); // 10 bytes from start of call to where return address points + return 10 + pre_call_resets_size(); // 10 bytes from start of call to where return address points } static int sizeof_FFree_Float_Stack_All = -1; int MachCallRuntimeNode::ret_addr_offset() { assert(sizeof_FFree_Float_Stack_All != -1, "must have been emitted already"); - return sizeof_FFree_Float_Stack_All + 5 + pre_call_FPU_size(); + return sizeof_FFree_Float_Stack_All + 5 + pre_call_resets_size(); } // Indicate if the safepoint node needs the polling page as an input. @@ -272,7 +278,7 @@ bool SafePointNode::needs_polling_address_input() { // The address of the call instruction needs to be 4-byte aligned to // ensure that it does not span a cache line so that it can be patched. int CallStaticJavaDirectNode::compute_padding(int current_offset) const { - current_offset += pre_call_FPU_size(); // skip fldcw, if any + current_offset += pre_call_resets_size(); // skip fldcw, if any current_offset += 1; // skip call opcode byte return round_to(current_offset, alignment_required()) - current_offset; } @@ -280,7 +286,7 @@ int CallStaticJavaDirectNode::compute_padding(int current_offset) const { // The address of the call instruction needs to be 4-byte aligned to // ensure that it does not span a cache line so that it can be patched. int CallStaticJavaHandleNode::compute_padding(int current_offset) const { - current_offset += pre_call_FPU_size(); // skip fldcw, if any + current_offset += pre_call_resets_size(); // skip fldcw, if any current_offset += preserve_SP_size(); // skip mov rbp, rsp current_offset += 1; // skip call opcode byte return round_to(current_offset, alignment_required()) - current_offset; @@ -289,7 +295,7 @@ int CallStaticJavaHandleNode::compute_padding(int current_offset) const { // The address of the call instruction needs to be 4-byte aligned to // ensure that it does not span a cache line so that it can be patched. int CallDynamicJavaDirectNode::compute_padding(int current_offset) const { - current_offset += pre_call_FPU_size(); // skip fldcw, if any + current_offset += pre_call_resets_size(); // skip fldcw, if any current_offset += 5; // skip MOV instruction current_offset += 1; // skip call opcode byte return round_to(current_offset, alignment_required()) - current_offset; @@ -583,16 +589,20 @@ void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream* st ) const { // Remove two words for return addr and rbp, framesize -= 2*wordSize; - if( C->in_24_bit_fp_mode() ) { + if (C->max_vector_size() > 16) { + st->print("VZEROUPPER"); + st->cr(); st->print("\t"); + } + if (C->in_24_bit_fp_mode()) { st->print("FLDCW standard control word"); st->cr(); st->print("\t"); } - if( framesize ) { + if (framesize) { st->print("ADD ESP,%d\t# Destroy frame",framesize); st->cr(); st->print("\t"); } st->print_cr("POPL EBP"); st->print("\t"); - if( do_polling() && C->is_method_compilation() ) { + if (do_polling() && C->is_method_compilation()) { st->print("TEST PollPage,EAX\t! Poll Safepoint"); st->cr(); st->print("\t"); } @@ -602,8 +612,14 @@ void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream* st ) const { void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { Compile *C = ra_->C; + if (C->max_vector_size() > 16) { + // Clear upper bits of YMM registers when current compiled code uses + // wide vectors to avoid AVX <-> SSE transition penalty during call. + MacroAssembler masm(&cbuf); + masm.vzeroupper(); + } // If method set FPU control word, restore to standard control word - if( C->in_24_bit_fp_mode() ) { + if (C->in_24_bit_fp_mode()) { MacroAssembler masm(&cbuf); masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std())); } @@ -615,12 +631,11 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { // Note that VerifyStackAtCalls' Majik cookie does not change the frame size popped here - if( framesize >= 128 ) { + if (framesize >= 128) { emit_opcode(cbuf, 0x81); // add SP, #framesize emit_rm(cbuf, 0x3, 0x00, ESP_enc); emit_d32(cbuf, framesize); - } - else if( framesize ) { + } else if (framesize) { emit_opcode(cbuf, 0x83); // add SP, #framesize emit_rm(cbuf, 0x3, 0x00, ESP_enc); emit_d8(cbuf, framesize); @@ -628,7 +643,7 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { emit_opcode(cbuf, 0x58 | EBP_enc); - if( do_polling() && C->is_method_compilation() ) { + if (do_polling() && C->is_method_compilation()) { cbuf.relocate(cbuf.insts_end(), relocInfo::poll_return_type, 0); emit_opcode(cbuf,0x85); emit_rm(cbuf, 0x0, EAX_enc, 0x5); // EAX @@ -640,7 +655,8 @@ uint MachEpilogNode::size(PhaseRegAlloc *ra_) const { Compile *C = ra_->C; // If method set FPU control word, restore to standard control word int size = C->in_24_bit_fp_mode() ? 6 : 0; - if( do_polling() && C->is_method_compilation() ) size += 6; + if (C->max_vector_size() > 16) size += 3; // vzeroupper + if (do_polling() && C->is_method_compilation()) size += 6; int framesize = C->frame_slots() << LogBytesPerInt; assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); @@ -649,7 +665,7 @@ uint MachEpilogNode::size(PhaseRegAlloc *ra_) const { size++; // popl rbp, - if( framesize >= 128 ) { + if (framesize >= 128) { size += 6; } else { size += framesize ? 3 : 0; @@ -1853,20 +1869,26 @@ encode %{ %} - enc_class pre_call_FPU %{ + enc_class pre_call_resets %{ // If method sets FPU control word restore it here debug_only(int off0 = cbuf.insts_size()); - if( Compile::current()->in_24_bit_fp_mode() ) { - MacroAssembler masm(&cbuf); - masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std())); + if (ra_->C->in_24_bit_fp_mode()) { + MacroAssembler _masm(&cbuf); + __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std())); + } + if (ra_->C->max_vector_size() > 16) { + // Clear upper bits of YMM registers when current compiled code uses + // wide vectors to avoid AVX <-> SSE transition penalty during call. + MacroAssembler _masm(&cbuf); + __ vzeroupper(); } debug_only(int off1 = cbuf.insts_size()); - assert(off1 - off0 == pre_call_FPU_size(), "correct size prediction"); + assert(off1 - off0 == pre_call_resets_size(), "correct size prediction"); %} enc_class post_call_FPU %{ // If method sets FPU control word do it here also - if( Compile::current()->in_24_bit_fp_mode() ) { + if (Compile::current()->in_24_bit_fp_mode()) { MacroAssembler masm(&cbuf); masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24())); } @@ -1877,17 +1899,17 @@ encode %{ // who we intended to call. cbuf.set_insts_mark(); $$$emit8$primary; - if ( !_method ) { + if (!_method) { emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4), runtime_call_Relocation::spec(), RELOC_IMM32 ); - } else if(_optimized_virtual) { + } else if (_optimized_virtual) { emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4), opt_virtual_call_Relocation::spec(), RELOC_IMM32 ); } else { emit_d32_reloc(cbuf, ($meth$$method - (int)(cbuf.insts_end()) - 4), static_call_Relocation::spec(), RELOC_IMM32 ); } - if( _method ) { // Emit stub for static call + if (_method) { // Emit stub for static call emit_java_to_interp(cbuf); } %} @@ -12828,7 +12850,7 @@ instruct CallStaticJavaDirect(method meth) %{ ins_cost(300); format %{ "CALL,static " %} opcode(0xE8); /* E8 cd */ - ins_encode( pre_call_FPU, + ins_encode( pre_call_resets, Java_Static_Call( meth ), call_epilog, post_call_FPU ); @@ -12849,7 +12871,7 @@ instruct CallStaticJavaHandle(method meth, eBPRegP ebp_mh_SP_save) %{ ins_cost(300); format %{ "CALL,static/MethodHandle " %} opcode(0xE8); /* E8 cd */ - ins_encode( pre_call_FPU, + ins_encode( pre_call_resets, preserve_SP, Java_Static_Call( meth ), restore_SP, @@ -12870,7 +12892,7 @@ instruct CallDynamicJavaDirect(method meth) %{ format %{ "MOV EAX,(oop)-1\n\t" "CALL,dynamic" %} opcode(0xE8); /* E8 cd */ - ins_encode( pre_call_FPU, + ins_encode( pre_call_resets, Java_Dynamic_Call( meth ), call_epilog, post_call_FPU ); @@ -12887,7 +12909,7 @@ instruct CallRuntimeDirect(method meth) %{ format %{ "CALL,runtime " %} opcode(0xE8); /* E8 cd */ // Use FFREEs to clear entries in float stack - ins_encode( pre_call_FPU, + ins_encode( pre_call_resets, FFree_Float_Stack_All, Java_To_Runtime( meth ), post_call_FPU ); @@ -12902,7 +12924,7 @@ instruct CallLeafDirect(method meth) %{ ins_cost(300); format %{ "CALL_LEAF,runtime " %} opcode(0xE8); /* E8 cd */ - ins_encode( pre_call_FPU, + ins_encode( pre_call_resets, FFree_Float_Stack_All, Java_To_Runtime( meth ), Verify_FPU_For_Leaf, post_call_FPU ); diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad index 7c902c4e31c..77dc5b01131 100644 --- a/hotspot/src/cpu/x86/vm/x86_64.ad +++ b/hotspot/src/cpu/x86/vm/x86_64.ad @@ -399,6 +399,9 @@ source %{ static int preserve_SP_size() { return 3; // rex.w, op, rm(reg/reg) } +static int clear_avx_size() { + return (Compile::current()->max_vector_size() > 16) ? 3 : 0; // vzeroupper +} // !!!!! Special hack to get all types of calls to specify the byte offset // from the start of the call to the point where the return address @@ -406,6 +409,7 @@ static int preserve_SP_size() { int MachCallStaticJavaNode::ret_addr_offset() { int offset = 5; // 5 bytes from start of call to where return address points + offset += clear_avx_size(); if (_method_handle_invoke) offset += preserve_SP_size(); return offset; @@ -413,11 +417,16 @@ int MachCallStaticJavaNode::ret_addr_offset() int MachCallDynamicJavaNode::ret_addr_offset() { - return 15; // 15 bytes from start of call to where return address points + int offset = 15; // 15 bytes from start of call to where return address points + offset += clear_avx_size(); + return offset; } -// In os_cpu .ad file -// int MachCallRuntimeNode::ret_addr_offset() +int MachCallRuntimeNode::ret_addr_offset() { + int offset = 13; // movq r10,#addr; callq (r10) + offset += clear_avx_size(); + return offset; +} // Indicate if the safepoint node needs the polling page as an input, // it does if the polling page is more than disp32 away. @@ -434,6 +443,7 @@ bool SafePointNode::needs_polling_address_input() // ensure that it does not span a cache line so that it can be patched. int CallStaticJavaDirectNode::compute_padding(int current_offset) const { + current_offset += clear_avx_size(); // skip vzeroupper current_offset += 1; // skip call opcode byte return round_to(current_offset, alignment_required()) - current_offset; } @@ -443,6 +453,7 @@ int CallStaticJavaDirectNode::compute_padding(int current_offset) const int CallStaticJavaHandleNode::compute_padding(int current_offset) const { current_offset += preserve_SP_size(); // skip mov rbp, rsp + current_offset += clear_avx_size(); // skip vzeroupper current_offset += 1; // skip call opcode byte return round_to(current_offset, alignment_required()) - current_offset; } @@ -451,6 +462,7 @@ int CallStaticJavaHandleNode::compute_padding(int current_offset) const // ensure that it does not span a cache line so that it can be patched. int CallDynamicJavaDirectNode::compute_padding(int current_offset) const { + current_offset += clear_avx_size(); // skip vzeroupper current_offset += 11; // skip movq instruction + call opcode byte return round_to(current_offset, alignment_required()) - current_offset; } @@ -764,6 +776,11 @@ int MachPrologNode::reloc() const void MachEpilogNode::format(PhaseRegAlloc* ra_, outputStream* st) const { Compile* C = ra_->C; + if (C->max_vector_size() > 16) { + st->print("vzeroupper"); + st->cr(); st->print("\t"); + } + int framesize = C->frame_slots() << LogBytesPerInt; assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); // Remove word for return adr already pushed @@ -793,6 +810,13 @@ void MachEpilogNode::format(PhaseRegAlloc* ra_, outputStream* st) const void MachEpilogNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const { Compile* C = ra_->C; + if (C->max_vector_size() > 16) { + // Clear upper bits of YMM registers when current compiled code uses + // wide vectors to avoid AVX <-> SSE transition penalty during call. + MacroAssembler _masm(&cbuf); + __ vzeroupper(); + } + int framesize = C->frame_slots() << LogBytesPerInt; assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); // Remove word for return adr already pushed @@ -2008,6 +2032,25 @@ encode %{ __ bind(miss); %} + enc_class clear_avx %{ + debug_only(int off0 = cbuf.insts_size()); + if (ra_->C->max_vector_size() > 16) { + // Clear upper bits of YMM registers when current compiled code uses + // wide vectors to avoid AVX <-> SSE transition penalty during call. + MacroAssembler _masm(&cbuf); + __ vzeroupper(); + } + debug_only(int off1 = cbuf.insts_size()); + assert(off1 - off0 == clear_avx_size(), "correct size prediction"); + %} + + enc_class Java_To_Runtime(method meth) %{ + // No relocation needed + MacroAssembler _masm(&cbuf); + __ mov64(r10, (int64_t) $meth$$method); + __ call(r10); + %} + enc_class Java_To_Interpreter(method meth) %{ // CALL Java_To_Interpreter @@ -11366,7 +11409,7 @@ instruct CallStaticJavaDirect(method meth) %{ ins_cost(300); format %{ "call,static " %} opcode(0xE8); /* E8 cd */ - ins_encode(Java_Static_Call(meth), call_epilog); + ins_encode(clear_avx, Java_Static_Call(meth), call_epilog); ins_pipe(pipe_slow); ins_alignment(4); %} @@ -11384,7 +11427,7 @@ instruct CallStaticJavaHandle(method meth, rbp_RegP rbp_mh_SP_save) %{ ins_cost(300); format %{ "call,static/MethodHandle " %} opcode(0xE8); /* E8 cd */ - ins_encode(preserve_SP, + ins_encode(clear_avx, preserve_SP, Java_Static_Call(meth), restore_SP, call_epilog); @@ -11403,7 +11446,7 @@ instruct CallDynamicJavaDirect(method meth) ins_cost(300); format %{ "movq rax, #Universe::non_oop_word()\n\t" "call,dynamic " %} - ins_encode(Java_Dynamic_Call(meth), call_epilog); + ins_encode(clear_avx, Java_Dynamic_Call(meth), call_epilog); ins_pipe(pipe_slow); ins_alignment(4); %} @@ -11416,8 +11459,7 @@ instruct CallRuntimeDirect(method meth) ins_cost(300); format %{ "call,runtime " %} - opcode(0xE8); /* E8 cd */ - ins_encode(Java_To_Runtime(meth)); + ins_encode(clear_avx, Java_To_Runtime(meth)); ins_pipe(pipe_slow); %} @@ -11429,8 +11471,7 @@ instruct CallLeafDirect(method meth) ins_cost(300); format %{ "call_leaf,runtime " %} - opcode(0xE8); /* E8 cd */ - ins_encode(Java_To_Runtime(meth)); + ins_encode(clear_avx, Java_To_Runtime(meth)); ins_pipe(pipe_slow); %} @@ -11442,7 +11483,6 @@ instruct CallLeafNoFPDirect(method meth) ins_cost(300); format %{ "call_leaf_nofp,runtime " %} - opcode(0xE8); /* E8 cd */ ins_encode(Java_To_Runtime(meth)); ins_pipe(pipe_slow); %} diff --git a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad index f4dc25d34fd..254328e0971 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad +++ b/hotspot/src/os_cpu/bsd_x86/vm/bsd_x86_64.ad @@ -55,20 +55,6 @@ encode %{ // adding a syntax that specifies the sizes of fields in an order, // so that the adlc can build the emit functions automagically - enc_class Java_To_Runtime(method meth) %{ - // No relocation needed - - // movq r10, - emit_opcode(cbuf, Assembler::REX_WB); - emit_opcode(cbuf, 0xB8 | (R10_enc - 8)); - emit_d64(cbuf, (int64_t) $meth$$method); - - // call (r10) - emit_opcode(cbuf, Assembler::REX_B); - emit_opcode(cbuf, 0xFF); - emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); - %} - %} @@ -76,8 +62,4 @@ encode %{ source %{ -int MachCallRuntimeNode::ret_addr_offset() { - return 13; // movq r10,#addr; callq (r10) -} - %} diff --git a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad index cf9adf40e90..3b3ac007cd1 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad +++ b/hotspot/src/os_cpu/linux_x86/vm/linux_x86_64.ad @@ -55,20 +55,6 @@ encode %{ // adding a syntax that specifies the sizes of fields in an order, // so that the adlc can build the emit functions automagically - enc_class Java_To_Runtime(method meth) %{ - // No relocation needed - - // movq r10, - emit_opcode(cbuf, Assembler::REX_WB); - emit_opcode(cbuf, 0xB8 | (R10_enc - 8)); - emit_d64(cbuf, (int64_t) $meth$$method); - - // call (r10) - emit_opcode(cbuf, Assembler::REX_B); - emit_opcode(cbuf, 0xFF); - emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); - %} - %} @@ -76,8 +62,4 @@ encode %{ source %{ -int MachCallRuntimeNode::ret_addr_offset() { - return 13; // movq r10,#addr; callq (r10) -} - %} diff --git a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad index fdce355abe9..f3334952f62 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad +++ b/hotspot/src/os_cpu/solaris_x86/vm/solaris_x86_64.ad @@ -54,39 +54,10 @@ encode %{ // main source block for now. In future, we can generalize this by // adding a syntax that specifies the sizes of fields in an order, // so that the adlc can build the emit functions automagically - - enc_class Java_To_Runtime(method meth) %{ - // No relocation needed - - // movq r10, - emit_opcode(cbuf, Assembler::REX_WB); - emit_opcode(cbuf, 0xB8 | (R10_enc - 8)); - emit_d64(cbuf, (int64_t) $meth$$method); - - // call (r10) - emit_opcode(cbuf, Assembler::REX_B); - emit_opcode(cbuf, 0xFF); - emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); - %} - - enc_class post_call_verify_mxcsr %{ - MacroAssembler _masm(&cbuf); - if (RestoreMXCSROnJNICalls) { - __ ldmxcsr(ExternalAddress(StubRoutines::amd64::mxcsr_std())); - } - else if (CheckJNICalls) { - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::amd64::verify_mxcsr_entry()))); - } - %} %} // Platform dependent source source %{ - -int MachCallRuntimeNode::ret_addr_offset() { - return 13; // movq r10,#addr; callq (r10) -} - %} diff --git a/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad b/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad index e251b2b0c37..54e183a0bc5 100644 --- a/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad +++ b/hotspot/src/os_cpu/windows_x86/vm/windows_x86_64.ad @@ -53,30 +53,11 @@ encode %{ // adding a syntax that specifies the sizes of fields in an order, // so that the adlc can build the emit functions automagically - enc_class Java_To_Runtime (method meth) %{ // CALL Java_To_Runtime - // No relocation needed - - // movq r10, - emit_opcode(cbuf, Assembler::REX_WB); - emit_opcode(cbuf, 0xB8 | (R10_enc - 8)); - emit_d64(cbuf, (int64_t) $meth$$method); - - // call (r10) - emit_opcode(cbuf, Assembler::REX_B); - emit_opcode(cbuf, 0xFF); - emit_opcode(cbuf, 0xD0 | (R10_enc - 8)); - %} - %} -// + // Platform dependent source -// + source %{ -int MachCallRuntimeNode::ret_addr_offset() -{ - return 13; // movq r10,#addr; callq (r10) -} - %} From 93c40233d6fa31d77d91c7997cf96e601b367539 Mon Sep 17 00:00:00 2001 From: Chuck Rasbold Date: Wed, 3 Apr 2013 15:00:55 -0700 Subject: [PATCH 26/52] 8010437: guarantee(this->is8bit(imm8)) failed: Short forward jump exceeds 8-bit offset Fix shorten_branches() to accurately count an initial nop that may be inserted in a block that starts with a safepoint. Reviewed-by: kvn --- hotspot/src/share/vm/opto/output.cpp | 34 ++++++++++++---------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp index c77b9f60c5e..178f3b717eb 100644 --- a/hotspot/src/share/vm/opto/output.cpp +++ b/hotspot/src/share/vm/opto/output.cpp @@ -449,6 +449,17 @@ void Compile::shorten_branches(uint* blk_starts, int& code_size, int& reloc_size int max_loop_pad = nb->code_alignment()-relocInfo::addr_unit(); if (max_loop_pad > 0) { assert(is_power_of_2(max_loop_pad+relocInfo::addr_unit()), ""); + // Adjust last_call_adr and/or last_avoid_back_to_back_adr. + // If either is the last instruction in this block, bump by + // max_loop_pad in lock-step with blk_size, so sizing + // calculations in subsequent blocks still can conservatively + // detect that it may the last instruction in this block. + if (last_call_adr == blk_starts[i]+blk_size) { + last_call_adr += max_loop_pad; + } + if (last_avoid_back_to_back_adr == blk_starts[i]+blk_size) { + last_avoid_back_to_back_adr += max_loop_pad; + } blk_size += max_loop_pad; } } @@ -1193,8 +1204,6 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { int last_call_offset = -1; int last_avoid_back_to_back_offset = -1; #ifdef ASSERT - int block_alignment_padding = 0; - uint* jmp_target = NEW_RESOURCE_ARRAY(uint,nblocks); uint* jmp_offset = NEW_RESOURCE_ARRAY(uint,nblocks); uint* jmp_size = NEW_RESOURCE_ARRAY(uint,nblocks); @@ -1228,8 +1237,6 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { Node *delay_slot = NULL; for (uint i=0; i < nblocks; i++) { - guarantee(blk_starts[i] >= (uint)cb->insts_size(),"should not increase size"); - Block *b = _cfg->_blocks[i]; Node *head = b->head(); @@ -1250,14 +1257,6 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { jmp_offset[i] = 0; jmp_size[i] = 0; jmp_rule[i] = 0; - - // Maximum alignment padding for loop block was used - // during first round of branches shortening, as result - // padding for nodes (sfpt after call) was not added. - // Take this into account for block's size change check - // and allow increase block's size by the difference - // of maximum and actual alignment paddings. - int orig_blk_size = blk_starts[i+1] - blk_starts[i] + block_alignment_padding; #endif int blk_offset = current_offset; @@ -1557,8 +1556,6 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { } } // End for all instructions in block - assert((uint)blk_offset <= blk_starts[i], "shouldn't increase distance"); - blk_starts[i] = blk_offset; // If the next block is the top of a loop, pad this block out to align // the loop top a little. Helps prevent pipe stalls at loop back branches. @@ -1572,16 +1569,13 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { nop->emit(*cb, _regalloc); current_offset = cb->insts_size(); } -#ifdef ASSERT - int max_loop_pad = nb->code_alignment()-relocInfo::addr_unit(); - block_alignment_padding = (max_loop_pad - padding); - assert(block_alignment_padding >= 0, "sanity"); -#endif } // Verify that the distance for generated before forward // short branches is still valid. - assert(orig_blk_size >= (current_offset - blk_offset), "shouldn't increase block size"); + guarantee((int)(blk_starts[i+1] - blk_starts[i]) >= (current_offset - blk_offset), "shouldn't increase block size"); + // Save new block start offset + blk_starts[i] = blk_offset; } // End of for all blocks blk_starts[nblocks] = current_offset; From 0f3a43e3184c1207b74fe55b8039b40ce6266f12 Mon Sep 17 00:00:00 2001 From: Niclas Adlertz Date: Thu, 4 Apr 2013 09:18:47 +0200 Subject: [PATCH 27/52] 8006008: Memory leak in hotspot/src/share/vm/adlc/archDesc.cpp Reviewed-by: roland, kvn --- hotspot/src/share/vm/adlc/archDesc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/src/share/vm/adlc/archDesc.cpp b/hotspot/src/share/vm/adlc/archDesc.cpp index a8983ebaee0..7e272e4d028 100644 --- a/hotspot/src/share/vm/adlc/archDesc.cpp +++ b/hotspot/src/share/vm/adlc/archDesc.cpp @@ -832,6 +832,7 @@ static const char *getRegMask(const char *reg_class_name) { int length = (int)strlen(rc_name) + (int)strlen(mask) + 5; char *regMask = new char[length]; sprintf(regMask,"%s%s()", rc_name, mask); + delete[] rc_name; return regMask; } } From a88f9ec2d628451ee1d62a85f84d4f79b6f4b059 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 4 Apr 2013 09:24:21 +0200 Subject: [PATCH 28/52] 8006828: "SKIP_BOOT_CYCLE=false" must work in new building infrastructure Reviewed-by: tbell, alanb --- common/autoconf/bootcycle-spec.gmk.in | 14 ++++++++++++-- common/autoconf/spec.gmk.in | 18 ++++++++++-------- common/makefiles/Jprt.gmk | 4 ++++ common/makefiles/Main.gmk | 5 ++--- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/common/autoconf/bootcycle-spec.gmk.in b/common/autoconf/bootcycle-spec.gmk.in index 6edca725b00..9bc4007dbbb 100644 --- a/common/autoconf/bootcycle-spec.gmk.in +++ b/common/autoconf/bootcycle-spec.gmk.in @@ -29,9 +29,16 @@ include @SPEC@ # Check that the user did not try to specify a different java to use for compiling. -ifneq ($(firstword $(SJAVAC_SERVER_JAVA)),$(firstword $(JAVA))) - $(error Bootcycle builds are not possible if --with-sjavac-server-java is specified) +# On windows we need to account for fixpath being first word. +ifeq ($(firstword $(JAVA)),$(FIXPATH)) + JAVA_EXEC_POS=2 +else + JAVA_EXEC_POS=1 endif +ifneq ($(word $(JAVA_EXEC_POS),$(SJAVAC_SERVER_JAVA)),$(word $(JAVA_EXEC_POS),$(JAVA))) + $(error Bootcycle builds are not possible if --with-sjavac-server-java is specified) +endif + # Override specific values to do a boot cycle build @@ -39,5 +46,8 @@ endif BUILD_OUTPUT:=@BUILD_OUTPUT@/bootcycle-build # Use a different Boot JDK +OLD_BOOT_JDK:=$(BOOT_JDK) BOOT_JDK:=@BUILD_OUTPUT@/images/j2sdk-image BOOT_RTJAR:=@BUILD_OUTPUT@/images/j2sdk-image/jre/lib/rt.jar + +SJAVAC_SERVER_JAVA:=$(subst $(OLD_BOOT_JDK),$(BOOT_JDK),$(SJAVAC_SERVER_JAVA)) diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index bfba636a7b1..4e5b7b48ca1 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -225,6 +225,7 @@ BUILD_VARIANT_RELEASE:=@BUILD_VARIANT_RELEASE@ # directory. BUILD_OUTPUT:=@BUILD_OUTPUT@ +# Colon left out to be able to override IMAGES_OUTPUTDIR for bootcycle-images LANGTOOLS_OUTPUTDIR=$(BUILD_OUTPUT)/langtools CORBA_OUTPUTDIR=$(BUILD_OUTPUT)/corba JAXP_OUTPUTDIR=$(BUILD_OUTPUT)/jaxp @@ -643,16 +644,17 @@ JDK_IMAGE_SUBDIR:=j2sdk-image JRE_IMAGE_SUBDIR:=j2re-image JDK_OVERLAY_IMAGE_SUBDIR:=j2sdk-overlay-image JRE_OVERLAY_IMAGE_SUBDIR:=j2re-overlay-image -JDK_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/$(JDK_IMAGE_SUBDIR) -JRE_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/$(JRE_IMAGE_SUBDIR) -JDK_OVERLAY_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/$(JDK_OVERLAY_IMAGE_SUBDIR) -JRE_OVERLAY_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/$(JRE_OVERLAY_IMAGE_SUBDIR) +# Colon left out to be able to override output dir for bootcycle-images +JDK_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_IMAGE_SUBDIR) +JRE_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_IMAGE_SUBDIR) +JDK_OVERLAY_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_OVERLAY_IMAGE_SUBDIR) +JRE_OVERLAY_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_OVERLAY_IMAGE_SUBDIR) # Macosx bundles directory definitions -JDK_BUNDLE_SUBDIR:=j2sdk-bundle/jdk$(JDK_VERSION).jdk/Contents -JRE_BUNDLE_SUBDIR:=j2re-bundle/jre$(JDK_VERSION).jre/Contents -JDK_BUNDLE_DIR:=$(IMAGES_OUTPUTDIR)/$(JDK_BUNDLE_SUBDIR) -JRE_BUNDLE_DIR:=$(IMAGES_OUTPUTDIR)/$(JRE_BUNDLE_SUBDIR) +JDK_BUNDLE_SUBDIR=j2sdk-bundle/jdk$(JDK_VERSION).jdk/Contents +JRE_BUNDLE_SUBDIR=j2re-bundle/jre$(JDK_VERSION).jre/Contents +JDK_BUNDLE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_BUNDLE_SUBDIR) +JRE_BUNDLE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_BUNDLE_SUBDIR) # Include the custom-spec.gmk file if it exists -include $(dir @SPEC@)/custom-spec.gmk diff --git a/common/makefiles/Jprt.gmk b/common/makefiles/Jprt.gmk index c70cf8872b4..938d4362e29 100644 --- a/common/makefiles/Jprt.gmk +++ b/common/makefiles/Jprt.gmk @@ -64,6 +64,10 @@ HOTSPOT_AVAILABLE := $(if $(wildcard $(root_dir)/hotspot),true,false) # Build with the configure bridge. After running configure, restart make # to parse the new spec file. BRIDGE_TARGETS := all +# Add bootcycle-images target if legacy variable is set. +ifeq ($(SKIP_BOOT_CYCLE),false) + BRIDGE_TARGETS += bootcycle-images +endif bridgeBuild: bridge2configure @cd $(root_dir) && $(MAKE) -f NewMakefile.gmk $(BRIDGE_TARGETS) diff --git a/common/makefiles/Main.gmk b/common/makefiles/Main.gmk index 11dda4bcff2..9e2bd401759 100644 --- a/common/makefiles/Main.gmk +++ b/common/makefiles/Main.gmk @@ -175,9 +175,8 @@ sign-jars-only: start-make @($(CD) $(JDK_TOPDIR)/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) -f BuildJdk.gmk sign-jars) @$(call TargetExit) -bootcycle-images: - @$(ECHO) Boot cycle build step 1: Building the JDK image normally - @($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(SPEC) images) +bootcycle-images: images bootcycle-images-only +bootcycle-images-only: start-make @$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image @($(CD) $(SRC_ROOT)/common/makefiles && $(BUILD_LOG_WRAPPER) $(MAKE) SPEC=$(dir $(SPEC))bootcycle-spec.gmk images) From 3231305a340c893ede3698a466e4d171a1c52cb0 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 4 Apr 2013 09:25:58 +0200 Subject: [PATCH 29/52] 8011372: Remove -p from cp in IdleCompilation.gmk Reviewed-by: pliden, tbell --- common/makefiles/IdlCompilation.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/makefiles/IdlCompilation.gmk b/common/makefiles/IdlCompilation.gmk index 2eb77dd3beb..b03ea43a9e5 100644 --- a/common/makefiles/IdlCompilation.gmk +++ b/common/makefiles/IdlCompilation.gmk @@ -70,7 +70,7 @@ define add_idl_package $(PREFIXES) \ $4 $(RM) -f $$(addprefix $3/$$($4_TMPDIR)/,$6) - $(CP) -rp $3/$$($4_TMPDIR)/* $3 + $(CP) -r $3/$$($4_TMPDIR)/* $3 ($(CD) $3/$$($4_TMPDIR) && $(FIND) . -type f | $(SED) 's!\./!$3/!g' | $(NAWK) '{ print $$$$1 ": $4" }' > $5) $(RM) -rf $3/$$($4_TMPDIR) endef From 02a014996bb81f76573ac914723d8e34f3b8f0d0 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Thu, 4 Apr 2013 09:33:24 +0200 Subject: [PATCH 30/52] 8010399: Test8009761.java "Failed: init recursive calls: 5498. After deopt 5494" Test from 8009761 shouldn't be run with -Xcomp Reviewed-by: kvn --- hotspot/test/compiler/8009761/Test8009761.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/compiler/8009761/Test8009761.java b/hotspot/test/compiler/8009761/Test8009761.java index c897ab40069..f588b82cd23 100644 --- a/hotspot/test/compiler/8009761/Test8009761.java +++ b/hotspot/test/compiler/8009761/Test8009761.java @@ -25,7 +25,7 @@ * @test * @bug 8009761 * @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates - * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation Test8009761 + * @run main/othervm -Xmixed -XX:-UseOnStackReplacement -XX:-BackgroundCompilation Test8009761 * */ From 5548661d72b8a11c8bdad43d2d9a9a2649f8cdbd Mon Sep 17 00:00:00 2001 From: Niclas Adlertz Date: Thu, 4 Apr 2013 09:30:06 +0200 Subject: [PATCH 31/52] 8006014: Memory leak in hotspot/src/share/vm/adlc/dfa.cpp Reviewed-by: kvn, roland --- hotspot/src/share/vm/adlc/dfa.cpp | 41 ++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/hotspot/src/share/vm/adlc/dfa.cpp b/hotspot/src/share/vm/adlc/dfa.cpp index 5333c152cea..6b15911a067 100644 --- a/hotspot/src/share/vm/adlc/dfa.cpp +++ b/hotspot/src/share/vm/adlc/dfa.cpp @@ -191,12 +191,19 @@ static void cost_check(FILE *fp, const char *spaces, // Macro equivalent to: _kids[0]->valid(FOO) && _kids[1]->valid(BAR) // static void child_test(FILE *fp, MatchList &mList) { - if( mList._lchild ) // If left child, check it - fprintf(fp, "STATE__VALID_CHILD(_kids[0], %s)", ArchDesc::getMachOperEnum(mList._lchild)); - if( mList._lchild && mList._rchild ) // If both, add the "&&" - fprintf(fp, " && " ); - if( mList._rchild ) // If right child, check it - fprintf(fp, "STATE__VALID_CHILD(_kids[1], %s)", ArchDesc::getMachOperEnum(mList._rchild)); + if (mList._lchild) { // If left child, check it + const char* lchild_to_upper = ArchDesc::getMachOperEnum(mList._lchild); + fprintf(fp, "STATE__VALID_CHILD(_kids[0], %s)", lchild_to_upper); + delete[] lchild_to_upper; + } + if (mList._lchild && mList._rchild) { // If both, add the "&&" + fprintf(fp, " && "); + } + if (mList._rchild) { // If right child, check it + const char* rchild_to_upper = ArchDesc::getMachOperEnum(mList._rchild); + fprintf(fp, "STATE__VALID_CHILD(_kids[1], %s)", rchild_to_upper); + delete[] rchild_to_upper; + } } //---------------------------calc_cost----------------------------------------- @@ -206,13 +213,17 @@ static void child_test(FILE *fp, MatchList &mList) { Expr *ArchDesc::calc_cost(FILE *fp, const char *spaces, MatchList &mList, ProductionState &status) { fprintf(fp, "%sunsigned int c = ", spaces); Expr *c = new Expr("0"); - if (mList._lchild ) { // If left child, add it in - sprintf(Expr::buffer(), "_kids[0]->_cost[%s]", ArchDesc::getMachOperEnum(mList._lchild)); + if (mList._lchild) { // If left child, add it in + const char* lchild_to_upper = ArchDesc::getMachOperEnum(mList._lchild); + sprintf(Expr::buffer(), "_kids[0]->_cost[%s]", lchild_to_upper); c->add(Expr::buffer()); + delete[] lchild_to_upper; } - if (mList._rchild) { // If right child, add it in - sprintf(Expr::buffer(), "_kids[1]->_cost[%s]", ArchDesc::getMachOperEnum(mList._rchild)); + if (mList._rchild) { // If right child, add it in + const char* rchild_to_upper = ArchDesc::getMachOperEnum(mList._rchild); + sprintf(Expr::buffer(), "_kids[1]->_cost[%s]", rchild_to_upper); c->add(Expr::buffer()); + delete[] rchild_to_upper; } // Add in cost of this rule const char *mList_cost = mList.get_cost(); @@ -232,15 +243,17 @@ void ArchDesc::gen_match(FILE *fp, MatchList &mList, ProductionState &status, Di fprintf(fp, "%s", spaces4); // Only generate child tests if this is not a leaf node bool has_child_constraints = mList._lchild || mList._rchild; - const char *predicate_test = mList.get_pred(); - if( has_child_constraints || predicate_test ) { + const char *predicate_test = mList.get_pred(); + if (has_child_constraints || predicate_test) { // Open the child-and-predicate-test braces fprintf(fp, "if( "); status.set_constraint(hasConstraint); child_test(fp, mList); // Only generate predicate test if one exists for this match - if( predicate_test ) { - if( has_child_constraints ) { fprintf(fp," &&\n"); } + if (predicate_test) { + if (has_child_constraints) { + fprintf(fp," &&\n"); + } fprintf(fp, "%s %s", spaces6, predicate_test); } // End of outer tests From c68fa92e4b77f9b16f5e5802b1ccbd2b58ba809d Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Thu, 4 Apr 2013 12:18:46 -0700 Subject: [PATCH 32/52] 8011198: LP64 setting is not preserved on Solaris after 8006965 Fixed incremental build makefiles generated by buildtree.make. Consolidated unix build.sh. Reviewed-by: twisti --- hotspot/make/bsd/makefiles/buildtree.make | 14 +- hotspot/make/{bsd => }/build.sh | 81 ++++++----- hotspot/make/linux/build.sh | 98 -------------- hotspot/make/linux/makefiles/buildtree.make | 16 ++- hotspot/make/solaris/build.sh | 127 ------------------ hotspot/make/solaris/makefiles/buildtree.make | 15 ++- hotspot/src/os/posix/launcher/launcher.script | 2 +- 7 files changed, 82 insertions(+), 271 deletions(-) rename hotspot/make/{bsd => }/build.sh (50%) delete mode 100644 hotspot/make/linux/build.sh delete mode 100644 hotspot/make/solaris/build.sh diff --git a/hotspot/make/bsd/makefiles/buildtree.make b/hotspot/make/bsd/makefiles/buildtree.make index 71bb04b9811..752e0febb76 100644 --- a/hotspot/make/bsd/makefiles/buildtree.make +++ b/hotspot/make/bsd/makefiles/buildtree.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 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 @@ -190,6 +190,17 @@ $(SIMPLE_DIRS): # literal "$(GAMMADIR)/" suitable for inclusion in a Makefile. gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2))) +# This bit is needed to enable local rebuilds. +# Unless the makefile itself sets LP64, any environmental +# setting of LP64 will interfere with the build. +LP64_SETTING/32 = LP64 = \#empty +LP64_SETTING/64 = LP64 = 1 + +DATA_MODE/i486 = 32 +DATA_MODE/amd64 = 64 + +DATA_MODE = $(DATA_MODE/$(BUILDARCH)) + flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst @echo Creating $@ ... $(QUIETLY) ( \ @@ -212,6 +223,7 @@ flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \ echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \ echo "OPENJDK = $(OPENJDK)"; \ + echo "$(LP64_SETTING/$(DATA_MODE))"; \ echo; \ echo "# Used for platform dispatching"; \ echo "TARGET_DEFINES = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \ diff --git a/hotspot/make/bsd/build.sh b/hotspot/make/build.sh similarity index 50% rename from hotspot/make/bsd/build.sh rename to hotspot/make/build.sh index ddb07e54129..d05ce4474ac 100644 --- a/hotspot/make/bsd/build.sh +++ b/hotspot/make/build.sh @@ -1,6 +1,6 @@ #! /bin/sh # -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 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 @@ -28,44 +28,38 @@ set -u -if [ $# != 2 ]; then - echo "Usage : $0 Build_Options Location" - echo "Build Options : debug or optimized or basicdebug or basic or clean" - echo "Location : specify any workspace which has gamma sources" +if [ $# -lt 1 ]; then + echo "Usage : $0 BuildTarget [LP64=1] [BuildOptions]" + echo " Server VM | Client VM" + echo "BuildTarget : debug | debug1" + echo " fastdebug | fastdebug1" + echo " jvmg | jvmg1" + echo " optimized | optimized1" + echo " profiled | profiled1" + echo " product | product1" + exit 1 +fi + +if [ "${JAVA_HOME-}" = "" -o ! -d "${JAVA_HOME-}" -o ! -d ${JAVA_HOME-}/jre/lib/ ]; then + echo "JAVA_HOME needs to be set to a valid JDK path" + echo "JAVA_HOME: ${JAVA_HOME-}" exit 1 fi # Just in case: -case ${JAVA_HOME} in -/*) true;; -?*) JAVA_HOME=`( cd $JAVA_HOME; pwd )`;; -esac +JAVA_HOME=`( cd $JAVA_HOME; pwd )` -case `uname -m` in - i386|i486|i586|i686) - mach=i386 - ;; - *) - echo "Unsupported machine: " `uname -m` - exit 1 - ;; -esac - -if [ "${JAVA_HOME}" = "" -o ! -d "${JAVA_HOME}" -o ! -d ${JAVA_HOME}/jre/lib/${mach} ]; then - echo "JAVA_HOME needs to be set to a valid JDK path" - echo "ksh : export JAVA_HOME=/net/tetrasparc/export/gobi/JDK1.2_fcs_V/bsd" - echo "csh : setenv JAVA_HOME /net/tetrasparc/export/gobi/JDK1.2_fcs_V/bsd" - exit 1 +if [ "${ALT_BOOTDIR-}" = "" -o ! -d "${ALT_BOOTDIR-}" -o ! -d ${ALT_BOOTDIR-}/jre/lib/ ]; then + ALT_BOOTDIR=${JAVA_HOME} fi +# build in current directory by default +if [ "${ALT_OUTPUTDIR-}" = "" -o ! -d "${ALT_OUTPUTDIR-}" ]; then + ALT_OUTPUTDIR=`(pwd)` +fi -LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/`uname -p`:\ -${JAVA_HOME}/jre/lib/`uname -p`/native_threads:${LD_LIBRARY_PATH-.} - -# This is necessary as long as we are using the old launcher -# with the new distribution format: -CLASSPATH=${JAVA_HOME}/jre/lib/rt.jar:${CLASSPATH-.} - +HOTSPOT_SRC=`(dirname $0)`/.. +HOTSPOT_SRC=`(cd ${HOTSPOT_SRC}; pwd)` for gm in gmake gnumake do @@ -74,22 +68,25 @@ do done : ${GNUMAKE:?'Cannot locate the gnumake program. Stop.'} +# quiet build by default +Quiet="MAKE_VERBOSE=" + +# no debug info by default +NoDebugInfo="ENABLE_FULL_DEBUG_SYMBOLS=" + +LANG=C echo "### ENVIRONMENT SETTINGS:" +export HOTSPOT_SRC ; echo "HOTSPOT_SRC=$HOTSPOT_SRC" export JAVA_HOME ; echo "JAVA_HOME=$JAVA_HOME" -export LD_LIBRARY_PATH ; echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" -export CLASSPATH ; echo "CLASSPATH=$CLASSPATH" +export ALT_BOOTDIR ; echo "ALT_BOOTDIR=$ALT_BOOTDIR" +export ALT_OUTPUTDIR ; echo "ALT_OUTPUTDIR=$ALT_OUTPUTDIR" export GNUMAKE ; echo "GNUMAKE=$GNUMAKE" +export LANG ; echo "LANG=$LANG" echo "###" -Build_Options=$1 -Location=$2 - -case ${Location} in -/*) true;; -?*) Location=`(cd ${Location}; pwd)`;; -esac +BuildOptions="$Quiet $NoDebugInfo $*" echo \ -${GNUMAKE} -f ${Location}/make/bsd/Makefile $Build_Options GAMMADIR=${Location} -${GNUMAKE} -f ${Location}/make/bsd/Makefile $Build_Options GAMMADIR=${Location} +${GNUMAKE} -f ${HOTSPOT_SRC}/make/Makefile $BuildOptions GAMMADIR=${HOTSPOT_SRC} +${GNUMAKE} -f ${HOTSPOT_SRC}/make/Makefile $BuildOptions GAMMADIR=${HOTSPOT_SRC} diff --git a/hotspot/make/linux/build.sh b/hotspot/make/linux/build.sh deleted file mode 100644 index 79844c51e1e..00000000000 --- a/hotspot/make/linux/build.sh +++ /dev/null @@ -1,98 +0,0 @@ -#! /bin/sh -# -# 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. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please 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 the variable JAVA_HOME is set before running this script. - -set -u - - -if [ $# != 2 ]; then - echo "Usage : $0 Build_Options Location" - echo "Build Options : debug or optimized or basicdebug or basic or clean" - echo "Location : specify any workspace which has gamma sources" - exit 1 -fi - -# Just in case: -case ${JAVA_HOME} in -/*) true;; -?*) JAVA_HOME=`( cd $JAVA_HOME; pwd )`;; -esac - -case `uname -m` in - i386|i486|i586|i686) - mach=i386 - ;; - x86_64) - mach=amd64 - ;; - *) - echo "Unsupported machine: " `uname -m` - exit 1 - ;; -esac - -if [ "${JAVA_HOME}" = "" -o ! -d "${JAVA_HOME}" -o ! -d ${JAVA_HOME}/jre/lib/${mach} ]; then - echo "JAVA_HOME needs to be set to a valid JDK path" - echo "ksh : export JAVA_HOME=/net/tetrasparc/export/gobi/JDK1.2_fcs_V/linux" - echo "csh : setenv JAVA_HOME /net/tetrasparc/export/gobi/JDK1.2_fcs_V/linux" - exit 1 -fi - - -LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/`uname -p`:\ -${JAVA_HOME}/jre/lib/`uname -p`/native_threads:${LD_LIBRARY_PATH-.} - -# This is necessary as long as we are using the old launcher -# with the new distribution format: -CLASSPATH=${JAVA_HOME}/jre/lib/rt.jar:${CLASSPATH-.} - - -for gm in gmake gnumake -do - if [ "${GNUMAKE-}" != "" ]; then break; fi - ($gm --version >/dev/null) 2>/dev/null && GNUMAKE=$gm -done -: ${GNUMAKE:?'Cannot locate the gnumake program. Stop.'} - - -echo "### ENVIRONMENT SETTINGS:" -export JAVA_HOME ; echo "JAVA_HOME=$JAVA_HOME" -export LD_LIBRARY_PATH ; echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" -export CLASSPATH ; echo "CLASSPATH=$CLASSPATH" -export GNUMAKE ; echo "GNUMAKE=$GNUMAKE" -echo "###" - -Build_Options=$1 -Location=$2 - -case ${Location} in -/*) true;; -?*) Location=`(cd ${Location}; pwd)`;; -esac - -echo \ -${GNUMAKE} -f ${Location}/make/linux/Makefile $Build_Options GAMMADIR=${Location} -${GNUMAKE} -f ${Location}/make/linux/Makefile $Build_Options GAMMADIR=${Location} diff --git a/hotspot/make/linux/makefiles/buildtree.make b/hotspot/make/linux/makefiles/buildtree.make index b75b4d57876..f980dcdafe0 100644 --- a/hotspot/make/linux/makefiles/buildtree.make +++ b/hotspot/make/linux/makefiles/buildtree.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 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 @@ -183,6 +183,19 @@ $(SIMPLE_DIRS): # literal "$(GAMMADIR)/" suitable for inclusion in a Makefile. gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2))) +# This bit is needed to enable local rebuilds. +# Unless the makefile itself sets LP64, any environmental +# setting of LP64 will interfere with the build. +LP64_SETTING/32 = LP64 = \#empty +LP64_SETTING/64 = LP64 = 1 + +DATA_MODE/i486 = 32 +DATA_MODE/sparc = 32 +DATA_MODE/sparcv9 = 64 +DATA_MODE/amd64 = 64 + +DATA_MODE = $(DATA_MODE/$(BUILDARCH)) + flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst @echo Creating $@ ... $(QUIETLY) ( \ @@ -205,6 +218,7 @@ flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \ echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \ echo "OPENJDK = $(OPENJDK)"; \ + echo "$(LP64_SETTING/$(DATA_MODE))"; \ echo; \ echo "# Used for platform dispatching"; \ echo "TARGET_DEFINES = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \ diff --git a/hotspot/make/solaris/build.sh b/hotspot/make/solaris/build.sh deleted file mode 100644 index 9a8326ac67e..00000000000 --- a/hotspot/make/solaris/build.sh +++ /dev/null @@ -1,127 +0,0 @@ -#! /bin/sh -# -# Copyright (c) 1998, 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. -# -# - -# Make sure the variable JAVA_HOME is set before running this script. - -set -u - - -usage() { - ( - echo "Usage : $0 [-sb | -sbfast] config ws_path" - echo "" - echo "Where:" - echo " -sb ::= enable source browser info generation for" - echo " all configs during compilation" - echo "" - echo " -sbfast ::= enable source browser info generation for" - echo " all configs without compilation" - echo "" - echo " config ::= debug | debug1 | debugcore" - echo " fastdebug | fastdebug1 | fastdebugcore" - echo " jvmg | jvmg1 | jvmgcore" - echo " optimized | optimized1 | optimizedcore" - echo " profiled | profiled1 | profiledcore" - echo " product | product1 | productcore" - echo "" - echo " ws_path ::= path to HotSpot workspace" - ) >&2 - exit 1 -} - -# extract possible options -options="" -if [ $# -gt 2 ]; then - case "$1" in - -sb) - options="CFLAGS_BROWSE=-xsb" - shift - ;; - -sbfast) - options="CFLAGS_BROWSE=-xsbfast" - shift - ;; - *) - echo "Unknown option: '$1'" >&2 - usage - ;; - esac -fi - -# should be just two args left at this point -if [ $# != 2 ]; then - usage -fi - -# Just in case: -case ${JAVA_HOME} in -/*) true;; -?*) JAVA_HOME=`( cd $JAVA_HOME; pwd )`;; -esac - -if [ "${JAVA_HOME}" = "" -o ! -d "${JAVA_HOME}" -o ! -d ${JAVA_HOME}/jre/lib/`uname -p` ]; then - echo "JAVA_HOME needs to be set to a valid JDK path" - echo "ksh : export JAVA_HOME=/net/tetrasparc/export/gobi/JDK1.2_fcs_V/solaris" - echo "csh : setenv JAVA_HOME /net/tetrasparc/export/gobi/JDK1.2_fcs_V/solaris" - exit 1 -fi - - -LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/`uname -p`:\ -${JAVA_HOME}/jre/lib/`uname -p`/native_threads:${LD_LIBRARY_PATH-.} - -# This is necessary as long as we are using the old launcher -# with the new distribution format: -CLASSPATH=${JAVA_HOME}/jre/lib/rt.jar:${CLASSPATH-.} - - -for gm in gmake gnumake -do - if [ "${GNUMAKE-}" != "" ]; then break; fi - ($gm --version >/dev/null) 2>/dev/null && GNUMAKE=$gm -done -: ${GNUMAKE:?'Cannot locate the gnumake program. Stop.'} - - -echo "### ENVIRONMENT SETTINGS:" -export JAVA_HOME ; echo "JAVA_HOME=$JAVA_HOME" -export LD_LIBRARY_PATH ; echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" -export CLASSPATH ; echo "CLASSPATH=$CLASSPATH" -export GNUMAKE ; echo "GNUMAKE=$GNUMAKE" -echo "###" - -config=$1 -ws_path=$2 - -case ${ws_path} in -/*) true;; -?*) ws_path=`(cd ${ws_path}; pwd)`;; -esac - -echo \ -${GNUMAKE} -f ${ws_path}/make/solaris/Makefile \ - $config GAMMADIR=${ws_path} $options -${GNUMAKE} -f ${ws_path}/make/solaris/Makefile \ - $config GAMMADIR=${ws_path} $options diff --git a/hotspot/make/solaris/makefiles/buildtree.make b/hotspot/make/solaris/makefiles/buildtree.make index 707d5f36a8d..a3ab0b5e52c 100644 --- a/hotspot/make/solaris/makefiles/buildtree.make +++ b/hotspot/make/solaris/makefiles/buildtree.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 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 @@ -176,6 +176,19 @@ $(SIMPLE_DIRS): # literal "$(GAMMADIR)/" suitable for inclusion in a Makefile. gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2))) +# This bit is needed to enable local rebuilds. +# Unless the makefile itself sets LP64, any environmental +# setting of LP64 will interfere with the build. +LP64_SETTING/32 = LP64 = \#empty +LP64_SETTING/64 = LP64 = 1 + +DATA_MODE/i486 = 32 +DATA_MODE/sparc = 32 +DATA_MODE/sparcv9 = 64 +DATA_MODE/amd64 = 64 + +DATA_MODE = $(DATA_MODE/$(BUILDARCH)) + flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst @echo Creating $@ ... $(QUIETLY) ( \ diff --git a/hotspot/src/os/posix/launcher/launcher.script b/hotspot/src/os/posix/launcher/launcher.script index 0a2ae5f4d6b..e8d4281808a 100644 --- a/hotspot/src/os/posix/launcher/launcher.script +++ b/hotspot/src/os/posix/launcher/launcher.script @@ -199,7 +199,7 @@ case "$MODE" in rm -f $GDBSCR ;; dbx) - $DBX -s $MYDIR/.dbxrc $LAUNCHER $JPARAMS + $DBX -s $HOME/.dbxrc $LAUNCHER $JPARMS ;; valgrind) echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap From 2c9fb2de3ee303ec34681133ef2337f5359cb34a Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:04 -0700 Subject: [PATCH 33/52] Added tag jdk8-b84 for changeset aec7eec37b03 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index db8b4550f1e..0896e836000 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -205,3 +205,4 @@ fd1a5574cf68af24bfd52decc37ac6361afb278a jdk8-b78 145dbc56f931c134e837b675b9e6e7bf08902e93 jdk8-b81 29153d0df68f84162ffe8c2cf4f402a3f2245e85 jdk8-b82 466685ba01bfb7bc1e1ac61490fd8c0f3cc18763 jdk8-b83 +01f631f89fa392b4e484d0812c40ea8f9d2353aa jdk8-b84 From 3cf1973527813a586ad6b7eb7c993b62958c5f74 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:06 -0700 Subject: [PATCH 34/52] Added tag jdk8-b84 for changeset 8d11dc7a1d97 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 5a2a5cfc102..1558a0bafe8 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -205,3 +205,4 @@ e41fb1aa0329767b2737303c994e38bede1baa07 jdk8-b79 2a00aeeb466b9dee22508f6261f63b70f9c696fe jdk8-b81 48e1bc77004d9af575b733c04637b98fd17603c2 jdk8-b82 a45bb25a67c7517b45f00c9682e317f46fecbba9 jdk8-b83 +928f8b888deb785cbd7bbd5f951cd6880f11f14e jdk8-b84 From c8755701efcf8560b6b4a757c4d4c2d1844a10a4 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:12 -0700 Subject: [PATCH 35/52] Added tag jdk8-b84 for changeset df190a3da0e2 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 40fd36ae97f..ea220e83592 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -328,3 +328,4 @@ dd6350b4abc4a6c19c89dd982cc0e4f3d119885c hs25-b22 e3a41fc0234895eba4f272b984f7dacff495f8eb hs25-b24 1c8db54ee9f315e20d6d5d9bf0b5c10349e9d301 jdk8-b83 8d0f263a370c5f3e61791bb06054560804117288 hs25-b25 +af788b85010ebabbc1e8f52c6766e08c7a95cf99 jdk8-b84 From 0f87989600ab810735f37b7ce33df52198ced482 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:21 -0700 Subject: [PATCH 36/52] Added tag jdk8-b84 for changeset 545ba3c9bf47 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 21b40f387ac..ea02757c9b6 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -205,3 +205,4 @@ ff0b73a6b3f6cea644d37d56d746a37743419fa7 jdk8-b75 ef3495555a4c6e706a3058c18aa229b14220de0b jdk8-b81 d5a58291f09a5081eaf22c2a6ab2f9ced4b78882 jdk8-b82 a46d69a1a8ec9652a48114823535372e1c980799 jdk8-b83 +f5f40094ffcc1230e2a5f76ea4c968645369be6c jdk8-b84 From 188c36b378fcba61298deaecba9cb1b8195d017c Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:24 -0700 Subject: [PATCH 37/52] Added tag jdk8-b84 for changeset 0ee966fccbc1 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 7bfa0ebd9f6..50c6a136c6e 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -205,3 +205,4 @@ b0224010e2f0c2474055ac592c8d3f37b9264690 jdk8-b80 c88bb21560ccf1a9e6d2a2ba08ed2045a002676f jdk8-b81 d8d8032d02d77fbf5f9b3bb8df73663f42fd4dd0 jdk8-b82 a1dcc0d83da1e07f3ada60ef110dd105d95d3554 jdk8-b83 +5773e3fc83803f392234ba54c3a437ba176f1ead jdk8-b84 From f4cf1435ed37a53cffb6f175a0aca18657012371 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:42 -0700 Subject: [PATCH 38/52] Added tag jdk8-b84 for changeset 5e63bda2ec36 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 359cd5e1440..193803775a3 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -205,3 +205,4 @@ a8227c61768499dac847ea718af6719027c949f2 jdk8-b80 ed69d087fdfd394491657a28ba9bc58e7849b7db jdk8-b81 825da6847791994a8f405ee397df9e7fa638a458 jdk8-b82 22ba3f92d4ae43bbc19793e854171cae2586f644 jdk8-b83 +cfb65ca92082b2412aed66c8422c2466bde544ef jdk8-b84 From 403f66ad1ddaf72eb6b8ea006b08f493e90995c0 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 4 Apr 2013 19:05:46 -0700 Subject: [PATCH 39/52] Added tag jdk8-b84 for changeset c3a8125548f0 --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index d182815a343..9886903b721 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -193,3 +193,4 @@ b8a1b238c77c7c00024daaa2cb7d10838e017b5f jdk8-b68 b8a1b238c77c7c00024daaa2cb7d10838e017b5f jdk8-b69 5759f600fcf7b51ccc6cc8229be980e2153f8675 jdk8-b82 053d7c55dc8272b58b8bb870dc92a4acf896d52a jdk8-b83 +999cc1bf55203f51b2985feae6378932667ecff2 jdk8-b84 From fe9ae80e5dcc098d5feb4e5e05ed8d0ea7a6731c Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Thu, 4 Apr 2013 21:06:39 -0700 Subject: [PATCH 40/52] Added tag hs25-b26 for changeset 7d026deaf1db --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index ea220e83592..b76e841cb82 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -329,3 +329,4 @@ e3a41fc0234895eba4f272b984f7dacff495f8eb hs25-b24 1c8db54ee9f315e20d6d5d9bf0b5c10349e9d301 jdk8-b83 8d0f263a370c5f3e61791bb06054560804117288 hs25-b25 af788b85010ebabbc1e8f52c6766e08c7a95cf99 jdk8-b84 +a947f40fb536e5b9e0aa210cf26abb430f80887a hs25-b26 From 6cb72b3aabbbda5009471bd5e7d02dfbdb99ae33 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Fri, 5 Apr 2013 09:38:54 +0200 Subject: [PATCH 41/52] 8008373: JFR JTReg tests fail with CompilationError on MacOSX; missing '._sunec.jar' Reviewed-by: tbell --- common/autoconf/basics.m4 | 4 + common/autoconf/generated-configure.sh | 542 +++++++++++++------------ common/autoconf/spec.gmk.in | 1 + common/makefiles/MakeBase.gmk | 11 +- 4 files changed, 306 insertions(+), 252 deletions(-) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index c713d22a804..20f444ff702 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -602,6 +602,10 @@ AC_PATH_PROG(TIME, time) if test "x$OPENJDK_TARGET_OS" = "xwindows"; then BASIC_REQUIRE_PROG(COMM, comm) fi + +if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then + BASIC_REQUIRE_PROG(XATTR, xattr) +fi ]) # Check if build directory is on local disk. If not possible to determine, diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 2293c92d133..259b93866fb 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for OpenJDK jdk8. +# Generated by GNU Autoconf 2.67 for OpenJDK jdk8. # # Report bugs to . # @@ -91,7 +91,6 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -217,18 +216,11 @@ IFS=$as_save_IFS # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -794,6 +786,7 @@ OS_VERSION_MICRO OS_VERSION_MINOR OS_VERSION_MAJOR PKG_CONFIG +XATTR TIME STAT HG @@ -1451,7 +1444,7 @@ Try \`$0 --help' for more information" $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac @@ -1885,7 +1878,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF OpenJDK configure jdk8 -generated by GNU Autoconf 2.68 +generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation @@ -1931,7 +1924,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1969,7 +1962,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile @@ -2007,7 +2000,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_objc_try_compile @@ -2044,7 +2037,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -2081,7 +2074,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp @@ -2094,10 +2087,10 @@ fi ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : + if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -2164,7 +2157,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -2173,7 +2166,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_header_mongrel @@ -2214,7 +2207,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_run @@ -2228,7 +2221,7 @@ ac_fn_cxx_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2246,7 +2239,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_header_compile @@ -2423,7 +2416,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f conftest.val fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_compute_int @@ -2469,7 +2462,7 @@ fi # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} as_fn_set_status $ac_retval } # ac_fn_cxx_try_link @@ -2482,7 +2475,7 @@ ac_fn_cxx_check_func () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2537,7 +2530,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_cxx_check_func @@ -2550,7 +2543,7 @@ ac_fn_c_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2568,7 +2561,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_header_compile cat >config.log <<_ACEOF @@ -2576,7 +2569,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2834,7 +2827,7 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi done @@ -3756,7 +3749,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1364922883 +DATE_WHEN_GENERATED=1365147397 ############################################################################### # @@ -3794,7 +3787,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BASENAME+:} false; then : +if test "${ac_cv_path_BASENAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BASENAME in @@ -3853,7 +3846,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BASH+:} false; then : +if test "${ac_cv_path_BASH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BASH in @@ -3912,7 +3905,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CAT+:} false; then : +if test "${ac_cv_path_CAT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CAT in @@ -3971,7 +3964,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHMOD+:} false; then : +if test "${ac_cv_path_CHMOD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHMOD in @@ -4030,7 +4023,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CMP+:} false; then : +if test "${ac_cv_path_CMP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CMP in @@ -4089,7 +4082,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_COMM+:} false; then : +if test "${ac_cv_path_COMM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -4148,7 +4141,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CP+:} false; then : +if test "${ac_cv_path_CP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CP in @@ -4207,7 +4200,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CPIO+:} false; then : +if test "${ac_cv_path_CPIO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CPIO in @@ -4266,7 +4259,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CUT+:} false; then : +if test "${ac_cv_path_CUT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CUT in @@ -4325,7 +4318,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DATE+:} false; then : +if test "${ac_cv_path_DATE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DATE in @@ -4384,7 +4377,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DIFF+:} false; then : +if test "${ac_cv_path_DIFF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DIFF in @@ -4443,7 +4436,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DIRNAME+:} false; then : +if test "${ac_cv_path_DIRNAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DIRNAME in @@ -4502,7 +4495,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ECHO+:} false; then : +if test "${ac_cv_path_ECHO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ECHO in @@ -4561,7 +4554,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_EXPR+:} false; then : +if test "${ac_cv_path_EXPR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $EXPR in @@ -4620,7 +4613,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_FILE+:} false; then : +if test "${ac_cv_path_FILE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $FILE in @@ -4679,7 +4672,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_FIND+:} false; then : +if test "${ac_cv_path_FIND+set}" = set; then : $as_echo_n "(cached) " >&6 else case $FIND in @@ -4738,7 +4731,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_HEAD+:} false; then : +if test "${ac_cv_path_HEAD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $HEAD in @@ -4797,7 +4790,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LN+:} false; then : +if test "${ac_cv_path_LN+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LN in @@ -4856,7 +4849,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LS+:} false; then : +if test "${ac_cv_path_LS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LS in @@ -4915,7 +4908,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MKDIR+:} false; then : +if test "${ac_cv_path_MKDIR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MKDIR in @@ -4974,7 +4967,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MKTEMP+:} false; then : +if test "${ac_cv_path_MKTEMP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MKTEMP in @@ -5033,7 +5026,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MV+:} false; then : +if test "${ac_cv_path_MV+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MV in @@ -5092,7 +5085,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PRINTF+:} false; then : +if test "${ac_cv_path_PRINTF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PRINTF in @@ -5151,7 +5144,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_THEPWDCMD+:} false; then : +if test "${ac_cv_path_THEPWDCMD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $THEPWDCMD in @@ -5210,7 +5203,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_RM+:} false; then : +if test "${ac_cv_path_RM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $RM in @@ -5269,7 +5262,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SH+:} false; then : +if test "${ac_cv_path_SH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SH in @@ -5328,7 +5321,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SORT+:} false; then : +if test "${ac_cv_path_SORT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SORT in @@ -5387,7 +5380,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TAIL+:} false; then : +if test "${ac_cv_path_TAIL+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TAIL in @@ -5446,7 +5439,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TAR+:} false; then : +if test "${ac_cv_path_TAR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TAR in @@ -5505,7 +5498,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TEE+:} false; then : +if test "${ac_cv_path_TEE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TEE in @@ -5564,7 +5557,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOUCH+:} false; then : +if test "${ac_cv_path_TOUCH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOUCH in @@ -5623,7 +5616,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TR+:} false; then : +if test "${ac_cv_path_TR+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TR in @@ -5682,7 +5675,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNAME+:} false; then : +if test "${ac_cv_path_UNAME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNAME in @@ -5741,7 +5734,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNIQ+:} false; then : +if test "${ac_cv_path_UNIQ+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNIQ in @@ -5800,7 +5793,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_WC+:} false; then : +if test "${ac_cv_path_WC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $WC in @@ -5859,7 +5852,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_WHICH+:} false; then : +if test "${ac_cv_path_WHICH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $WHICH in @@ -5918,7 +5911,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_XARGS+:} false; then : +if test "${ac_cv_path_XARGS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $XARGS in @@ -5978,7 +5971,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : +if test "${ac_cv_prog_AWK+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -6028,7 +6021,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : +if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -6103,7 +6096,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : +if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -6182,7 +6175,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } -if ${ac_cv_path_FGREP+:} false; then : +if test "${ac_cv_path_FGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 @@ -6261,7 +6254,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : +if test "${ac_cv_path_SED+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ @@ -6347,7 +6340,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_NAWK+:} false; then : +if test "${ac_cv_path_NAWK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $NAWK in @@ -6407,7 +6400,7 @@ RM="$RM -f" set dummy cygpath; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CYGPATH+:} false; then : +if test "${ac_cv_path_CYGPATH+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CYGPATH in @@ -6447,7 +6440,7 @@ fi set dummy readlink; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_READLINK+:} false; then : +if test "${ac_cv_path_READLINK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $READLINK in @@ -6487,7 +6480,7 @@ fi set dummy df; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_DF+:} false; then : +if test "${ac_cv_path_DF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $DF in @@ -6527,7 +6520,7 @@ fi set dummy SetFile; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_SETFILE+:} false; then : +if test "${ac_cv_path_SETFILE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $SETFILE in @@ -6573,7 +6566,7 @@ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : +if test "${ac_cv_build+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias @@ -6589,7 +6582,7 @@ fi $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -6607,7 +6600,7 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : +if test "${ac_cv_host+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then @@ -6622,7 +6615,7 @@ fi $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -6640,7 +6633,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } -if ${ac_cv_target+:} false; then : +if test "${ac_cv_target+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then @@ -6655,7 +6648,7 @@ fi $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; -*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' @@ -8121,7 +8114,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PKGHANDLER+:} false; then : +if test "${ac_cv_prog_PKGHANDLER+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PKGHANDLER"; then @@ -8486,7 +8479,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_GMAKE+:} false; then : +if test "${ac_cv_path_CHECK_GMAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_GMAKE in @@ -8840,7 +8833,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_MAKE+:} false; then : +if test "${ac_cv_path_CHECK_MAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_MAKE in @@ -9199,7 +9192,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_TOOLSDIR_GMAKE+:} false; then : +if test "${ac_cv_path_CHECK_TOOLSDIR_GMAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_GMAKE in @@ -9552,7 +9545,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CHECK_TOOLSDIR_MAKE+:} false; then : +if test "${ac_cv_path_CHECK_TOOLSDIR_MAKE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CHECK_TOOLSDIR_MAKE in @@ -9948,7 +9941,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_UNZIP+:} false; then : +if test "${ac_cv_path_UNZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $UNZIP in @@ -10007,7 +10000,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ZIP+:} false; then : +if test "${ac_cv_path_ZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ZIP in @@ -10066,7 +10059,7 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} set dummy ldd; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LDD+:} false; then : +if test "${ac_cv_path_LDD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LDD in @@ -10112,7 +10105,7 @@ fi set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_OTOOL+:} false; then : +if test "${ac_cv_path_OTOOL+set}" = set; then : $as_echo_n "(cached) " >&6 else case $OTOOL in @@ -10157,7 +10150,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_READELF+:} false; then : +if test "${ac_cv_path_READELF+set}" = set; then : $as_echo_n "(cached) " >&6 else case $READELF in @@ -10200,7 +10193,7 @@ done set dummy hg; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_HG+:} false; then : +if test "${ac_cv_path_HG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $HG in @@ -10240,7 +10233,7 @@ fi set dummy stat; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_STAT+:} false; then : +if test "${ac_cv_path_STAT+set}" = set; then : $as_echo_n "(cached) " >&6 else case $STAT in @@ -10280,7 +10273,7 @@ fi set dummy time; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TIME+:} false; then : +if test "${ac_cv_path_TIME+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TIME in @@ -10325,7 +10318,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_COMM+:} false; then : +if test "${ac_cv_path_COMM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $COMM in @@ -10377,6 +10370,68 @@ $as_echo "$as_me: Could not find $PROG_NAME!" >&6;} fi +fi + +if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then + + for ac_prog in xattr +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_XATTR+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $XATTR in + [\\/]* | ?:[\\/]*) + ac_cv_path_XATTR="$XATTR" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_XATTR="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +XATTR=$ac_cv_path_XATTR +if test -n "$XATTR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XATTR" >&5 +$as_echo "$XATTR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$XATTR" && break +done + + + if test "x$XATTR" = x; then + if test "xxattr" = x; then + PROG_NAME=xattr + else + PROG_NAME=xattr + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find $PROG_NAME!" >&5 +$as_echo "$as_me: Could not find $PROG_NAME!" >&6;} + as_fn_error $? "Cannot continue" "$LINENO" 5 + fi + + fi @@ -10389,7 +10444,7 @@ if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_PKG_CONFIG+:} false; then : +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in @@ -10432,7 +10487,7 @@ if test -z "$ac_cv_path_PKG_CONFIG"; then set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in @@ -10605,7 +10660,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_BDEPS_UNZIP+:} false; then : +if test "${ac_cv_prog_BDEPS_UNZIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_UNZIP"; then @@ -10651,7 +10706,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_BDEPS_FTP+:} false; then : +if test "${ac_cv_prog_BDEPS_FTP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$BDEPS_FTP"; then @@ -11924,7 +11979,7 @@ $as_echo "$BOOT_JDK_VERSION" >&6; } set dummy javac; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_JAVAC_CHECK+:} false; then : +if test "${ac_cv_path_JAVAC_CHECK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $JAVAC_CHECK in @@ -11964,7 +12019,7 @@ fi set dummy java; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_JAVA_CHECK+:} false; then : +if test "${ac_cv_path_JAVA_CHECK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $JAVA_CHECK in @@ -16038,7 +16093,7 @@ if test "x$OPENJDK_TARGET_OS" = "xwindows"; then set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CYGWIN_LINK+:} false; then : +if test "${ac_cv_path_CYGWIN_LINK+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CYGWIN_LINK in @@ -17453,7 +17508,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_CC+:} false; then : +if test "${ac_cv_path_BUILD_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_CC in @@ -17764,7 +17819,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_CXX+:} false; then : +if test "${ac_cv_path_BUILD_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_CXX in @@ -18073,7 +18128,7 @@ $as_echo "$as_me: Rewriting BUILD_CXX to \"$new_complete\"" >&6;} set dummy ld; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_BUILD_LD+:} false; then : +if test "${ac_cv_path_BUILD_LD+set}" = set; then : $as_echo_n "(cached) " >&6 else case $BUILD_LD in @@ -18589,7 +18644,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOOLS_DIR_CC+:} false; then : +if test "${ac_cv_path_TOOLS_DIR_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CC in @@ -18641,7 +18696,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_POTENTIAL_CC+:} false; then : +if test "${ac_cv_path_POTENTIAL_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CC in @@ -19054,7 +19109,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PROPER_COMPILER_CC+:} false; then : +if test "${ac_cv_prog_PROPER_COMPILER_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CC"; then @@ -19098,7 +19153,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CC"; then @@ -19548,7 +19603,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -19592,7 +19647,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -19645,7 +19700,7 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -19760,7 +19815,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -19803,7 +19858,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -19862,7 +19917,7 @@ $as_echo "$ac_try_echo"; } >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi fi fi @@ -19873,7 +19928,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : +if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -19914,7 +19969,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -19924,7 +19979,7 @@ OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -19961,7 +20016,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -20039,7 +20094,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : +if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -20162,7 +20217,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_TOOLS_DIR_CXX+:} false; then : +if test "${ac_cv_path_TOOLS_DIR_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $TOOLS_DIR_CXX in @@ -20214,7 +20269,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_POTENTIAL_CXX+:} false; then : +if test "${ac_cv_path_POTENTIAL_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else case $POTENTIAL_CXX in @@ -20627,7 +20682,7 @@ $as_echo "yes, trying to find proper $COMPILER_NAME compiler" >&6; } set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_PROPER_COMPILER_CXX+:} false; then : +if test "${ac_cv_prog_PROPER_COMPILER_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$PROPER_COMPILER_CXX"; then @@ -20671,7 +20726,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+:} false; then : +if test "${ac_cv_prog_ac_ct_PROPER_COMPILER_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_PROPER_COMPILER_CXX"; then @@ -21125,7 +21180,7 @@ if test -z "$CXX"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CXX+:} false; then : +if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then @@ -21169,7 +21224,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CXX+:} false; then : +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then @@ -21247,7 +21302,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if ${ac_cv_cxx_compiler_gnu+:} false; then : +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21284,7 +21339,7 @@ ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } -if ${ac_cv_prog_cxx_g+:} false; then : +if test "${ac_cv_prog_cxx_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag @@ -21382,7 +21437,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJC+:} false; then : +if test "${ac_cv_prog_OBJC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJC"; then @@ -21426,7 +21481,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJC+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJC"; then @@ -21502,7 +21557,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Objective C compiler" >&5 $as_echo_n "checking whether we are using the GNU Objective C compiler... " >&6; } -if ${ac_cv_objc_compiler_gnu+:} false; then : +if test "${ac_cv_objc_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -21539,7 +21594,7 @@ ac_test_OBJCFLAGS=${OBJCFLAGS+set} ac_save_OBJCFLAGS=$OBJCFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $OBJC accepts -g" >&5 $as_echo_n "checking whether $OBJC accepts -g... " >&6; } -if ${ac_cv_prog_objc_g+:} false; then : +if test "${ac_cv_prog_objc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_objc_werror_flag=$ac_objc_werror_flag @@ -21915,7 +21970,7 @@ if test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : +if test "${ac_cv_prog_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then @@ -21955,7 +22010,7 @@ if test -z "$ac_cv_prog_AR"; then set dummy ar; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then @@ -22297,7 +22352,7 @@ if test "x$OPENJDK_TARGET_OS" = xwindows; then : set dummy link; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_WINLD+:} false; then : +if test "${ac_cv_prog_WINLD+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$WINLD"; then @@ -22636,7 +22691,7 @@ $as_echo "yes" >&6; } set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_MT+:} false; then : +if test "${ac_cv_prog_MT+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$MT"; then @@ -22957,7 +23012,7 @@ $as_echo "$as_me: Rewriting MT to \"$new_complete\"" >&6;} set dummy rc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RC+:} false; then : +if test "${ac_cv_prog_RC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$RC"; then @@ -23348,7 +23403,7 @@ fi set dummy lib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_WINAR+:} false; then : +if test "${ac_cv_prog_WINAR+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$WINAR"; then @@ -23654,7 +23709,7 @@ $as_echo "$as_me: Rewriting WINAR to \"$new_complete\"" >&6;} set dummy dumpbin; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DUMPBIN+:} false; then : +if test "${ac_cv_prog_DUMPBIN+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then @@ -23973,7 +24028,7 @@ if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : + if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -24089,7 +24144,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=cpp @@ -24373,7 +24428,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then - if ${ac_cv_prog_CXXCPP+:} false; then : + if test "${ac_cv_prog_CXXCPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded @@ -24489,7 +24544,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=cpp @@ -24791,7 +24846,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then set dummy as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_AS+:} false; then : +if test "${ac_cv_path_AS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $AS in @@ -25105,7 +25160,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_NM+:} false; then : +if test "${ac_cv_path_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else case $NM in @@ -25414,7 +25469,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_STRIP+:} false; then : +if test "${ac_cv_path_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $STRIP in @@ -25720,7 +25775,7 @@ $as_echo "$as_me: Rewriting STRIP to \"$new_complete\"" >&6;} set dummy mcs; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_MCS+:} false; then : +if test "${ac_cv_path_MCS+set}" = set; then : $as_echo_n "(cached) " >&6 else case $MCS in @@ -26028,7 +26083,7 @@ elif test "x$OPENJDK_TARGET_OS" != xwindows; then set dummy ${ac_tool_prefix}nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_NM+:} false; then : +if test "${ac_cv_prog_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then @@ -26068,7 +26123,7 @@ if test -z "$ac_cv_prog_NM"; then set dummy nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_NM+:} false; then : +if test "${ac_cv_prog_ac_ct_NM+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NM"; then @@ -26386,7 +26441,7 @@ $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : +if test "${ac_cv_prog_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -26426,7 +26481,7 @@ if test -z "$ac_cv_prog_STRIP"; then set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -26751,7 +26806,7 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris || test "x$OPENJDK_TARGET_OS" = xlinux; set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJCOPY+:} false; then : +if test "${ac_cv_prog_OBJCOPY+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJCOPY"; then @@ -26795,7 +26850,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJCOPY+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJCOPY+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJCOPY"; then @@ -27122,7 +27177,7 @@ if test -n "$ac_tool_prefix"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJDUMP+:} false; then : +if test "${ac_cv_prog_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then @@ -27166,7 +27221,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : +if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then @@ -27490,7 +27545,7 @@ if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_LIPO+:} false; then : +if test "${ac_cv_path_LIPO+set}" = set; then : $as_echo_n "(cached) " >&6 else case $LIPO in @@ -27805,7 +27860,7 @@ PATH="$OLD_PATH" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -27981,7 +28036,7 @@ fi for ac_header in stdio.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "stdio.h" "ac_cv_header_stdio_h" "$ac_includes_default" -if test "x$ac_cv_header_stdio_h" = xyes; then : +if test "x$ac_cv_header_stdio_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDIO_H 1 _ACEOF @@ -28010,7 +28065,7 @@ done # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5 $as_echo_n "checking size of int *... " >&6; } -if ${ac_cv_sizeof_int_p+:} false; then : +if test "${ac_cv_sizeof_int_p+set}" = set; then : $as_echo_n "(cached) " >&6 else if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then : @@ -28020,7 +28075,7 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int *) -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else ac_cv_sizeof_int_p=0 fi @@ -28067,7 +28122,7 @@ $as_echo "$OPENJDK_TARGET_CPU_BITS bits" >&6; } # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if ${ac_cv_c_bigendian+:} false; then : +if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown @@ -29079,8 +29134,8 @@ if test "x$with_x" = xno; then have_x=disabled else case $x_includes,$x_libraries in #( - *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5;; #( - *,NONE | NONE,*) if ${ac_cv_have_x+:} false; then : + *\'*) as_fn_error $? "cannot use X directory names containing '" "$LINENO" 5 ;; #( + *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then : $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. @@ -29357,7 +29412,7 @@ if ac_fn_cxx_try_link "$LINENO"; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet... " >&6; } -if ${ac_cv_lib_dnet_dnet_ntoa+:} false; then : +if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29391,14 +29446,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_dnet_ntoa" = xyes; then : +if test "x$ac_cv_lib_dnet_dnet_ntoa" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_ntoa in -ldnet_stub" >&5 $as_echo_n "checking for dnet_ntoa in -ldnet_stub... " >&6; } -if ${ac_cv_lib_dnet_stub_dnet_ntoa+:} false; then : +if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29432,7 +29487,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 $as_echo "$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } -if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = xyes; then : +if test "x$ac_cv_lib_dnet_stub_dnet_ntoa" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi @@ -29451,14 +29506,14 @@ rm -f core conftest.err conftest.$ac_objext \ # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. ac_fn_cxx_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" -if test "x$ac_cv_func_gethostbyname" = xyes; then : +if test "x$ac_cv_func_gethostbyname" = x""yes; then : fi if test $ac_cv_func_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 $as_echo_n "checking for gethostbyname in -lnsl... " >&6; } -if ${ac_cv_lib_nsl_gethostbyname+:} false; then : +if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29492,14 +29547,14 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 $as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } -if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : +if test "x$ac_cv_lib_nsl_gethostbyname" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lbsd" >&5 $as_echo_n "checking for gethostbyname in -lbsd... " >&6; } -if ${ac_cv_lib_bsd_gethostbyname+:} false; then : +if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29533,7 +29588,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_gethostbyname" >&5 $as_echo "$ac_cv_lib_bsd_gethostbyname" >&6; } -if test "x$ac_cv_lib_bsd_gethostbyname" = xyes; then : +if test "x$ac_cv_lib_bsd_gethostbyname" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi @@ -29548,14 +29603,14 @@ fi # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. ac_fn_cxx_check_func "$LINENO" "connect" "ac_cv_func_connect" -if test "x$ac_cv_func_connect" = xyes; then : +if test "x$ac_cv_func_connect" = x""yes; then : fi if test $ac_cv_func_connect = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 $as_echo_n "checking for connect in -lsocket... " >&6; } -if ${ac_cv_lib_socket_connect+:} false; then : +if test "${ac_cv_lib_socket_connect+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29589,7 +29644,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 $as_echo "$ac_cv_lib_socket_connect" >&6; } -if test "x$ac_cv_lib_socket_connect" = xyes; then : +if test "x$ac_cv_lib_socket_connect" = x""yes; then : X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi @@ -29597,14 +29652,14 @@ fi # Guillermo Gomez says -lposix is necessary on A/UX. ac_fn_cxx_check_func "$LINENO" "remove" "ac_cv_func_remove" -if test "x$ac_cv_func_remove" = xyes; then : +if test "x$ac_cv_func_remove" = x""yes; then : fi if test $ac_cv_func_remove = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for remove in -lposix" >&5 $as_echo_n "checking for remove in -lposix... " >&6; } -if ${ac_cv_lib_posix_remove+:} false; then : +if test "${ac_cv_lib_posix_remove+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29638,7 +29693,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix_remove" >&5 $as_echo "$ac_cv_lib_posix_remove" >&6; } -if test "x$ac_cv_lib_posix_remove" = xyes; then : +if test "x$ac_cv_lib_posix_remove" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi @@ -29646,14 +29701,14 @@ fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. ac_fn_cxx_check_func "$LINENO" "shmat" "ac_cv_func_shmat" -if test "x$ac_cv_func_shmat" = xyes; then : +if test "x$ac_cv_func_shmat" = x""yes; then : fi if test $ac_cv_func_shmat = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shmat in -lipc" >&5 $as_echo_n "checking for shmat in -lipc... " >&6; } -if ${ac_cv_lib_ipc_shmat+:} false; then : +if test "${ac_cv_lib_ipc_shmat+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29687,7 +29742,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipc_shmat" >&5 $as_echo "$ac_cv_lib_ipc_shmat" >&6; } -if test "x$ac_cv_lib_ipc_shmat" = xyes; then : +if test "x$ac_cv_lib_ipc_shmat" = x""yes; then : X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi @@ -29705,7 +29760,7 @@ fi # John Interrante, Karl Berry { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IceConnectionNumber in -lICE" >&5 $as_echo_n "checking for IceConnectionNumber in -lICE... " >&6; } -if ${ac_cv_lib_ICE_IceConnectionNumber+:} false; then : +if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -29739,7 +29794,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 $as_echo "$ac_cv_lib_ICE_IceConnectionNumber" >&6; } -if test "x$ac_cv_lib_ICE_IceConnectionNumber" = xyes; then : +if test "x$ac_cv_lib_ICE_IceConnectionNumber" = x""yes; then : X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi @@ -30752,7 +30807,7 @@ $as_echo "$FREETYPE2_FOUND" >&6; } LDFLAGS="$FREETYPE2_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FT_Init_FreeType in -lfreetype" >&5 $as_echo_n "checking for FT_Init_FreeType in -lfreetype... " >&6; } -if ${ac_cv_lib_freetype_FT_Init_FreeType+:} false; then : +if test "${ac_cv_lib_freetype_FT_Init_FreeType+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -30786,7 +30841,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_freetype_FT_Init_FreeType" >&5 $as_echo "$ac_cv_lib_freetype_FT_Init_FreeType" >&6; } -if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = xyes; then : +if test "x$ac_cv_lib_freetype_FT_Init_FreeType" = x""yes; then : FREETYPE2_FOUND=true else as_fn_error $? "Could not find freetype2! $HELP_MSG " "$LINENO" 5 @@ -31074,7 +31129,7 @@ fi for ac_header in alsa/asoundlib.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "alsa/asoundlib.h" "ac_cv_header_alsa_asoundlib_h" "$ac_includes_default" -if test "x$ac_cv_header_alsa_asoundlib_h" = xyes; then : +if test "x$ac_cv_header_alsa_asoundlib_h" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ALSA_ASOUNDLIB_H 1 _ACEOF @@ -31133,7 +31188,7 @@ fi USE_EXTERNAL_LIBJPEG=true { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ljpeg" >&5 $as_echo_n "checking for main in -ljpeg... " >&6; } -if ${ac_cv_lib_jpeg_main+:} false; then : +if test "${ac_cv_lib_jpeg_main+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31161,7 +31216,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_main" >&5 $as_echo "$ac_cv_lib_jpeg_main" >&6; } -if test "x$ac_cv_lib_jpeg_main" = xyes; then : +if test "x$ac_cv_lib_jpeg_main" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBJPEG 1 _ACEOF @@ -31210,7 +31265,7 @@ if test "x${with_giflib}" = "xbundled"; then USE_EXTERNAL_LIBGIF=false elif test "x${with_giflib}" = "xsystem"; then ac_fn_cxx_check_header_mongrel "$LINENO" "gif_lib.h" "ac_cv_header_gif_lib_h" "$ac_includes_default" -if test "x$ac_cv_header_gif_lib_h" = xyes; then : +if test "x$ac_cv_header_gif_lib_h" = x""yes; then : else as_fn_error $? "--with-giflib=system specified, but gif_lib.h not found!" "$LINENO" 5 @@ -31219,7 +31274,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DGifGetCode in -lgif" >&5 $as_echo_n "checking for DGifGetCode in -lgif... " >&6; } -if ${ac_cv_lib_gif_DGifGetCode+:} false; then : +if test "${ac_cv_lib_gif_DGifGetCode+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31253,7 +31308,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gif_DGifGetCode" >&5 $as_echo "$ac_cv_lib_gif_DGifGetCode" >&6; } -if test "x$ac_cv_lib_gif_DGifGetCode" = xyes; then : +if test "x$ac_cv_lib_gif_DGifGetCode" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBGIF 1 _ACEOF @@ -31285,7 +31340,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compress in -lz" >&5 $as_echo_n "checking for compress in -lz... " >&6; } -if ${ac_cv_lib_z_compress+:} false; then : +if test "${ac_cv_lib_z_compress+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31319,7 +31374,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_compress" >&5 $as_echo "$ac_cv_lib_z_compress" >&6; } -if test "x$ac_cv_lib_z_compress" = xyes; then : +if test "x$ac_cv_lib_z_compress" = x""yes; then : ZLIB_FOUND=yes else ZLIB_FOUND=no @@ -31412,7 +31467,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 $as_echo_n "checking for cos in -lm... " >&6; } -if ${ac_cv_lib_m_cos+:} false; then : +if test "${ac_cv_lib_m_cos+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31446,7 +31501,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 $as_echo "$ac_cv_lib_m_cos" >&6; } -if test "x$ac_cv_lib_m_cos" = xyes; then : +if test "x$ac_cv_lib_m_cos" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -31470,7 +31525,7 @@ save_LIBS="$LIBS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : +if test "${ac_cv_lib_dl_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -31504,7 +31559,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : +if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBDL 1 _ACEOF @@ -32194,7 +32249,7 @@ fi set dummy ccache; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CCACHE+:} false; then : +if test "${ac_cv_path_CCACHE+set}" = set; then : $as_echo_n "(cached) " >&6 else case $CCACHE in @@ -32455,21 +32510,10 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then + test "x$cache_file" != "x/dev/null" && { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi + cat confcache >$cache_file else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -32501,7 +32545,7 @@ LTLIBOBJS=$ac_ltlibobjs -: "${CONFIG_STATUS=./config.status}" +: ${CONFIG_STATUS=./config.status} ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -32602,7 +32646,6 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -32910,7 +32953,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by OpenJDK $as_me jdk8, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -32973,7 +33016,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ OpenJDK config.status jdk8 -configured by $0, generated by GNU Autoconf 2.68, +configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. @@ -33102,7 +33145,7 @@ do "$OUTPUT_ROOT/spec.sh") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in" ;; "$OUTPUT_ROOT/Makefile") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/Makefile:$AUTOCONF_DIR/Makefile.in" ;; - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done @@ -33124,10 +33167,9 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= ac_tmp= + tmp= trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -33135,13 +33177,12 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" + test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -33163,7 +33204,7 @@ else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +echo 'BEGIN {' >"$tmp/subs1.awk" && _ACEOF @@ -33191,7 +33232,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -33239,7 +33280,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && +cat >>"\$tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -33271,7 +33312,7 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ +fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF @@ -33305,7 +33346,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || +cat >"$tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -33317,8 +33358,8 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then + ac_t=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_t"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 @@ -33419,7 +33460,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -33438,7 +33479,7 @@ do for ac_f do case $ac_f in - -) ac_f="$ac_tmp/stdin";; + -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -33447,7 +33488,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -33473,8 +33514,8 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -33599,22 +33640,21 @@ s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$ac_tmp/stdin" + rm -f "$tmp/stdin" case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + -) cat "$tmp/out" && rm -f "$tmp/out";; + *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; @@ -33625,20 +33665,20 @@ which seems to be undefined. Please make sure it is defined" >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" + } >"$tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ + mv "$tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 4e5b7b48ca1..11d19a342d7 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -523,6 +523,7 @@ FILE:=@FILE@ HG:=@HG@ OBJCOPY:=@OBJCOPY@ SETFILE:=@SETFILE@ +XATTR:=@XATTR@ FIXPATH:=@FIXPATH@ diff --git a/common/makefiles/MakeBase.gmk b/common/makefiles/MakeBase.gmk index 708cbada085..5a54e38a0ea 100644 --- a/common/makefiles/MakeBase.gmk +++ b/common/makefiles/MakeBase.gmk @@ -374,15 +374,24 @@ endef ifeq ($(OPENJDK_TARGET_OS),solaris) # On Solaris, if the target is a symlink and exists, cp won't overwrite. +# Cp has to operate in recursive mode to allow for -P flag, to preserve soft links. If the +# name of the target file differs from the source file, rename after copy. define install-file $(MKDIR) -p $(@D) $(RM) '$@' $(CP) -f -r -P '$<' '$(@D)' + if [ "$(@F)" != "$( Date: Fri, 5 Apr 2013 09:39:10 +0200 Subject: [PATCH 42/52] 8008373: JFR JTReg tests fail with CompilationError on MacOSX; missing '._sunec.jar' Reviewed-by: tbell --- jdk/makefiles/CompileDemos.gmk | 67 +++++------- jdk/makefiles/CompileJavaClasses.gmk | 3 +- jdk/makefiles/CompileLaunchers.gmk | 6 +- jdk/makefiles/CompileNativeLibraries.gmk | 10 +- jdk/makefiles/CopyFiles.gmk | 132 ++++++----------------- jdk/makefiles/CopyIntoClasses.gmk | 4 +- jdk/makefiles/CopySamples.gmk | 12 +-- jdk/makefiles/GendataFontConfig.gmk | 4 +- jdk/makefiles/GensrcCharacterData.gmk | 3 +- jdk/makefiles/GensrcMisc.gmk | 11 +- jdk/makefiles/GensrcSwing.gmk | 6 +- jdk/makefiles/SignJars.gmk | 3 +- jdk/makefiles/Tools.gmk | 10 +- 13 files changed, 84 insertions(+), 187 deletions(-) diff --git a/jdk/makefiles/CompileDemos.gmk b/jdk/makefiles/CompileDemos.gmk index f3100b10ab3..f61d9404020 100644 --- a/jdk/makefiles/CompileDemos.gmk +++ b/jdk/makefiles/CompileDemos.gmk @@ -136,8 +136,7 @@ define SetupDemo $$(wildcard $$(addprefix $(JDK_TOPDIR)/src/$6share/demo/$2/$1/,$7))) ifneq ($7,) $(JDK_OUTPUTDIR)/demo/$2/$1/% : $(JDK_TOPDIR)/src/$6share/demo/$2/$1/% - $(MKDIR) -p $$(@D) - $(CP) $$< $$@ + $$(call install-file) $(CHMOD) -f ug+w $$@ BUILD_DEMOS += $$($1_COPY_TARGETS) @@ -190,8 +189,7 @@ ifndef OPENJDK $(JDK_OUTPUTDIR)/demo/nbproject/%,\ $(call CacheFind,$(JDK_TOPDIR)/src/closed/share/demo/nbproject)) $(JDK_OUTPUTDIR)/demo/nbproject/% : $(JDK_TOPDIR)/src/closed/share/demo/nbproject/% - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) $(CHMOD) -f ug+w $@ endif @@ -268,8 +266,7 @@ define SetupJVMTIDemo ZIP:=$(JDK_OUTPUTDIR)/demo/jvmti/$1/src.zip)) $(JDK_OUTPUTDIR)/demo/jvmti/$1/README.txt : $(JDK_TOPDIR)/src/share/demo/jvmti/$1/README.txt - $(MKDIR) -p $$(@D) - $(CP) $$< $$@ + $$(call install-file) $(CHMOD) -f ug+w $$@ ifneq (,$$(wildcard $(JDK_TOPDIR)/src/share/demo/jvmti/$1/*.java)) @@ -325,23 +322,22 @@ JPDA_SOURCES:=$(call CacheFind,$(JDK_TOPDIR)/src/share/classes/com/sun/tools/exa JPDA_FILES:=$(subst $(JDK_TOPDIR)/src/share/classes/,,$(JPDA_SOURCES)) $(JDK_OUTPUTDIR)/demo/jpda/src.zip : $(JPDA_SOURCES) - $(MKDIR) -p $(@D) - (cd $(JDK_TOPDIR)/src/share/classes && $(ZIP) -qru $@ com -i "com/sun/tools/example/*") + $(MKDIR) -p $(@D) + (cd $(JDK_TOPDIR)/src/share/classes && $(ZIP) -qru $@ com -i "com/sun/tools/example/*") $(JDK_OUTPUTDIR)/demo/jpda/examples.jar : $(JPDA_SOURCES) - $(MKDIR) -p $(@D) - $(RM) $(@D)/_the.sources - $(call ListPathsSafely,JPDA_FILES,\n, >> $(@D)/_the.sources) - $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \ - -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" $(JDK_TOPDIR)/make/tools/manifest.mf > $(@D)/_the.manifest - $(ECHO) "Main-Class: " >> $(@D)/_the.manifest - (cd $(JDK_TOPDIR)/src/share/classes && $(JAR) cfm $@ $(@D)/_the.manifest @$(@D)/_the.sources) - (cd $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example && $(JAR) uf $@ README) + $(MKDIR) -p $(@D) + $(RM) $(@D)/_the.sources + $(call ListPathsSafely,JPDA_FILES,\n, >> $(@D)/_the.sources) + $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \ + -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" $(JDK_TOPDIR)/make/tools/manifest.mf > $(@D)/_the.manifest + $(ECHO) "Main-Class: " >> $(@D)/_the.manifest + (cd $(JDK_TOPDIR)/src/share/classes && $(JAR) cfm $@ $(@D)/_the.manifest @$(@D)/_the.sources) + (cd $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example && $(JAR) uf $@ README) $(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README : $(JDK_TOPDIR)/src/share/classes/com/sun/tools/example/README - $(MKDIR) -p $(@D) - $(CP) $< $@ - $(CHMOD) -f ug+w $@ + $(call install-file) + $(CHMOD) -f ug+w $@ BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jpda/src.zip $(JDK_OUTPUTDIR)/demo/jpda/examples.jar \ $(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README @@ -349,14 +345,12 @@ BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jpda/src.zip $(JDK_OUTPUTDIR)/demo/jpda/exa ################################################################################################## $(JDK_OUTPUTDIR)/demo/management/index.html : $(JDK_TOPDIR)/src/share/demo/management/index.html - $(MKDIR) -p $(@D) - $(CP) $< $@ - $(CHMOD) -f ug+w $@ + $(call install-file) + $(CHMOD) -f ug+w $@ $(JDK_OUTPUTDIR)/demo/jvmti/index.html : $(JDK_TOPDIR)/src/share/demo/jvmti/index.html - $(MKDIR) -p $(@D) - $(CP) $< $@ - $(CHMOD) -f ug+w $@ + $(call install-file) + $(CHMOD) -f ug+w $@ BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/management/index.html \ $(JDK_OUTPUTDIR)/demo/jvmti/index.html @@ -369,15 +363,13 @@ BUILD_DEMOS += $(patsubst $(JDK_TOPDIR)/src/share/demo/nbproject/%,\ $(call CacheFind,$(JDK_TOPDIR)/src/share/demo/nbproject)) $(JDK_OUTPUTDIR)/demo/nbproject/% : $(JDK_TOPDIR)/src/share/demo/nbproject/% - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) $(CHMOD) -f ug+w $@ ################################################################################################## $(JDK_OUTPUTDIR)/demo/README: $(JDK_TOPDIR)/src/share/demo/README - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/README @@ -386,14 +378,12 @@ BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/README ifeq ($(OPENJDK_TARGET_OS), solaris) $(JDK_OUTPUTDIR)/democlasses/jni/Poller/% : $(JDK_TOPDIR)/src/solaris/demo/jni/Poller/% - $(MKDIR) -p $(@D) - $(CP) $< $@ - $(CHMOD) -f ug+w $@ + $(call install-file) + $(CHMOD) -f ug+w $@ $(JDK_OUTPUTDIR)/demo/jni/Poller/README.txt : $(JDK_TOPDIR)/src/solaris/demo/jni/Poller/README.txt - $(MKDIR) -p $(@D) - $(CP) $< $@ - $(CHMOD) -f ug+w $@ + $(call install-file) + $(CHMOD) -f ug+w $@ $(JDK_OUTPUTDIR)/demo/jni/Poller/Poller.jar : \ $(JDK_OUTPUTDIR)/democlasses/jni/Poller/README.txt $(JDK_OUTPUTDIR)/democlasses/jni/Poller/Poller.c @@ -433,8 +423,7 @@ $(JDK_OUTPUTDIR)/demoobjs/jni/Poller/Poller.o : $(JDK_OUTPUTDIR)/demo/jni/Poller $(JDK_OUTPUTDIR)/demo/jni/Poller/lib/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX) : \ $(JDK_OUTPUTDIR)/demoobjs/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX) - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/jni/Poller/lib/$(LIBRARY_PREFIX)Poller$(SHARED_LIBRARY_SUFFIX) @@ -456,8 +445,8 @@ ifndef OPENJDK $(JDK_OUTPUTDIR)/demo/db/README-JDK-DEMOS.html: \ $(JDK_TOPDIR)/src/closed/share/db/README-JDK-DEMOS.html \ | $(JDK_OUTPUTDIR)/demo/_the.db.unzipped - $(MKDIR) -p $(@D) - $(CP) '$<' '$@' + $(call install-file) + BUILD_DEMOS += $(JDK_OUTPUTDIR)/demo/_the.db.unzipped $(JDK_OUTPUTDIR)/demo/db/README-JDK-DEMOS.html endif diff --git a/jdk/makefiles/CompileJavaClasses.gmk b/jdk/makefiles/CompileJavaClasses.gmk index 584458c00c4..24ce0d922f0 100644 --- a/jdk/makefiles/CompileJavaClasses.gmk +++ b/jdk/makefiles/CompileJavaClasses.gmk @@ -281,8 +281,7 @@ endif # These resources violates the convention of having code and resources together under # $(JDK_TOPDIR)/src/.../classes directories $(JDK_OUTPUTDIR)/classes/javax/swing/beaninfo/images/%.gif: $(JDK_TOPDIR)/make/tools/swing-beans/beaninfo/images/%.gif - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) # The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying # JDK_FILTER at the make command line, only a subset of the JDK java files will diff --git a/jdk/makefiles/CompileLaunchers.gmk b/jdk/makefiles/CompileLaunchers.gmk index 501c986082e..7ecad956fbb 100644 --- a/jdk/makefiles/CompileLaunchers.gmk +++ b/jdk/makefiles/CompileLaunchers.gmk @@ -489,8 +489,7 @@ endif # -link -incremental:no # like all other launchers. $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/unpack200$(EXE_SUFFIX): $(BUILD_UNPACKEXE) - $(MKDIR) -p $(@D) - $(CP) '$<' '$@' + $(call install-file) BUILD_LAUNCHERS += $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/unpack200$(EXE_SUFFIX) @@ -588,8 +587,7 @@ ifeq ($(OPENJDK_TARGET_OS),windows) $(call SET_SHARED_LIBRARY_MAPFILE,$(JDK_TOPDIR)/makefiles/java/main/java/mapfile-$(OPENJDK_TARGET_CPU)))) else $(JAVA_RMI_CGI): $(JDK_TOPDIR)/src/solaris/bin/java-rmi.cgi.sh - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) $(CHMOD) a+x $@ endif diff --git a/jdk/makefiles/CompileNativeLibraries.gmk b/jdk/makefiles/CompileNativeLibraries.gmk index e73c91f3adb..0158000c130 100644 --- a/jdk/makefiles/CompileNativeLibraries.gmk +++ b/jdk/makefiles/CompileNativeLibraries.gmk @@ -109,7 +109,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFDLIBM_MAC,\ BUILD_LIBFDLIBM := $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) $(BUILD_LIBFDLIBM) : $(BUILD_LIBFDLIBM_MAC) - $(CP) -a $< $@ + $(call install-file) endif BUILD_LIBRARIES += $(BUILD_LIBFDLIBM) @@ -1838,16 +1838,14 @@ BUILD_LIBRARIES += $(BUILD_LIBNET) $(JDK_OUTPUTDIR)/lib/net.properties: $(JDK_TOPDIR)/src/share/lib/net.properties $(ECHO) $(LOG_INFO) Copying $(@F) - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) COPY_FILES += $(JDK_OUTPUTDIR)/lib/net.properties ifeq ($(OPENJDK_TARGET_OS), solaris) $(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template : $(JDK_TOPDIR)/src/${OPENJDK_TARGET_OS_API_DIR}/lib/sdp/sdp.conf.template $(ECHO) $(LOG_INFO) Copying $(@F) - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) COPY_FILES += $(JDK_OUTPUTDIR)/lib/sdp/sdp.conf.template endif @@ -2168,7 +2166,7 @@ else ifeq ($(OPENJDK_TARGET_OS),macosx) OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static)) $(JDK_OUTPUTDIR)/objs/libjli_static.a : $(BUILD_LIBJLI_STATIC) - $(CP) -a $< $@ + $(call install-file) BUILD_LIBRARIES += $(JDK_OUTPUTDIR)/objs/libjli_static.a endif diff --git a/jdk/makefiles/CopyFiles.gmk b/jdk/makefiles/CopyFiles.gmk index 0b4bbfd68ce..6b15e677b32 100644 --- a/jdk/makefiles/CopyFiles.gmk +++ b/jdk/makefiles/CopyFiles.gmk @@ -46,14 +46,10 @@ H_TARGET_FILES =$(INCLUDEDIR)/jdwpTransport.h \ $(OPENJDK_TARGET_OS_INCLUDE)/jawt_md.h $(INCLUDEDIR)/%.h: $(JDK_TOPDIR)/src/share/javavm/export/%.h - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(OPENJDK_TARGET_OS_INCLUDE)/%.h: $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export/%.h - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES = $(H_TARGET_FILES) @@ -88,22 +84,16 @@ MGMT_SRC_FILES = $(wildcard $(MGMT_LIB_SRC)/*) MGMT_TARGET_FILES = $(subst $(MGMT_LIB_SRC),$(MGMT_LIBDIR),$(MGMT_SRC_FILES)) $(MGMT_LIBDIR)/management.properties: $(MGMT_LIB_SRC)/management.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 644 $@ # this file has different permissions...don't know why... $(MGMT_LIBDIR)/jmxremote.access: $(MGMT_LIB_SRC)/jmxremote.access - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 644 $@ $(MGMT_LIBDIR)/%: $(MGMT_LIB_SRC)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 444 $@ COPY_FILES += $(MGMT_TARGET_FILES) @@ -113,9 +103,7 @@ COPY_FILES += $(MGMT_TARGET_FILES) LOGGING_LIB_SRC = $(JDK_TOPDIR)/src/share/lib $(LIBDIR)/logging.properties: $(LOGGING_LIB_SRC)/logging.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/logging.properties @@ -128,9 +116,7 @@ PSFONTPROPFILE_SRCS = $(wildcard $(PSFONTPROPFILE_SRC_DIR)/*.properties*) PSFONTPROPFILE_TARGET_FILES = $(subst $(PSFONTPROPFILE_SRC_DIR),$(LIBDIR),$(PSFONTPROPFILE_SRCS)) $(LIBDIR)/%: $(PSFONTPROPFILE_SRC_DIR)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(PSFONTPROPFILE_TARGET_FILES) @@ -145,9 +131,7 @@ OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/macosx/lib endif $(LIBDIR)/flavormap.properties: $(OPENJDK_TARGET_OS_LIB_SRC)/flavormap.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/flavormap.properties @@ -155,9 +139,7 @@ CURSORS_DEST_DIR = $(LIBDIR)/images/cursors CURSORS_OPENJDK_TARGET_OS_LIB_SRC = $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib/images/cursors $(CURSORS_DEST_DIR)/cursors.properties: $(CURSORS_OPENJDK_TARGET_OS_LIB_SRC)/cursors.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(CURSORS_DEST_DIR)/cursors.properties @@ -170,9 +152,7 @@ endif # OPENJDK_TARGET_OS CURSORS_TARGET_FILES = $(subst $(CURSORS_LIB_SRC),$(CURSORS_DEST_DIR),$(CURSORS_SRC_FILES)) $(CURSORS_DEST_DIR)/%: $(CURSORS_LIB_SRC)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(CURSORS_TARGET_FILES) @@ -181,9 +161,7 @@ COPY_FILES += $(CURSORS_TARGET_FILES) CONTENT_TYPES_SRC=$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib $(LIBDIR)/content-types.properties: $(CONTENT_TYPES_SRC)/content-types.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/content-types.properties @@ -192,9 +170,7 @@ COPY_FILES += $(LIBDIR)/content-types.properties CALENDARS_SRC := $(JDK_TOPDIR)/src/share/lib $(LIBDIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/calendars.properties @@ -205,9 +181,7 @@ ifeq ($(OPENJDK_TARGET_OS),windows) TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib $(LIBDIR)/tzmappings: $(TZMAPPINGS_SRC)/tzmappings - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/tzmappings @@ -227,9 +201,7 @@ ICCPROFILE_SRCS:=$(wildcard $(ICCPROFILE_SRC_DIR)/*.pf) ICCPROFILE_TARGET_FILES:=$(subst $(ICCPROFILE_SRC_DIR),$(ICCPROFILE_DEST_DIR),$(ICCPROFILE_SRCS)) $(ICCPROFILE_DEST_DIR)%.pf: $(ICCPROFILE_SRC_DIR)%.pf - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 444 $@ COPY_FILES += $(ICCPROFILE_TARGET_FILES) @@ -279,9 +251,7 @@ ifeq ($(OPENJDK_TARGET_OS),windows) MSVCR_TARGET := $(JDK_OUTPUTDIR)/bin/$(notdir $(MSVCR_DLL)) # Chmod to avoid permission issues if bundles are unpacked on unix platforms. $(MSVCR_TARGET): $(MSVCR_DLL) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) a+rx $@ COPY_FILES += $(MSVCR_TARGET) @@ -292,9 +262,7 @@ endif HPROF_SRC=$(JDK_TOPDIR)/src/share/demo/jvmti/hprof/jvm.hprof.txt $(LIBDIR)/jvm.hprof.txt : $(HPROF_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(LIBDIR)/jvm.hprof.txt @@ -351,17 +319,13 @@ ifeq ($(OPENJDK_TARGET_CPU_BITS),32) else # Use the default jvm.cfg for this 32 bit setup. $(JVMCFG): $(JVMCFG_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) endif endif else # Use the default jvm.cfg for this 64 bit setup. $(JVMCFG): $(JVMCFG_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) endif COPY_FILES += $(JVMCFG) @@ -372,9 +336,7 @@ PROPS_SRC := $(JDK_TOPDIR)/src/share/lib/security/java.security-$(OPENJDK_TARGET PROPS_DST := $(JDK_OUTPUTDIR)/lib/security/java.security $(PROPS_DST): $(PROPS_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(PROPS_DST) @@ -384,9 +346,7 @@ POLICY_SRC := $(JDK_TOPDIR)/src/share/lib/security/java.policy POLICY_DST := $(JDK_OUTPUTDIR)/lib/security/java.policy $(POLICY_DST): $(POLICY_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(POLICY_DST) @@ -396,9 +356,7 @@ CACERTS_SRC := $(CACERTS_FILE) CACERTS_DST := $(JDK_OUTPUTDIR)/lib/security/cacerts $(CACERTS_DST): $(CACERTS_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(CACERTS_DST) @@ -413,16 +371,12 @@ TRUSTEDLIBS_SRC := $(JDK_TOPDIR)/src/closed/share/lib/security/trusted.libraries TRUSTEDLIBS_DST := $(JDK_OUTPUTDIR)/lib/security/trusted.libraries $(BLACKLIST_DST): $(BLACKLIST_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(BLACKLIST_DST) $(TRUSTEDLIBS_DST): $(TRUSTEDLIBS_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(TRUSTEDLIBS_DST) @@ -448,14 +402,10 @@ SHARED_FONTS_SRC := $(foreach F,$(SHARED_FONTS_FILES),$(SHARED_FONTS_SRC_DIR)/$( SHARED_FONTS_DST := $(foreach F,$(SHARED_FONTS_FILES),$(SHARED_FONTS_DST_DIR)/$(F)) $(SHARED_FONTS_DST_DIR)/%.ttf : $(SHARED_FONTS_SRC_DIR)/%.ttf - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(SHARED_FONTS_DST_DIR)/fonts.dir : $(JDK_TOPDIR)/src/solaris/classes/sun/awt/motif/java.fonts.dir - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(SHARED_FONTS_DST) @@ -476,14 +426,10 @@ OBL_FONTS_SRC := $(foreach F,$(OBL_FONTS_FILES),$(OBL_FONTS_SRC_DIR)/$(F)) OBL_FONTS_DST := $(foreach F,$(OBL_FONTS_FILES),$(OBL_FONTS_DST_DIR)/$(F)) $(OBL_FONTS_DST_DIR)/%.ttf : $(OBL_FONTS_SRC_DIR)/%.ttf - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(OBL_FONTS_DST_DIR)/fonts.dir : $(JDK_TOPDIR)/src/solaris/classes/sun/awt/motif/java.oblique-fonts.dir - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(OBL_FONTS_DST) $(OBL_FONTS_DST_DIR)/fonts.dir @@ -502,9 +448,7 @@ JS_RESOURCES_SRC := $(foreach F,$(JS_RESOURCES_FILES),$(JS_RESOURCES_SRC_DIR)/$( JS_RESOURCES_DST := $(foreach F,$(JS_RESOURCES_FILES),$(JS_RESOURCES_DST_DIR)/$(F)) $(JS_RESOURCES_DST_DIR)/% : $(JS_RESOURCES_SRC_DIR)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(JS_RESOURCES_DST) @@ -539,15 +483,11 @@ _DGALIBS_amd64 = # no amd64 library yet DGALIBS = $(_DGALIBS_$(OPENJDK_TARGET_CPU_LEGACY):%=$(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/%) $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libxinerama.so: $(JDK_TOPDIR)/src/closed/solaris/lib/$(OPENJDK_TARGET_CPU_LEGACY)/libxinerama.so - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 755 $@ $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNW%.so: $(JDK_TOPDIR)/src/closed/solaris/lib/$(OPENJDK_TARGET_CPU_LEGACY)/libjdgaSUNW%.so - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(CHMOD) 755 $@ $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNWafb.so: $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjdgaSUNWffb.so @@ -567,9 +507,7 @@ SUNPKCS11_CFG_SRC := $(JDK_TOPDIR)/src/share/lib/security/sunpkcs11-solaris.cfg SUNPKCS11_CFG_DST := $(JDK_OUTPUTDIR)/lib/security/sunpkcs11-solaris.cfg $(SUNPKCS11_CFG_DST) : $(SUNPKCS11_CFG_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(SUNPKCS11_CFG_DST) @@ -584,9 +522,7 @@ UCRYPTO_CFG_SRC := $(JDK_TOPDIR)/src/closed/share/lib/security/ucrypto-solaris.c UCRYPTO_CFG_DST := $(JDK_OUTPUTDIR)/lib/security/ucrypto-solaris.cfg $(UCRYPTO_CFG_DST) : $(UCRYPTO_CFG_SRC) - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(UCRYPTO_CFG_DST) @@ -596,9 +532,7 @@ endif ########################################################################################## $(JDK_OUTPUTDIR)/lib/sound.properties : $(JDK_TOPDIR)/src/share/lib/sound.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $(@) + $(call install-file) COPY_FILES += $(JDK_OUTPUTDIR)/lib/sound.properties diff --git a/jdk/makefiles/CopyIntoClasses.gmk b/jdk/makefiles/CopyIntoClasses.gmk index 549a58efd68..d4df3424b6e 100644 --- a/jdk/makefiles/CopyIntoClasses.gmk +++ b/jdk/makefiles/CopyIntoClasses.gmk @@ -223,9 +223,7 @@ COPY_EXTRA += $(OUT_SERVICES_FILES_PRINT) ### $(JDK_OUTPUTDIR)/classes/sun/nio/cs/ext/sjis0213.dat : $(JDK_OUTPUTDIR)/gensrc/sun/nio/cs/ext/sjis0213.dat - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $(@) + $(call install-file) COPY_EXTRA += $(JDK_OUTPUTDIR)/classes/sun/nio/cs/ext/sjis0213.dat diff --git a/jdk/makefiles/CopySamples.gmk b/jdk/makefiles/CopySamples.gmk index 7f432f8693b..1f6b3bfb893 100644 --- a/jdk/makefiles/CopySamples.gmk +++ b/jdk/makefiles/CopySamples.gmk @@ -53,19 +53,13 @@ ifneq (, $(filter $(OPENJDK_TARGET_OS), solaris macosx)) endif $(SAMPLE_TARGET_DIR)/dtrace/%: $(SAMPLE_SOLARIS_SOURCE_DIR)/dtrace/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(SAMPLE_TARGET_DIR)/webservices/%: $(SAMPLE_CLOSED_SOURCE_DIR)/webservices/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) $(SAMPLE_TARGET_DIR)/%: $(SAMPLE_SOURCE_DIR)/% - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) COPY_FILES += $(SAMPLE_TARGET) diff --git a/jdk/makefiles/GendataFontConfig.gmk b/jdk/makefiles/GendataFontConfig.gmk index 7f539083c9d..189a7327a1d 100644 --- a/jdk/makefiles/GendataFontConfig.gmk +++ b/jdk/makefiles/GendataFontConfig.gmk @@ -72,9 +72,7 @@ endif $(GENDATA_FONT_CONFIG_DST)/%.src : \ $(GENDATA_FONT_CONFIG_SRC_DIR)/$(GENDATA_FONT_CONFIG_SRC_PREFIX)% - $(RM) $@ - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) $(GENDATA_FONT_CONFIG_DST)/%.bfc : \ $(GENDATA_FONT_CONFIG_SRC_DIR)/$(GENDATA_FONT_CONFIG_SRC_PREFIX)%.properties diff --git a/jdk/makefiles/GensrcCharacterData.gmk b/jdk/makefiles/GensrcCharacterData.gmk index e720ab860ed..f64edbab85c 100644 --- a/jdk/makefiles/GensrcCharacterData.gmk +++ b/jdk/makefiles/GensrcCharacterData.gmk @@ -55,9 +55,8 @@ $(eval $(call SetupCharacterData,CharacterData0E,-plane 14,11 4 1)) # Copy two Java files that need no preprocessing. $(JDK_OUTPUTDIR)/gensrc/java/lang/%.java : $(CHARACTERDATA)/%.java.template - $(MKDIR) -p $(@D) $(ECHO) $(LOG_INFO) Generating $(@F) - $(CP) -f $< $@ + $(call install-file) GENSRC_CHARACTERDATA += $(JDK_OUTPUTDIR)/gensrc/java/lang/CharacterDataUndefined.java \ $(JDK_OUTPUTDIR)/gensrc/java/lang/CharacterDataPrivateUse.java diff --git a/jdk/makefiles/GensrcMisc.gmk b/jdk/makefiles/GensrcMisc.gmk index 72a789b452c..812b2cee6c7 100644 --- a/jdk/makefiles/GensrcMisc.gmk +++ b/jdk/makefiles/GensrcMisc.gmk @@ -72,9 +72,8 @@ ifeq ($(OPENJDK_TARGET_OS_API),posix) $(JDK_OUTPUTDIR)/gensrc/java/lang/UNIXProcess.java : \ $(JDK_TOPDIR)/src/solaris/classes/java/lang/UNIXProcess.java.$(UPSUFFIX) - $(MKDIR) -p $(@D) $(ECHO) $(LOG_INFO) Copying UNIXProcess.java.$(OPENJDK_TARGET_OS) to java/lang/UNIXProcess.java - $(CP) $< $@ + $(call install-file) $(CHMOD) u+rw $@ GENSRC_MISC += $(JDK_OUTPUTDIR)/gensrc/java/lang/UNIXProcess.java @@ -114,9 +113,7 @@ $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java : $(BUILD_GENSRC_SO $(MV) $@.tmp $@ else $(JDK_OUTPUTDIR)/gensrc/sun/nio/ch/SocketOptionRegistry.java : $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/ch/SocketOptionRegistry-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) endif ########################################################################################## @@ -156,9 +153,7 @@ $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java : $(BUILD_GENSRC_UC_EXE) $(MV) $@.tmp $@ else $(JDK_OUTPUTDIR)/gensrc/sun/nio/fs/UnixConstants.java : $(JDK_TOPDIR)/src/closed/solaris/classes/sun/nio/fs/UnixConstants-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH).java - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + $(call install-file) endif endif diff --git a/jdk/makefiles/GensrcSwing.gmk b/jdk/makefiles/GensrcSwing.gmk index 9f3bff1ba41..f5741ae5f46 100644 --- a/jdk/makefiles/GensrcSwing.gmk +++ b/jdk/makefiles/GensrcSwing.gmk @@ -85,14 +85,12 @@ $(JDK_OUTPUTDIR)/gensrc_no_srczip/_the.generated_beaninfo: $(BEANS_SRC) $(JDK_OU # For some reason it is under $(JDK_TOPDIR)/make/tools/swing-beans/javax/swing # Should it be moved under $(JDK_TOPDIR)/src/share/classes/javax/swing instead? $(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing/SwingBeanInfoBase.java: $(DOCLETSRC_DIR)/javax/swing/SwingBeanInfoBase.java - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) # This file is the part of dt.jar # For some reason it is under $(JDK_TOPDIR)/make/tools/swing-beans/sun/swing # Should it be moved under $(JDK_TOPDIR)/src/share/classes/sun/swing instead? $(JDK_OUTPUTDIR)/gensrc/sun/swing/BeanInfoUtils.java: $(DOCLETSRC_DIR)/sun/swing/BeanInfoUtils.java - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) GENSRC_SWING_BEANINFO = $(JDK_OUTPUTDIR)/gensrc_no_srczip/_the.generated_beaninfo diff --git a/jdk/makefiles/SignJars.gmk b/jdk/makefiles/SignJars.gmk index 99caa99cc22..6e84d14844a 100644 --- a/jdk/makefiles/SignJars.gmk +++ b/jdk/makefiles/SignJars.gmk @@ -79,8 +79,7 @@ check-keystore: fi $(JCE_OUTPUTDIR)/%: $(IMAGES_OUTPUTDIR)/unsigned/% - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(call install-file) $(JARSIGNER) -keystore $(SIGNING_KEYSTORE) \ $@ $(SIGNING_ALIAS) < $(SIGNING_PASSPHRASE) @$(PRINTF) "\nJar codesigning finished.\n" diff --git a/jdk/makefiles/Tools.gmk b/jdk/makefiles/Tools.gmk index 360cbe4092e..66d08b49be3 100644 --- a/jdk/makefiles/Tools.gmk +++ b/jdk/makefiles/Tools.gmk @@ -47,17 +47,15 @@ $(eval $(call SetupJavaCompilation,BUILD_TOOLS,\ endif $(JDK_OUTPUTDIR)/btclasses/build/tools/generatenimbus/resources/%.template : \ - $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/nimbus/%.template - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/nimbus/%.template + $(call install-file) BUILD_TOOLS += $(foreach i,$(wildcard $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/nimbus/*.template),$(JDK_OUTPUTDIR)/btclasses/build/tools/generatenimbus/resources/$(notdir $i)) # Resources used by CheckDeps tool $(JDK_OUTPUTDIR)/btclasses/build/tools/deps/% : \ - $(JDK_TOPDIR)/make/tools/src/build/tools/deps/% - $(MKDIR) -p $(@D) - $(CP) $< $@ + $(JDK_TOPDIR)/make/tools/src/build/tools/deps/% + $(call install-file) BUILD_TOOLS += $(JDK_OUTPUTDIR)/btclasses/build/tools/deps/refs.allowed From ca98a33db4fdac3607e62b8baf784bd068facca5 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 8 Apr 2013 14:07:32 -0400 Subject: [PATCH 43/52] 8011388: Support building zero and zeroshark with the new build Co-authored-by: Roman Kennke Reviewed-by: andrew, dholmes, erikj --- common/autoconf/generated-configure.sh | 224 ++++++++++++++++++++++++- common/autoconf/hotspot-spec.gmk.in | 13 ++ common/autoconf/jdk-options.m4 | 9 + common/autoconf/libraries.m4 | 55 +++++- common/autoconf/platform.m4 | 23 +++ common/autoconf/spec.gmk.in | 2 + 6 files changed, 323 insertions(+), 3 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 259b93866fb..20953b32231 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -609,6 +609,12 @@ SALIB_NAME HOTSPOT_MAKE_ARGS FIXPATH LIBCXX +LLVM_LIBS +LLVM_LDFLAGS +LLVM_CFLAGS +LLVM_CONFIG +LIBFFI_LIBS +LIBFFI_CFLAGS STATIC_CXX_SETTING LIBDL LIBM @@ -811,6 +817,7 @@ FASTDEBUG VARIANT DEBUG_LEVEL MACOSX_UNIVERSAL +INCLUDE_SA JVM_VARIANT_ZEROSHARK JVM_VARIANT_ZERO JVM_VARIANT_KERNEL @@ -826,6 +833,8 @@ BUILD_LOG SYS_ROOT PATH_SEP SRC_ROOT +ZERO_ARCHDEF +ZERO_ARCHFLAG DEFINE_CROSS_COMPILE_ARCH LP64 OPENJDK_TARGET_OS_API_DIR @@ -1039,7 +1048,9 @@ XMKMF FREETYPE2_CFLAGS FREETYPE2_LIBS ALSA_CFLAGS -ALSA_LIBS' +ALSA_LIBS +LIBFFI_CFLAGS +LIBFFI_LIBS' # Initialize some variables set by options. @@ -1809,6 +1820,9 @@ Some influential environment variables: linker flags for FREETYPE2, overriding pkg-config ALSA_CFLAGS C compiler flags for ALSA, overriding pkg-config ALSA_LIBS linker flags for ALSA, overriding pkg-config + LIBFFI_CFLAGS + C compiler flags for LIBFFI, overriding pkg-config + LIBFFI_LIBS linker flags for LIBFFI, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -7084,6 +7098,29 @@ $as_echo "$COMPILE_TYPE" >&6; } fi + # Some Zero and Shark settings. + # ZERO_ARCHFLAG tells the compiler which mode to build for + case "${OPENJDK_TARGET_CPU}" in + s390) + ZERO_ARCHFLAG="-m31" + ;; + *) + ZERO_ARCHFLAG="-m${OPENJDK_TARGET_CPU_BITS}" + esac + + + # ZERO_ARCHDEF is used to enable architecture-specific code + case "${OPENJDK_TARGET_CPU}" in + ppc*) ZERO_ARCHDEF=PPC ;; + s390*) ZERO_ARCHDEF=S390 ;; + sparc*) ZERO_ARCHDEF=SPARC ;; + x86_64*) ZERO_ARCHDEF=AMD64 ;; + x86) ZERO_ARCHDEF=IA32 ;; + *) ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z) + esac + + + # Continue setting up basic stuff. Most remaining code require fundamental tools. @@ -7694,6 +7731,15 @@ fi +INCLUDE_SA=true +if test "x$JVM_VARIANT_ZERO" = xtrue ; then + INCLUDE_SA=false +fi +if test "x$JVM_VARIANT_ZEROSHARK" = xtrue ; then + INCLUDE_SA=false +fi + + if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then MACOSX_UNIVERSAL="true" fi @@ -31693,7 +31739,7 @@ $as_echo "$has_static_libstdcxx" >&6; } $as_echo_n "checking how to link with libstdc++... " >&6; } # If dynamic was requested, it's available since it would fail above otherwise. # If dynamic wasn't requested, go with static unless it isn't available. - if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno; then + if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then LIBCXX="$LIBCXX -lstdc++" LDCXX="$CXX" STATIC_CXX_SETTING="STATIC_CXX=false" @@ -31709,6 +31755,180 @@ $as_echo "static" >&6; } fi +if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then + # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBFFI" >&5 +$as_echo_n "checking for LIBFFI... " >&6; } + +if test -n "$LIBFFI_CFLAGS"; then + pkg_cv_LIBFFI_CFLAGS="$LIBFFI_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libffi\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libffi") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBFFI_CFLAGS=`$PKG_CONFIG --cflags "libffi" 2>/dev/null` +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBFFI_LIBS"; then + pkg_cv_LIBFFI_LIBS="$LIBFFI_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libffi\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libffi") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBFFI_LIBS=`$PKG_CONFIG --libs "libffi" 2>/dev/null` +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + LIBFFI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libffi" 2>&1` + else + LIBFFI_PKG_ERRORS=`$PKG_CONFIG --print-errors "libffi" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBFFI_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (libffi) were not met: + +$LIBFFI_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables LIBFFI_CFLAGS +and LIBFFI_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +" "$LINENO" 5 +elif test $pkg_failed = untried; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables LIBFFI_CFLAGS +and LIBFFI_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details" "$LINENO" 5; } +else + LIBFFI_CFLAGS=$pkg_cv_LIBFFI_CFLAGS + LIBFFI_LIBS=$pkg_cv_LIBFFI_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + : +fi + +fi + +if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then + # Extract the first word of "llvm-config", so it can be a program name with args. +set dummy llvm-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_LLVM_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$LLVM_CONFIG"; then + ac_cv_prog_LLVM_CONFIG="$LLVM_CONFIG" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_LLVM_CONFIG="llvm-config" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +LLVM_CONFIG=$ac_cv_prog_LLVM_CONFIG +if test -n "$LLVM_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLVM_CONFIG" >&5 +$as_echo "$LLVM_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + if test "x$LLVM_CONFIG" != xllvm-config; then + as_fn_error $? "llvm-config not found in $PATH." "$LINENO" 5 + fi + + llvm_components="jit mcjit engine nativecodegen native" + unset LLVM_CFLAGS + for flag in $("$LLVM_CONFIG" --cxxflags); do + if echo "${flag}" | grep -q '^-[ID]'; then + if test "${flag}" != "-D_DEBUG" ; then + if test "${LLVM_CFLAGS}" != "" ; then + LLVM_CFLAGS="${LLVM_CFLAGS} " + fi + LLVM_CFLAGS="${LLVM_CFLAGS}${flag}" + fi + fi + done + llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//') + LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}" + + unset LLVM_LDFLAGS + for flag in $("${LLVM_CONFIG}" --ldflags); do + if echo "${flag}" | grep -q '^-L'; then + if test "${LLVM_LDFLAGS}" != ""; then + LLVM_LDFLAGS="${LLVM_LDFLAGS} " + fi + LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}" + fi + done + + unset LLVM_LIBS + for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do + if echo "${flag}" | grep -q '^-l'; then + if test "${LLVM_LIBS}" != ""; then + LLVM_LIBS="${LLVM_LIBS} " + fi + LLVM_LIBS="${LLVM_LIBS}${flag}" + fi + done + + + + +fi + # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so) if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1" diff --git a/common/autoconf/hotspot-spec.gmk.in b/common/autoconf/hotspot-spec.gmk.in index 5b120e73335..17b404a5902 100644 --- a/common/autoconf/hotspot-spec.gmk.in +++ b/common/autoconf/hotspot-spec.gmk.in @@ -75,6 +75,19 @@ ARCH=$(OPENJDK_TARGET_CPU_LEGACY) # If yes then this expands to _LP64:=1 @LP64@ +# Legacy settings for zero +ZERO_ENDIANNESS=$(OPENJDK_TARGET_CPU_ENDIAN) +ZERO_LIBARCH=$(OPENJDK_TARGET_CPU_LEGACY_LIB) +ZERO_ARCHDEF=@ZERO_ARCHDEF@ +ZERO_ARCHFLAG=@ZERO_ARCHFLAG@ +LIBFFI_CFLAGS=@LIBFFI_CFLAGS@ +LIBFFI_LIBS=@LIBFFI_LIBS@ + +# Legacy settings for zeroshark +LLVM_CFLAGS=@LLVM_CFLAGS@ +LLVM_LIBS=@LLVM_LIBS@ +LLVM_LDFLAGS=@LLVM_LDFLAGS@ + ALT_OUTPUTDIR=$(HOTSPOT_OUTPUTDIR) ALT_EXPORT_PATH=$(HOTSPOT_DIST) diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index 7e286036c51..268bd842f10 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -121,6 +121,15 @@ AC_SUBST(JVM_VARIANT_KERNEL) AC_SUBST(JVM_VARIANT_ZERO) AC_SUBST(JVM_VARIANT_ZEROSHARK) +INCLUDE_SA=true +if test "x$JVM_VARIANT_ZERO" = xtrue ; then + INCLUDE_SA=false +fi +if test "x$JVM_VARIANT_ZEROSHARK" = xtrue ; then + INCLUDE_SA=false +fi +AC_SUBST(INCLUDE_SA) + if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then MACOSX_UNIVERSAL="true" fi diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4 index 21c5a96f292..58c9c783b2b 100644 --- a/common/autoconf/libraries.m4 +++ b/common/autoconf/libraries.m4 @@ -687,7 +687,7 @@ if test "x$OPENJDK_TARGET_OS" = xlinux; then AC_MSG_CHECKING([how to link with libstdc++]) # If dynamic was requested, it's available since it would fail above otherwise. # If dynamic wasn't requested, go with static unless it isn't available. - if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno; then + if test "x$with_stdc__lib" = xdynamic || test "x$has_static_libstdcxx" = xno || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then LIBCXX="$LIBCXX -lstdc++" LDCXX="$CXX" STATIC_CXX_SETTING="STATIC_CXX=false" @@ -701,6 +701,59 @@ if test "x$OPENJDK_TARGET_OS" = xlinux; then fi AC_SUBST(STATIC_CXX_SETTING) +if test "x$JVM_VARIANT_ZERO" = xtrue || test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then + # Figure out LIBFFI_CFLAGS and LIBFFI_LIBS + PKG_CHECK_MODULES([LIBFFI], [libffi]) + +fi + +if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then + AC_CHECK_PROG([LLVM_CONFIG], [llvm-config], [llvm-config]) + + if test "x$LLVM_CONFIG" != xllvm-config; then + AC_MSG_ERROR([llvm-config not found in $PATH.]) + fi + + llvm_components="jit mcjit engine nativecodegen native" + unset LLVM_CFLAGS + for flag in $("$LLVM_CONFIG" --cxxflags); do + if echo "${flag}" | grep -q '^-@<:@ID@:>@'; then + if test "${flag}" != "-D_DEBUG" ; then + if test "${LLVM_CFLAGS}" != "" ; then + LLVM_CFLAGS="${LLVM_CFLAGS} " + fi + LLVM_CFLAGS="${LLVM_CFLAGS}${flag}" + fi + fi + done + llvm_version=$("${LLVM_CONFIG}" --version | sed 's/\.//; s/svn.*//') + LLVM_CFLAGS="${LLVM_CFLAGS} -DSHARK_LLVM_VERSION=${llvm_version}" + + unset LLVM_LDFLAGS + for flag in $("${LLVM_CONFIG}" --ldflags); do + if echo "${flag}" | grep -q '^-L'; then + if test "${LLVM_LDFLAGS}" != ""; then + LLVM_LDFLAGS="${LLVM_LDFLAGS} " + fi + LLVM_LDFLAGS="${LLVM_LDFLAGS}${flag}" + fi + done + + unset LLVM_LIBS + for flag in $("${LLVM_CONFIG}" --libs ${llvm_components}); do + if echo "${flag}" | grep -q '^-l'; then + if test "${LLVM_LIBS}" != ""; then + LLVM_LIBS="${LLVM_LIBS} " + fi + LLVM_LIBS="${LLVM_LIBS}${flag}" + fi + done + + AC_SUBST(LLVM_CFLAGS) + AC_SUBST(LLVM_LDFLAGS) + AC_SUBST(LLVM_LIBS) +fi + # libCrun is the c++ runtime-library with SunStudio (roughly the equivalent of gcc's libstdc++.so) if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$LIBCXX" = x; then LIBCXX="/usr/lib${OPENJDK_TARGET_CPU_ISADIR}/libCrun.so.1" diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 index 2977606ba79..067650688c3 100644 --- a/common/autoconf/platform.m4 +++ b/common/autoconf/platform.m4 @@ -332,6 +332,29 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS], DEFINE_CROSS_COMPILE_ARCH="" fi AC_SUBST(DEFINE_CROSS_COMPILE_ARCH) + + # Some Zero and Shark settings. + # ZERO_ARCHFLAG tells the compiler which mode to build for + case "${OPENJDK_TARGET_CPU}" in + s390) + ZERO_ARCHFLAG="-m31" + ;; + *) + ZERO_ARCHFLAG="-m${OPENJDK_TARGET_CPU_BITS}" + esac + AC_SUBST(ZERO_ARCHFLAG) + + # ZERO_ARCHDEF is used to enable architecture-specific code + case "${OPENJDK_TARGET_CPU}" in + ppc*) ZERO_ARCHDEF=PPC ;; + s390*) ZERO_ARCHDEF=S390 ;; + sparc*) ZERO_ARCHDEF=SPARC ;; + x86_64*) ZERO_ARCHDEF=AMD64 ;; + x86) ZERO_ARCHDEF=IA32 ;; + *) ZERO_ARCHDEF=$(echo "${OPENJDK_TARGET_CPU_LEGACY_LIB}" | tr a-z A-Z) + esac + AC_SUBST(ZERO_ARCHDEF) + ]) AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES], diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 11d19a342d7..e84b0749b48 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -636,6 +636,8 @@ INSTALL_SYSCONFDIR=@sysconfdir@ # Name of Service Agent library SALIB_NAME=@SALIB_NAME@ +INCLUDE_SA=@INCLUDE_SA@ + OS_VERSION_MAJOR:=@OS_VERSION_MAJOR@ OS_VERSION_MINOR:=@OS_VERSION_MINOR@ OS_VERSION_MICRO:=@OS_VERSION_MICRO@ From 7f1fd4ecb92638fb0b62f0e794fc9be64548b472 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 8 Apr 2013 14:09:01 -0400 Subject: [PATCH 44/52] 8011388: Support building zero and zeroshark with the new build Co-authored-by: Roman Kennke Reviewed-by: andrew, dholmes, erikj --- jdk/makefiles/Profiles.gmk | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/jdk/makefiles/Profiles.gmk b/jdk/makefiles/Profiles.gmk index 316d2d34329..47fadcc9df9 100644 --- a/jdk/makefiles/Profiles.gmk +++ b/jdk/makefiles/Profiles.gmk @@ -93,8 +93,11 @@ ALL_JARS := $(FULL_JRE_JARS) \ $(IMAGES_OUTPUTDIR)/lib/dt.jar \ $(IMAGES_OUTPUTDIR)/lib/tools.jar \ $(IMAGES_OUTPUTDIR)/lib/ct.sym \ - $(IMAGES_OUTPUTDIR)/src.zip \ - $(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar + $(IMAGES_OUTPUTDIR)/src.zip + +ifeq ($(INCLUDE_SA),true) + ALL_JARS += $(IMAGES_OUTPUTDIR)/lib/sa-jdi.jar +endif ifeq ($(OPENJDK_TARGET_OS),solaris) ifndef OPENJDK From 21711140e2e497d9736eae750d7e44cd5b6ee869 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 9 Apr 2013 09:42:20 +0200 Subject: [PATCH 45/52] 8006288: build-infra: Use solaris nm and not gnm on solaris Reviewed-by: tbell --- common/autoconf/compare.sh.in | 2 +- common/autoconf/generated-configure.sh | 324 ++++++++++++++++++++++++- common/autoconf/spec.gmk.in | 1 + common/autoconf/toolchain.m4 | 6 +- 4 files changed, 321 insertions(+), 12 deletions(-) diff --git a/common/autoconf/compare.sh.in b/common/autoconf/compare.sh.in index b8fa8b85d8a..2b344aac4d8 100644 --- a/common/autoconf/compare.sh.in +++ b/common/autoconf/compare.sh.in @@ -49,7 +49,7 @@ JAVAP="@FIXPATH@ @BOOT_JDK@/bin/javap" LDD="@LDD@" MKDIR="@MKDIR@" NAWK="@NAWK@" -NM="@NM@" +NM="@GNM@" OBJDUMP="@OBJDUMP@" OTOOL="@OTOOL@" PRINTF="@PRINTF@" diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 20953b32231..ece735837c6 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -686,6 +686,7 @@ ac_ct_OBJCOPY OBJCOPY MCS STRIP +GNM NM AS CXXCPP @@ -3763,7 +3764,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1365147397 +DATE_WHEN_GENERATED=1365493306 ############################################################################### # @@ -25200,10 +25201,8 @@ fi if test "x$OPENJDK_TARGET_OS" = xsolaris; then - for ac_prog in gnm nm -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 + # Extract the first word of "nm", so it can be a program name with args. +set dummy nm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if test "${ac_cv_path_NM+set}" = set; then : @@ -25242,9 +25241,6 @@ $as_echo "no" >&6; } fi - test -n "$NM" && break -done - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -25511,6 +25507,312 @@ $as_echo "$as_me: This might be caused by spaces in the path, which is not allow $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} fi + # Extract the first word of "gnm", so it can be a program name with args. +set dummy gnm; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_GNM+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $GNM in + [\\/]* | ?:[\\/]*) + ac_cv_path_GNM="$GNM" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_GNM="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +GNM=$ac_cv_path_GNM +if test -n "$GNM"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GNM" >&5 +$as_echo "$GNM" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # First separate the path from the arguments. This will split at the first + # space. + complete="$GNM" + path="${complete%% *}" + tmp="$complete EOL" + arguments="${tmp#* }" + + # Input might be given as Windows format, start by converting to + # unix format. + new_path=`$CYGPATH -u "$path"` + + # Now try to locate executable using which + new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in cygwin causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path=`$CYGPATH -u "$path"` + fi + if test "x$new_path" = x; then + # Oops. Which didn't find the executable. + # The splitting of arguments from the executable at a space might have been incorrect, + # since paths with space are more likely in Windows. Give it another try with the whole + # argument. + path="$complete" + arguments="EOL" + new_path=`$CYGPATH -u "$path"` + new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in cygwin causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path=`$CYGPATH -u "$path"` + fi + if test "x$new_path" = x; then + # It's still not found. Now this is an unrecoverable error. + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of GNM, which resolves as \"$complete\", is not found." >&5 +$as_echo "$as_me: The path of GNM, which resolves as \"$complete\", is not found." >&6;} + has_space=`$ECHO "$complete" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 +$as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} + fi + as_fn_error $? "Cannot locate the the path of GNM" "$LINENO" 5 + fi + fi + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + # Short path failed, file does not exist as specified. + # Try adding .exe or .cmd + if test -f "${new_path}.exe"; then + input_to_shortpath="${new_path}.exe" + elif test -f "${new_path}.cmd"; then + input_to_shortpath="${new_path}.cmd" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of GNM, which resolves as \"$new_path\", is invalid." >&5 +$as_echo "$as_me: The path of GNM, which resolves as \"$new_path\", is invalid." >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5 +$as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;} + as_fn_error $? "Cannot locate the the path of GNM" "$LINENO" 5 + fi + else + input_to_shortpath="$new_path" + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + new_path="$input_to_shortpath" + + input_path="$input_to_shortpath" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-stile (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $input_to_shortpath | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + # remove trailing .exe if any + new_path="${new_path/%.exe/}" + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + # First separate the path from the arguments. This will split at the first + # space. + complete="$GNM" + path="${complete%% *}" + tmp="$complete EOL" + arguments="${tmp#* }" + + # Input might be given as Windows format, start by converting to + # unix format. + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + + # Now try to locate executable using which + new_path=`$WHICH "$new_path" 2> /dev/null` + + if test "x$new_path" = x; then + # Oops. Which didn't find the executable. + # The splitting of arguments from the executable at a space might have been incorrect, + # since paths with space are more likely in Windows. Give it another try with the whole + # argument. + path="$complete" + arguments="EOL" + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + + new_path=`$WHICH "$new_path" 2> /dev/null` + + if test "x$new_path" = x; then + # It's still not found. Now this is an unrecoverable error. + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of GNM, which resolves as \"$complete\", is not found." >&5 +$as_echo "$as_me: The path of GNM, which resolves as \"$complete\", is not found." >&6;} + has_space=`$ECHO "$complete" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5 +$as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;} + fi + as_fn_error $? "Cannot locate the the path of GNM" "$LINENO" 5 + fi + fi + + # Now new_path has a complete unix path to the binary + if test "x`$ECHO $new_path | $GREP ^/bin/`" != x; then + # Keep paths in /bin as-is, but remove trailing .exe if any + new_path="${new_path/%.exe/}" + # Do not save /bin paths to all_fixpath_prefixes! + else + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $new_path` + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + # Output is in $new_path + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + # remove trailing .exe if any + new_path="${new_path/%.exe/}" + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + fi + + else + # We're on a posix platform. Hooray! :) + # First separate the path from the arguments. This will split at the first + # space. + complete="$GNM" + path="${complete%% *}" + tmp="$complete EOL" + arguments="${tmp#* }" + + # Cannot rely on the command "which" here since it doesn't always work. + is_absolute_path=`$ECHO "$path" | $GREP ^/` + if test -z "$is_absolute_path"; then + # Path to executable is not absolute. Find it. + IFS_save="$IFS" + IFS=: + for p in $PATH; do + if test -f "$p/$path" && test -x "$p/$path"; then + new_path="$p/$path" + break + fi + done + IFS="$IFS_save" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: Resolving GNM (as $path) failed, using $path directly." >&5 +$as_echo "$as_me: Resolving GNM (as $path) failed, using $path directly." >&6;} + new_path="$path" + fi + + if test "x$new_path" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of GNM, which resolves as \"$complete\", is not found." >&5 +$as_echo "$as_me: The path of GNM, which resolves as \"$complete\", is not found." >&6;} + has_space=`$ECHO "$complete" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5 +$as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;} + fi + as_fn_error $? "Cannot locate the the path of GNM" "$LINENO" 5 + fi + fi + + # Now join together the path and the arguments once again + if test "x$arguments" != xEOL; then + new_complete="$new_path ${arguments% *}" + else + new_complete="$new_path" + fi + + if test "x$complete" != "x$new_complete"; then + GNM="$new_complete" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting GNM to \"$new_complete\"" >&5 +$as_echo "$as_me: Rewriting GNM to \"$new_complete\"" >&6;} + fi + # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -26482,6 +26784,8 @@ $as_echo "$as_me: This might be caused by spaces in the path, which is not allow $as_echo "$as_me: Rewriting NM to \"$new_complete\"" >&6;} fi + GNM="$NM" + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 @@ -31835,7 +32139,7 @@ and LIBFFI_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . -See \`config.log' for more details" "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } else LIBFFI_CFLAGS=$pkg_cv_LIBFFI_CFLAGS LIBFFI_LIBS=$pkg_cv_LIBFFI_LIBS @@ -31851,7 +32155,7 @@ if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then set dummy llvm-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_LLVM_CONFIG+:} false; then : +if test "${ac_cv_prog_LLVM_CONFIG+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$LLVM_CONFIG"; then diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index e84b0749b48..92b0c83017e 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -377,6 +377,7 @@ AR:=@FIXPATH@ @AR@ ARFLAGS:=@ARFLAGS@ NM:=@NM@ +GNM:=@GNM@ STRIP:=@STRIP@ MCS:=@MCS@ diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index bacff783414..893fb16d674 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -441,8 +441,10 @@ fi AC_SUBST(AS) if test "x$OPENJDK_TARGET_OS" = xsolaris; then - AC_PATH_PROGS(NM, [gnm nm]) + AC_PATH_PROG(NM, nm) BASIC_FIXUP_EXECUTABLE(NM) + AC_PATH_PROG(GNM, gnm) + BASIC_FIXUP_EXECUTABLE(GNM) AC_PATH_PROG(STRIP, strip) BASIC_FIXUP_EXECUTABLE(STRIP) AC_PATH_PROG(MCS, mcs) @@ -450,6 +452,8 @@ if test "x$OPENJDK_TARGET_OS" = xsolaris; then elif test "x$OPENJDK_TARGET_OS" != xwindows; then AC_CHECK_TOOL(NM, nm) BASIC_FIXUP_EXECUTABLE(NM) + GNM="$NM" + AC_SUBST(GNM) AC_CHECK_TOOL(STRIP, strip) BASIC_FIXUP_EXECUTABLE(STRIP) fi From 80b7d8cf9905d5afa404ed7af32beb8aa836b1ed Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 9 Apr 2013 09:45:48 +0200 Subject: [PATCH 46/52] 8010465: Can't enable sjavac when building in jprt Reviewed-by: ohair, tbell --- common/makefiles/JavaCompilation.gmk | 4 ++-- common/makefiles/Jprt.gmk | 3 +++ common/makefiles/MakeBase.gmk | 10 +++++----- common/makefiles/MakeHelpers.gmk | 22 +++++++++++++++------- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/common/makefiles/JavaCompilation.gmk b/common/makefiles/JavaCompilation.gmk index bc13da5357b..4301cee1f0b 100644 --- a/common/makefiles/JavaCompilation.gmk +++ b/common/makefiles/JavaCompilation.gmk @@ -86,7 +86,7 @@ define SetupArchive # NOTE: $2 is dependencies, not a named argument! $(foreach i,3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) $(call LogSetupMacroEntry,SetupArchive($1),,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) - $(if $(findstring $(LOG),debug trace), $(info *[2] = $(strip $2))) + $(if $(findstring $(LOG_LEVEL),debug trace), $(info *[2] = $(strip $2))) $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk)) $1_JARMAIN:=$(strip $$($1_JARMAIN)) @@ -505,7 +505,7 @@ define SetupJavaCompilation --permit-unidentified-artifacts \ --permit-sources-without-package \ --compare-found-sources $$($1_BIN)/_the.batch.tmp \ - --log=$(LOG) \ + --log=$(LOG_LEVEL) \ $$($1_SJAVAC_ARGS) \ $$($1_FLAGS) \ $$($1_HEADERS_ARG) \ diff --git a/common/makefiles/Jprt.gmk b/common/makefiles/Jprt.gmk index 938d4362e29..c38dedce1f5 100644 --- a/common/makefiles/Jprt.gmk +++ b/common/makefiles/Jprt.gmk @@ -103,6 +103,9 @@ endif ifdef ALT_FREETYPE_HEADERS_PATH @$(ECHO) " --with-freetype=$(call UnixPath,$(ALT_FREETYPE_HEADERS_PATH)/..) " >> $@.tmp endif +ifdef ENABLE_SJAVAC + @$(ECHO) " --enable-sjavac" >> $@.tmp +endif ifeq ($(HOTSPOT_AVAILABLE),false) ifdef ALT_JDK_IMPORT_PATH @$(ECHO) " --with-import-hotspot=$(call UnixPath,$(ALT_JDK_IMPORT_PATH)) " >> $@.tmp diff --git a/common/makefiles/MakeBase.gmk b/common/makefiles/MakeBase.gmk index 5a54e38a0ea..3cbdf79bae9 100644 --- a/common/makefiles/MakeBase.gmk +++ b/common/makefiles/MakeBase.gmk @@ -328,7 +328,7 @@ $(ECHO) $1/$(HGTIP_FILENAME) endef define SetupLogging - ifeq ($$(LOG), trace) + ifeq ($$(LOG_LEVEL),trace) # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make # For each target executed, will print # Building (from ) ( newer) @@ -339,17 +339,17 @@ define SetupLogging endif # Never remove warning messages; this is just for completeness LOG_WARN= - ifneq ($$(findstring $$(LOG),info debug trace),) + ifneq ($$(findstring $$(LOG_LEVEL),info debug trace),) LOG_INFO= else LOG_INFO=> /dev/null endif - ifneq ($$(findstring $$(LOG),debug trace),) + ifneq ($$(findstring $$(LOG_LEVEL),debug trace),) LOG_DEBUG= else LOG_DEBUG=> /dev/null endif - ifneq ($$(findstring $$(LOG),trace),) + ifneq ($$(findstring $$(LOG_LEVEL),trace),) LOG_TRACE= else LOG_TRACE=> /dev/null @@ -362,7 +362,7 @@ $(eval $(call SetupLogging)) # This is to be called by all SetupFoo macros define LogSetupMacroEntry $(if $(26),$(error Internal makefile error: Too many arguments to LogSetupMacroEntry, please update MakeBase.gmk)) - $(if $(findstring $(LOG),debug trace), $(info $1 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25,$(if $($i),$(NEWLINE) $(strip [$i] $($i)))))) + $(if $(findstring $(LOG_LEVEL),debug trace), $(info $1 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25,$(if $($i),$(NEWLINE) $(strip [$i] $($i)))))) endef # Make directory without forking mkdir if not needed diff --git a/common/makefiles/MakeHelpers.gmk b/common/makefiles/MakeHelpers.gmk index 81e1d697e11..aa495323b5d 100644 --- a/common/makefiles/MakeHelpers.gmk +++ b/common/makefiles/MakeHelpers.gmk @@ -184,26 +184,34 @@ define ParseLogLevel LOG_STRIPPED2=$$(subst nofile,,$$(LOG_STRIPPED1)) # We might have ended up with a leading comma. Remove it LOG_STRIPPED3=$$(strip $$(patsubst $$(COMMA)%,%,$$(LOG_STRIPPED2))) - override LOG:=$$(LOG_STRIPPED3) + LOG_LEVEL:=$$(LOG_STRIPPED3) + else + LOG_LEVEL:=$$(LOG) endif - ifeq ($$(LOG),) + ifeq ($$(LOG_LEVEL),) # Set LOG to "warn" as default if not set (and no VERBOSE given) - override LOG=warn + override LOG_LEVEL=warn endif - ifeq ($$(LOG),warn) + ifeq ($$(LOG_LEVEL),warn) VERBOSE=-s - else ifeq ($$(LOG),info) + else ifeq ($$(LOG_LEVEL),info) VERBOSE=-s - else ifeq ($$(LOG),debug) + else ifeq ($$(LOG_LEVEL),debug) VERBOSE= - else ifeq ($$(LOG),trace) + else ifeq ($$(LOG_LEVEL),trace) VERBOSE= else $$(info Error: LOG must be one of: warn, info, debug or trace.) $$(eval $$(call FatalError)) endif else + # Provide resonable interpretations of LOG_LEVEL if VERBOSE is given. + ifeq ($(VERBOSE),) + LOG_LEVEL:=debug + else + LOG_LEVEL:=warn + endif ifneq ($$(LOG),) # We have both a VERBOSE and a LOG argument. This is OK only if this is a repeated call by ourselves, # but complain if this is the top-level make call. From 0a6c65bc99ee750499d9c894d18ab325b452d8d9 Mon Sep 17 00:00:00 2001 From: Tim Bell Date: Tue, 9 Apr 2013 13:05:22 -0700 Subject: [PATCH 47/52] 8011348: use of which in common/autoconf/autogen.sh is not portable Reviewed-by: erikj, katleman, mduigou --- common/autoconf/autogen.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/autoconf/autogen.sh b/common/autoconf/autogen.sh index 6df1f557552..35ed2a5813a 100644 --- a/common/autoconf/autogen.sh +++ b/common/autoconf/autogen.sh @@ -43,8 +43,8 @@ fi custom_hook=$custom_script_dir/custom-hook.m4 -AUTOCONF=$(which autoconf 2> /dev/null); -AUTOCONF_267=$(which autoconf-2.67 2> /dev/null); +AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`" +AUTOCONF_267="`which autoconf-2.67 2> /dev/null | grep -v '^no autoconf-2.67 in'`" echo "Autoconf found: ${AUTOCONF}" echo "Autoconf-2.67 found: ${AUTOCONF_267}" From 8e31509df1443c2282cd08575266c5f142a6681a Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 18:48:17 +0200 Subject: [PATCH 48/52] Added tag jdk8-b84 for changeset d7ad0dfaa411 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 95524f5c8df..a689628fb73 100644 --- a/.hgtags +++ b/.hgtags @@ -205,3 +205,4 @@ a1313a8d90d17d363a3b2a645dc4030ec204b168 jdk8-b79 e41d716405b209d3eddef8bd4240cec2bd34dcca jdk8-b81 5e8c55025644730385a6f8fa029ecdb2d2c98a07 jdk8-b82 bcebd3fdefc91abb9d7fa0c5af6211b3f8720da6 jdk8-b83 +d7ad0dfaa41151bd3a9ae46725b0aec3730a9cd0 jdk8-b84 From 488df135583efd941bbe34f8faf564fda70228fc Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 11 Apr 2013 09:40:13 -0700 Subject: [PATCH 49/52] Added tag jdk8-b85 for changeset c62699ce4007 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 5548c0a383e..ef6e16f2fe3 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -206,3 +206,4 @@ c0f8022eba536dcdc8aae659005b33f3982b9368 jdk8-b81 624bcb4800065c6656171948e31ebb2925f25c7a jdk8-b82 ac519af51769e92c51b597a730974e8607357709 jdk8-b83 7b4721e4edb4e1c65e9c839a70d7cc67f81c7632 jdk8-b84 +296676d534c52888c36e305a2bf7f345c4ca70f8 jdk8-b85 From 58af157d96b1f757cff0a368ff249daa57ac3581 Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Fri, 12 Apr 2013 07:57:35 -0700 Subject: [PATCH 50/52] 8011172: JSR 310 DateTime API Updates II Integration of JSR310 Date/Time API update Co-authored-by: Roger Riggs Co-authored-by: Masayoshi Okutsu Reviewed-by: alanb, naoto, dholmes --- jdk/make/java/java/Makefile | 11 +- jdk/make/java/text/base/FILES_java.gmk | 6 +- jdk/make/java/util/FILES_java.gmk | 3 +- jdk/make/sun/text/FILES_java.gmk | 53 +- jdk/make/sun/tzdb/Makefile | 14 +- .../cldrconverter/AbstractLDMLHandler.java | 5 +- .../src/build/tools/cldrconverter/Bundle.java | 19 +- .../tools/cldrconverter/CLDRConverter.java | 66 +- .../tools/cldrconverter/LDMLParseHandler.java | 38 + .../tools/tzdb/TzdbZoneRulesCompiler.java | 561 ++---- jdk/makefiles/CopyFiles.gmk | 7 + jdk/makefiles/CreateJars.gmk | 5 - jdk/makefiles/GendataTZDB.gmk | 13 +- jdk/makefiles/profile-includes.txt | 6 +- .../share/classes/java/time/DayOfWeek.java | 23 +- jdk/src/share/classes/java/time/Duration.java | 116 +- jdk/src/share/classes/java/time/Instant.java | 96 +- .../share/classes/java/time/LocalDate.java | 156 +- .../classes/java/time/LocalDateTime.java | 146 +- .../share/classes/java/time/LocalTime.java | 86 +- jdk/src/share/classes/java/time/Month.java | 21 +- jdk/src/share/classes/java/time/MonthDay.java | 48 +- .../classes/java/time/OffsetDateTime.java | 97 +- .../share/classes/java/time/OffsetTime.java | 77 +- jdk/src/share/classes/java/time/Period.java | 88 +- jdk/src/share/classes/java/time/Year.java | 70 +- .../share/classes/java/time/YearMonth.java | 94 +- jdk/src/share/classes/java/time/ZoneId.java | 297 ++- .../share/classes/java/time/ZoneOffset.java | 25 +- .../share/classes/java/time/ZoneRegion.java | 73 +- .../classes/java/time/ZonedDateTime.java | 123 +- .../java/time/chrono/ChronoDateImpl.java | 49 +- .../java/time/chrono/ChronoLocalDate.java | 152 +- .../java/time/chrono/ChronoLocalDateTime.java | 130 +- .../time/chrono/ChronoLocalDateTimeImpl.java | 19 +- .../java/time/chrono/ChronoZonedDateTime.java | 147 +- .../time/chrono/ChronoZonedDateTimeImpl.java | 1 + .../classes/java/time/chrono/Chronology.java | 370 +++- .../share/classes/java/time/chrono/Era.java | 89 +- .../java/time/chrono/HijrahChronology.java | 1785 +++++++---------- .../classes/java/time/chrono/HijrahDate.java | 413 ++-- .../time/chrono/HijrahDeviationReader.java | 244 --- .../classes/java/time/chrono/HijrahEra.java | 105 +- .../java/time/chrono/IsoChronology.java | 337 +++- .../classes/java/time/chrono/IsoEra.java | 67 +- .../java/time/chrono/JapaneseChronology.java | 141 +- .../java/time/chrono/JapaneseDate.java | 85 +- .../classes/java/time/chrono/JapaneseEra.java | 95 +- .../java/time/chrono/MinguoChronology.java | 112 +- .../classes/java/time/chrono/MinguoDate.java | 73 +- .../classes/java/time/chrono/MinguoEra.java | 69 +- .../time/chrono/ThaiBuddhistChronology.java | 111 +- .../java/time/chrono/ThaiBuddhistDate.java | 71 +- .../java/time/chrono/ThaiBuddhistEra.java | 77 +- .../java/time/format/DateTimeBuilder.java | 595 ------ .../format/DateTimeFormatStyleProvider.java | 147 -- .../java/time/format/DateTimeFormatter.java | 1153 +++++++---- .../time/format/DateTimeFormatterBuilder.java | 940 ++++++--- .../time/format/DateTimeParseContext.java | 152 +- .../time/format/DateTimePrintContext.java | 142 +- .../time/format/DateTimeTextProvider.java | 233 ++- .../classes/java/time/format/Parsed.java | 482 +++++ .../java/time/format/ResolverStyle.java | 116 ++ .../classes/java/time/format/TextStyle.java | 96 +- .../java/time/temporal/ChronoField.java | 78 +- .../java/time/temporal/ChronoUnit.java | 2 +- .../classes/java/time/temporal/IsoFields.java | 148 +- .../java/time/temporal/JulianFields.java | 38 +- .../classes/java/time/temporal/Queries.java | 356 ---- .../classes/java/time/temporal/Temporal.java | 26 +- .../java/time/temporal/TemporalAccessor.java | 58 +- .../java/time/temporal/TemporalAdjuster.java | 327 ++- ...{Adjusters.java => TemporalAdjusters.java} | 234 +-- .../java/time/temporal/TemporalAmount.java | 17 +- .../java/time/temporal/TemporalField.java | 88 +- .../java/time/temporal/TemporalQueries.java | 157 ++ .../java/time/temporal/TemporalQuery.java | 220 +- .../java/time/temporal/TemporalUnit.java | 18 +- .../UnsupportedTemporalTypeException.java | 101 + .../java/time/temporal/ValueRange.java | 16 +- .../java/time/temporal/WeekFields.java | 458 ++++- .../java/time/temporal/package-info.java | 6 +- .../java/time/zone/TzdbZoneRulesProvider.java | 8 +- .../java/time/zone/ZoneOffsetTransition.java | 2 +- .../time/zone/ZoneOffsetTransitionRule.java | 4 +- .../java/time/zone/ZoneRulesProvider.java | 2 +- .../share/classes/java/util/Formatter.java | 4 +- .../classes/java/util/GregorianCalendar.java | 2 +- jdk/src/share/classes/java/util/TimeZone.java | 2 +- .../sun/text/resources/FormatData.java | 147 +- .../text/resources/JavaTimeSupplementary.java | 287 +++ .../sun/text/resources/ar/FormatData_ar.java | 178 +- .../text/resources/ar/FormatData_ar_JO.java | 8 +- .../text/resources/ar/FormatData_ar_LB.java | 8 +- .../text/resources/ar/FormatData_ar_SY.java | 8 +- .../ar/JavaTimeSupplementary_ar.java | 285 +++ .../sun/text/resources/be/FormatData_be.java | 35 +- .../text/resources/be/FormatData_be_BY.java | 8 +- .../be/JavaTimeSupplementary_be.java | 138 ++ .../sun/text/resources/bg/FormatData_bg.java | 64 +- .../text/resources/bg/FormatData_bg_BG.java | 8 +- .../bg/JavaTimeSupplementary_bg.java | 163 ++ .../sun/text/resources/ca/FormatData_ca.java | 69 +- .../text/resources/ca/FormatData_ca_ES.java | 8 +- .../ca/JavaTimeSupplementary_ca.java | 140 ++ .../sun/text/resources/cs/FormatData_cs.java | 101 +- .../text/resources/cs/FormatData_cs_CZ.java | 8 +- .../cs/JavaTimeSupplementary_cs.java | 190 ++ .../sun/text/resources/da/FormatData_da.java | 93 +- .../text/resources/da/FormatData_da_DK.java | 8 +- .../da/JavaTimeSupplementary_da.java | 194 ++ .../sun/text/resources/de/FormatData_de.java | 106 +- .../text/resources/de/FormatData_de_AT.java | 8 +- .../text/resources/de/FormatData_de_CH.java | 8 +- .../text/resources/de/FormatData_de_DE.java | 8 +- .../text/resources/de/FormatData_de_LU.java | 8 +- .../de/JavaTimeSupplementary_de.java | 194 ++ .../sun/text/resources/el/FormatData_el.java | 148 +- .../text/resources/el/FormatData_el_CY.java | 29 +- .../text/resources/el/FormatData_el_GR.java | 8 +- .../el/JavaTimeSupplementary_el.java | 184 ++ .../sun/text/resources/en/FormatData_en.java | 8 +- .../text/resources/en/FormatData_en_AU.java | 8 +- .../text/resources/en/FormatData_en_CA.java | 8 +- .../text/resources/en/FormatData_en_GB.java | 8 +- .../text/resources/en/FormatData_en_IE.java | 8 +- .../text/resources/en/FormatData_en_IN.java | 8 +- .../text/resources/en/FormatData_en_MT.java | 29 +- .../text/resources/en/FormatData_en_NZ.java | 8 +- .../text/resources/en/FormatData_en_PH.java | 29 +- .../text/resources/en/FormatData_en_SG.java | 29 +- .../text/resources/en/FormatData_en_US.java | 8 +- .../text/resources/en/FormatData_en_ZA.java | 8 +- .../en/JavaTimeSupplementary_en.java | 186 ++ .../en/JavaTimeSupplementary_en_GB.java | 122 ++ .../en/JavaTimeSupplementary_en_SG.java | 106 + .../sun/text/resources/es/FormatData_es.java | 101 +- .../text/resources/es/FormatData_es_AR.java | 8 +- .../text/resources/es/FormatData_es_BO.java | 8 +- .../text/resources/es/FormatData_es_CL.java | 8 +- .../text/resources/es/FormatData_es_CO.java | 8 +- .../text/resources/es/FormatData_es_CR.java | 8 +- .../text/resources/es/FormatData_es_DO.java | 8 +- .../text/resources/es/FormatData_es_EC.java | 8 +- .../text/resources/es/FormatData_es_ES.java | 8 +- .../text/resources/es/FormatData_es_GT.java | 8 +- .../text/resources/es/FormatData_es_HN.java | 8 +- .../text/resources/es/FormatData_es_MX.java | 8 +- .../text/resources/es/FormatData_es_NI.java | 8 +- .../text/resources/es/FormatData_es_PA.java | 8 +- .../text/resources/es/FormatData_es_PE.java | 8 +- .../text/resources/es/FormatData_es_PR.java | 8 +- .../text/resources/es/FormatData_es_PY.java | 8 +- .../text/resources/es/FormatData_es_SV.java | 8 +- .../text/resources/es/FormatData_es_US.java | 29 +- .../text/resources/es/FormatData_es_UY.java | 8 +- .../text/resources/es/FormatData_es_VE.java | 8 +- .../es/JavaTimeSupplementary_es.java | 206 ++ .../sun/text/resources/et/FormatData_et.java | 48 +- .../text/resources/et/FormatData_et_EE.java | 8 +- .../et/JavaTimeSupplementary_et.java | 146 ++ .../sun/text/resources/fi/FormatData_fi.java | 154 +- .../text/resources/fi/FormatData_fi_FI.java | 8 +- .../fi/JavaTimeSupplementary_fi.java | 219 ++ .../sun/text/resources/fr/FormatData_fr.java | 164 +- .../text/resources/fr/FormatData_fr_BE.java | 8 +- .../text/resources/fr/FormatData_fr_CA.java | 8 +- .../text/resources/fr/FormatData_fr_CH.java | 8 +- .../text/resources/fr/FormatData_fr_FR.java | 8 +- .../fr/JavaTimeSupplementary_fr.java | 264 +++ .../sun/text/resources/ga/FormatData_ga.java | 52 +- .../text/resources/ga/FormatData_ga_IE.java | 29 +- .../ga/JavaTimeSupplementary_ga.java | 96 + .../text/resources/hi/FormatData_hi_IN.java | 47 +- .../hi/JavaTimeSupplementary_hi_IN.java | 167 ++ .../sun/text/resources/hr/FormatData_hr.java | 109 +- .../text/resources/hr/FormatData_hr_HR.java | 8 +- .../hr/JavaTimeSupplementary_hr.java | 190 ++ .../sun/text/resources/hu/FormatData_hu.java | 154 +- .../text/resources/hu/FormatData_hu_HU.java | 8 +- .../hu/JavaTimeSupplementary_hu.java | 235 +++ .../sun/text/resources/in/FormatData_in.java | 29 +- .../text/resources/in/FormatData_in_ID.java | 29 +- .../sun/text/resources/is/FormatData_is.java | 30 +- .../text/resources/is/FormatData_is_IS.java | 8 +- .../is/JavaTimeSupplementary_is.java | 140 ++ .../sun/text/resources/it/FormatData_it.java | 122 +- .../text/resources/it/FormatData_it_CH.java | 8 +- .../text/resources/it/FormatData_it_IT.java | 8 +- .../it/JavaTimeSupplementary_it.java | 200 ++ .../sun/text/resources/iw/FormatData_iw.java | 69 +- .../text/resources/iw/FormatData_iw_IL.java | 8 +- .../iw/JavaTimeSupplementary_iw.java | 167 ++ .../iw/JavaTimeSupplementary_iw_IL.java | 167 ++ .../sun/text/resources/ja/FormatData_ja.java | 59 +- .../text/resources/ja/FormatData_ja_JP.java | 8 +- .../ja/JavaTimeSupplementary_ja.java | 254 +++ .../sun/text/resources/ko/FormatData_ko.java | 100 +- .../text/resources/ko/FormatData_ko_KR.java | 8 +- .../ko/JavaTimeSupplementary_ko.java | 214 ++ .../sun/text/resources/lt/FormatData_lt.java | 94 +- .../text/resources/lt/FormatData_lt_LT.java | 8 +- .../lt/JavaTimeSupplementary_lt.java | 154 ++ .../sun/text/resources/lv/FormatData_lv.java | 58 +- .../text/resources/lv/FormatData_lv_LV.java | 8 +- .../lv/JavaTimeSupplementary_lv.java | 163 ++ .../sun/text/resources/mk/FormatData_mk.java | 41 +- .../text/resources/mk/FormatData_mk_MK.java | 8 +- .../mk/JavaTimeSupplementary_mk.java | 132 ++ .../sun/text/resources/ms/FormatData_ms.java | 103 +- .../text/resources/ms/FormatData_ms_MY.java | 29 +- .../ms/JavaTimeSupplementary_ms.java | 186 ++ .../sun/text/resources/mt/FormatData_mt.java | 37 +- .../text/resources/mt/FormatData_mt_MT.java | 29 +- .../mt/JavaTimeSupplementary_mt.java | 134 ++ .../sun/text/resources/nl/FormatData_nl.java | 128 +- .../text/resources/nl/FormatData_nl_BE.java | 8 +- .../text/resources/nl/FormatData_nl_NL.java | 8 +- .../nl/JavaTimeSupplementary_nl.java | 240 +++ .../sun/text/resources/no/FormatData_no.java | 120 +- .../text/resources/no/FormatData_no_NO.java | 8 +- .../resources/no/FormatData_no_NO_NY.java | 8 +- .../no/JavaTimeSupplementary_no.java | 194 ++ .../sun/text/resources/pl/FormatData_pl.java | 155 +- .../text/resources/pl/FormatData_pl_PL.java | 8 +- .../pl/JavaTimeSupplementary_pl.java | 257 +++ .../sun/text/resources/pt/FormatData_pt.java | 93 +- .../text/resources/pt/FormatData_pt_BR.java | 8 +- .../text/resources/pt/FormatData_pt_PT.java | 8 +- .../pt/JavaTimeSupplementary_pt.java | 206 ++ .../pt/JavaTimeSupplementary_pt_PT.java | 134 ++ .../sun/text/resources/ro/FormatData_ro.java | 128 +- .../text/resources/ro/FormatData_ro_RO.java | 8 +- .../ro/JavaTimeSupplementary_ro.java | 166 ++ .../sun/text/resources/ru/FormatData_ru.java | 144 +- .../text/resources/ru/FormatData_ru_RU.java | 8 +- .../ru/JavaTimeSupplementary_ru.java | 263 +++ .../sun/text/resources/sk/FormatData_sk.java | 73 +- .../text/resources/sk/FormatData_sk_SK.java | 8 +- .../sk/JavaTimeSupplementary_sk.java | 140 ++ .../sun/text/resources/sl/FormatData_sl.java | 52 +- .../text/resources/sl/FormatData_sl_SI.java | 8 +- .../sl/JavaTimeSupplementary_sl.java | 146 ++ .../sun/text/resources/sq/FormatData_sq.java | 25 +- .../text/resources/sq/FormatData_sq_AL.java | 8 +- .../sq/JavaTimeSupplementary_sq.java | 80 + .../sun/text/resources/sr/FormatData_sr.java | 89 +- .../text/resources/sr/FormatData_sr_BA.java | 29 +- .../text/resources/sr/FormatData_sr_CS.java | 29 +- .../text/resources/sr/FormatData_sr_Latn.java | 35 +- .../resources/sr/FormatData_sr_Latn_ME.java | 7 +- .../text/resources/sr/FormatData_sr_ME.java | 29 +- .../text/resources/sr/FormatData_sr_RS.java | 29 +- .../sr/JavaTimeSupplementary_sr.java | 219 ++ .../sr/JavaTimeSupplementary_sr_Latn.java | 150 ++ .../sun/text/resources/sv/FormatData_sv.java | 142 +- .../text/resources/sv/FormatData_sv_SE.java | 8 +- .../sv/JavaTimeSupplementary_sv.java | 215 ++ .../sun/text/resources/th/FormatData_th.java | 126 +- .../text/resources/th/FormatData_th_TH.java | 8 +- .../th/JavaTimeSupplementary_th.java | 243 +++ .../sun/text/resources/tr/FormatData_tr.java | 185 +- .../text/resources/tr/FormatData_tr_TR.java | 8 +- .../tr/JavaTimeSupplementary_tr.java | 211 ++ .../sun/text/resources/uk/FormatData_uk.java | 58 +- .../text/resources/uk/FormatData_uk_UA.java | 8 +- .../uk/JavaTimeSupplementary_uk.java | 163 ++ .../sun/text/resources/vi/FormatData_vi.java | 100 +- .../text/resources/vi/FormatData_vi_VN.java | 8 +- .../vi/JavaTimeSupplementary_vi.java | 200 ++ .../sun/text/resources/zh/FormatData_zh.java | 163 +- .../text/resources/zh/FormatData_zh_CN.java | 8 +- .../text/resources/zh/FormatData_zh_HK.java | 8 +- .../text/resources/zh/FormatData_zh_SG.java | 29 +- .../text/resources/zh/FormatData_zh_TW.java | 123 +- .../zh/JavaTimeSupplementary_zh.java | 236 +++ .../zh/JavaTimeSupplementary_zh_TW.java | 225 +++ .../classes/sun/util/calendar/ZoneInfo.java | 3 +- .../sun/util/calendar/ZoneInfoFile.java | 556 +++-- .../locale/provider/CalendarDataUtility.java | 22 +- .../provider/CalendarNameProviderImpl.java | 30 +- .../util/locale/provider/LocaleResources.java | 34 +- .../sun/util/resources/LocaleData.java | 82 +- .../resources/OpenListResourceBundle.java | 18 +- .../resources/ParallelListResourceBundle.java | 259 +++ jdk/src/share/lib/calendars.properties | 6 + .../lib/hijrah-config-umalqura.properties | 58 + .../tck/java/time/AbstractDateTimeTest.java | 37 +- .../java/time/tck/java/time/TCKClock.java | 6 +- .../java/time/tck/java/time/TCKDayOfWeek.java | 46 +- .../java/time/tck/java/time/TCKDuration.java | 751 +++++-- .../java/time/tck/java/time/TCKInstant.java | 273 ++- .../java/time/tck/java/time/TCKLocalDate.java | 622 +++--- .../time/tck/java/time/TCKLocalDateTime.java | 845 +++++--- .../java/time/tck/java/time/TCKLocalTime.java | 503 +++-- .../java/time/tck/java/time/TCKMonth.java | 55 +- .../java/time/tck/java/time/TCKMonthDay.java | 175 +- .../time/tck/java/time/TCKOffsetDateTime.java | 346 ++-- .../time/tck/java/time/TCKOffsetTime.java | 299 +-- .../java/time/tck/java/time/TCKPeriod.java | 230 +++ jdk/test/java/time/tck/java/time/TCKYear.java | 318 ++- .../java/time/tck/java/time/TCKYearMonth.java | 382 ++-- .../java/time/tck/java/time/TCKZoneId.java | 290 ++- .../time/tck/java/time/TCKZoneOffset.java | 95 +- .../time/tck/java/time/TCKZonedDateTime.java | 697 ++++--- .../time/tck/java/time/TestChronology.java | 192 -- .../time/tck/java/time/TestIsoChronology.java | 65 +- .../java/time/chrono/CopticChronology.java | 28 +- .../time/tck/java/time/chrono/CopticDate.java | 11 +- .../time/tck/java/time/chrono/CopticEra.java | 19 +- ...LocalDate.java => TCKChronoLocalDate.java} | 76 +- .../TCKChronoLocalDateTime.java} | 77 +- .../TCKChronoZonedDateTime.java} | 72 +- .../tck/java/time/chrono/TCKChronology.java | 347 ++-- .../chrono/TCKChronologySerialization.java | 135 ++ ...ronology.java => TCKHijrahChronology.java} | 211 +- .../tck/java/time/chrono/TCKHijrahEra.java | 115 ++ .../java/time/chrono/TCKIsoChronology.java | 679 +++++++ .../time/tck/java/time/chrono/TCKIsoEra.java | 116 ++ ...nology.java => TCKJapaneseChronology.java} | 271 ++- .../tck/java/time/chrono/TCKJapaneseEra.java | 122 ++ .../java/time/chrono/TCKMinguoChronology.java | 523 +++++ .../tck/java/time/chrono/TCKMinguoEra.java | 121 ++ .../time/chrono/TCKTestServiceLoader.java | 26 +- ...gy.java => TCKThaiBuddhistChronology.java} | 172 +- .../java/time/chrono/TCKThaiBuddhistEra.java | 120 ++ .../time/chrono/TestChronoLocalDateTime.java | 470 ----- .../time/chrono/TestMinguoChronology.java | 325 --- .../time/format/TCKChronoPrinterParser.java | 6 +- .../time/format/TCKDateTimeFormatSymbols.java | 38 +- .../time/format/TCKDateTimeFormatter.java | 276 ++- .../format/TCKDateTimeFormatterBuilder.java | 108 +- .../time/format/TCKDateTimeFormatters.java | 274 ++- .../time/format/TCKDateTimeParseResolver.java | 522 +++++ .../time/format/TCKDateTimeTextPrinting.java | 28 +- .../time/format/TCKLocalizedFieldParser.java | 89 +- .../time/format/TCKLocalizedFieldPrinter.java | 46 +- .../format/TCKLocalizedPrinterParser.java | 1 - .../time/format/TCKOffsetPrinterParser.java | 108 +- .../java/time/format/TCKTextStyle.java} | 62 +- .../time/format/TCKZoneIdPrinterParser.java | 32 +- .../tck/java/time/temporal/TCKIsoFields.java | 206 +- .../java/time/temporal/TCKJulianFields.java | 34 +- ...justers.java => TCKTemporalAdjusters.java} | 186 +- .../tck/java/time/temporal/TCKWeekFields.java | 237 ++- .../time/temporal/TestChronoLocalDate.java | 503 ----- .../tck/java/time/zone/TCKFixedZoneRules.java | 33 +- .../time/zone/TCKZoneOffsetTransition.java | 35 +- .../zone/TCKZoneOffsetTransitionRule.java | 76 +- .../time/tck/java/time/zone/TCKZoneRules.java | 5 +- .../java/time/zone/TCKZoneRulesProvider.java | 14 +- .../time/test/java/time/MockSimplePeriod.java | 7 +- .../time/test/java/time/TestClock_System.java | 5 +- .../time/test/java/time/TestDuration.java | 40 +- .../time/test/java/time/TestLocalDate.java | 46 +- .../test/java/time/TestLocalDateTime.java | 124 +- .../time/test/java/time/TestLocalTime.java | 26 +- .../time/test/java/time/TestMonthDay.java | 10 +- .../test/java/time/TestOffsetDateTime.java | 64 +- .../time/TestOffsetDateTime_instants.java | 7 +- .../java/time/test/java/time/TestPeriod.java | 2 + .../java/time/test/java/time/TestZoneId.java | 59 +- .../java/time/chrono/TestChronoLocalDate.java | 233 +++ .../java/time/chrono/TestChronologyPerf.java | 48 + .../java/time/chrono/TestExampleCode.java | 34 +- .../java/time/chrono/TestIsoChronoImpl.java | 47 +- .../TestJapaneseChronoImpl.java | 15 +- .../java/time/chrono/TestServiceLoader.java | 5 +- .../TestThaiBuddhistChronoImpl.java | 18 +- .../time/chrono/TestUmmAlQuraChronology.java | 225 +++ .../format/AbstractTestPrinterParser.java | 20 +- .../format/MockIOExceptionAppendable.java | 2 - .../time/format/TestCharLiteralParser.java | 8 +- .../time/format/TestCharLiteralPrinter.java | 4 +- .../format/TestDateTimeFormatSymbols.java | 7 +- .../time/format/TestDateTimeFormatter.java | 15 +- .../format/TestDateTimeFormatterBuilder.java | 127 +- .../time/format/TestDateTimeTextProvider.java | 9 +- .../format/TestFractionPrinterParser.java | 2 +- .../java/time/format/TestNonIsoFormatter.java | 99 +- .../java/time/format/TestNumberParser.java | 28 +- .../time/format/TestPadPrinterDecorator.java | 2 +- .../java/time/format/TestReducedParser.java | 2 +- .../java/time/format/TestReducedPrinter.java | 7 +- .../java/time/format/TestSettingsParser.java | 2 +- .../time/format/TestStringLiteralParser.java | 8 +- .../time/format/TestStringLiteralPrinter.java | 4 +- .../test/java/time/format/TestTextParser.java | 103 +- .../java/time/format/TestTextPrinter.java | 87 +- .../time/format/TestZoneOffsetParser.java | 2 +- .../time/format/TestZoneOffsetPrinter.java | 2 +- .../format/TestZoneTextPrinterParser.java | 47 +- .../time/test/java/time/format/ZoneName.java | 3 - .../java/time/temporal/MockFieldValue.java | 11 +- .../java/time/temporal/TestChronoField.java | 159 ++ .../java/time/temporal/TestChronoUnit.java | 36 +- .../TestDateTimeBuilderCombinations.java | 10 +- .../time/temporal/TestDateTimeValueRange.java | 39 +- .../java/time/zone/TestFixedZoneRules.java | 2 +- .../time/test/java/util/TestFormatter.java | 2 +- jdk/test/java/util/Calendar/Bug8007038.java | 2 +- .../util/Calendar/CldrFormatNamesTest.java | 12 +- jdk/test/java/util/Calendar/JavatimeTest.java | 9 +- jdk/test/sun/text/resources/LocaleData | 1134 ----------- .../sun/util/calendar/zi/TestZoneInfo310.java | 42 +- 405 files changed, 31145 insertions(+), 14572 deletions(-) delete mode 100644 jdk/src/share/classes/java/time/chrono/HijrahDeviationReader.java delete mode 100644 jdk/src/share/classes/java/time/format/DateTimeBuilder.java delete mode 100644 jdk/src/share/classes/java/time/format/DateTimeFormatStyleProvider.java create mode 100644 jdk/src/share/classes/java/time/format/Parsed.java create mode 100644 jdk/src/share/classes/java/time/format/ResolverStyle.java delete mode 100644 jdk/src/share/classes/java/time/temporal/Queries.java rename jdk/src/share/classes/java/time/temporal/{Adjusters.java => TemporalAdjusters.java} (70%) create mode 100644 jdk/src/share/classes/java/time/temporal/TemporalQueries.java create mode 100644 jdk/src/share/classes/java/time/temporal/UnsupportedTemporalTypeException.java create mode 100644 jdk/src/share/classes/sun/text/resources/JavaTimeSupplementary.java create mode 100644 jdk/src/share/classes/sun/text/resources/ar/JavaTimeSupplementary_ar.java create mode 100644 jdk/src/share/classes/sun/text/resources/be/JavaTimeSupplementary_be.java create mode 100644 jdk/src/share/classes/sun/text/resources/bg/JavaTimeSupplementary_bg.java create mode 100644 jdk/src/share/classes/sun/text/resources/ca/JavaTimeSupplementary_ca.java create mode 100644 jdk/src/share/classes/sun/text/resources/cs/JavaTimeSupplementary_cs.java create mode 100644 jdk/src/share/classes/sun/text/resources/da/JavaTimeSupplementary_da.java create mode 100644 jdk/src/share/classes/sun/text/resources/de/JavaTimeSupplementary_de.java create mode 100644 jdk/src/share/classes/sun/text/resources/el/JavaTimeSupplementary_el.java create mode 100644 jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en.java create mode 100644 jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en_GB.java create mode 100644 jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en_SG.java create mode 100644 jdk/src/share/classes/sun/text/resources/es/JavaTimeSupplementary_es.java create mode 100644 jdk/src/share/classes/sun/text/resources/et/JavaTimeSupplementary_et.java create mode 100644 jdk/src/share/classes/sun/text/resources/fi/JavaTimeSupplementary_fi.java create mode 100644 jdk/src/share/classes/sun/text/resources/fr/JavaTimeSupplementary_fr.java create mode 100644 jdk/src/share/classes/sun/text/resources/ga/JavaTimeSupplementary_ga.java create mode 100644 jdk/src/share/classes/sun/text/resources/hi/JavaTimeSupplementary_hi_IN.java create mode 100644 jdk/src/share/classes/sun/text/resources/hr/JavaTimeSupplementary_hr.java create mode 100644 jdk/src/share/classes/sun/text/resources/hu/JavaTimeSupplementary_hu.java create mode 100644 jdk/src/share/classes/sun/text/resources/is/JavaTimeSupplementary_is.java create mode 100644 jdk/src/share/classes/sun/text/resources/it/JavaTimeSupplementary_it.java create mode 100644 jdk/src/share/classes/sun/text/resources/iw/JavaTimeSupplementary_iw.java create mode 100644 jdk/src/share/classes/sun/text/resources/iw/JavaTimeSupplementary_iw_IL.java create mode 100644 jdk/src/share/classes/sun/text/resources/ja/JavaTimeSupplementary_ja.java create mode 100644 jdk/src/share/classes/sun/text/resources/ko/JavaTimeSupplementary_ko.java create mode 100644 jdk/src/share/classes/sun/text/resources/lt/JavaTimeSupplementary_lt.java create mode 100644 jdk/src/share/classes/sun/text/resources/lv/JavaTimeSupplementary_lv.java create mode 100644 jdk/src/share/classes/sun/text/resources/mk/JavaTimeSupplementary_mk.java create mode 100644 jdk/src/share/classes/sun/text/resources/ms/JavaTimeSupplementary_ms.java create mode 100644 jdk/src/share/classes/sun/text/resources/mt/JavaTimeSupplementary_mt.java create mode 100644 jdk/src/share/classes/sun/text/resources/nl/JavaTimeSupplementary_nl.java create mode 100644 jdk/src/share/classes/sun/text/resources/no/JavaTimeSupplementary_no.java create mode 100644 jdk/src/share/classes/sun/text/resources/pl/JavaTimeSupplementary_pl.java create mode 100644 jdk/src/share/classes/sun/text/resources/pt/JavaTimeSupplementary_pt.java create mode 100644 jdk/src/share/classes/sun/text/resources/pt/JavaTimeSupplementary_pt_PT.java create mode 100644 jdk/src/share/classes/sun/text/resources/ro/JavaTimeSupplementary_ro.java create mode 100644 jdk/src/share/classes/sun/text/resources/ru/JavaTimeSupplementary_ru.java create mode 100644 jdk/src/share/classes/sun/text/resources/sk/JavaTimeSupplementary_sk.java create mode 100644 jdk/src/share/classes/sun/text/resources/sl/JavaTimeSupplementary_sl.java create mode 100644 jdk/src/share/classes/sun/text/resources/sq/JavaTimeSupplementary_sq.java create mode 100644 jdk/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr.java create mode 100644 jdk/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr_Latn.java create mode 100644 jdk/src/share/classes/sun/text/resources/sv/JavaTimeSupplementary_sv.java create mode 100644 jdk/src/share/classes/sun/text/resources/th/JavaTimeSupplementary_th.java create mode 100644 jdk/src/share/classes/sun/text/resources/tr/JavaTimeSupplementary_tr.java create mode 100644 jdk/src/share/classes/sun/text/resources/uk/JavaTimeSupplementary_uk.java create mode 100644 jdk/src/share/classes/sun/text/resources/vi/JavaTimeSupplementary_vi.java create mode 100644 jdk/src/share/classes/sun/text/resources/zh/JavaTimeSupplementary_zh.java create mode 100644 jdk/src/share/classes/sun/text/resources/zh/JavaTimeSupplementary_zh_TW.java create mode 100644 jdk/src/share/classes/sun/util/resources/ParallelListResourceBundle.java create mode 100644 jdk/src/share/lib/hijrah-config-umalqura.properties delete mode 100644 jdk/test/java/time/tck/java/time/TestChronology.java rename jdk/test/java/time/tck/java/time/chrono/{TestChronoLocalDate.java => TCKChronoLocalDate.java} (89%) rename jdk/test/java/time/tck/java/time/{temporal/TestChronoLocalDateTime.java => chrono/TCKChronoLocalDateTime.java} (89%) rename jdk/test/java/time/tck/java/time/{temporal/TestChronoZonedDateTime.java => chrono/TCKChronoZonedDateTime.java} (90%) create mode 100644 jdk/test/java/time/tck/java/time/chrono/TCKChronologySerialization.java rename jdk/test/java/time/tck/java/time/chrono/{TestHijrahChronology.java => TCKHijrahChronology.java} (51%) create mode 100644 jdk/test/java/time/tck/java/time/chrono/TCKHijrahEra.java create mode 100644 jdk/test/java/time/tck/java/time/chrono/TCKIsoChronology.java create mode 100644 jdk/test/java/time/tck/java/time/chrono/TCKIsoEra.java rename jdk/test/java/time/tck/java/time/chrono/{TestJapaneseChronology.java => TCKJapaneseChronology.java} (60%) create mode 100644 jdk/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java create mode 100644 jdk/test/java/time/tck/java/time/chrono/TCKMinguoChronology.java create mode 100644 jdk/test/java/time/tck/java/time/chrono/TCKMinguoEra.java rename jdk/test/java/time/tck/java/time/chrono/{TestThaiBuddhistChronology.java => TCKThaiBuddhistChronology.java} (75%) create mode 100644 jdk/test/java/time/tck/java/time/chrono/TCKThaiBuddhistEra.java delete mode 100644 jdk/test/java/time/tck/java/time/chrono/TestChronoLocalDateTime.java delete mode 100644 jdk/test/java/time/tck/java/time/chrono/TestMinguoChronology.java create mode 100644 jdk/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java rename jdk/test/java/time/{test/java/time/temporal/TestDateTimeAdjusters.java => tck/java/time/format/TCKTextStyle.java} (63%) rename jdk/test/java/time/tck/java/time/temporal/{TCKDateTimeAdjusters.java => TCKTemporalAdjusters.java} (80%) delete mode 100644 jdk/test/java/time/tck/java/time/temporal/TestChronoLocalDate.java create mode 100644 jdk/test/java/time/test/java/time/chrono/TestChronoLocalDate.java create mode 100644 jdk/test/java/time/test/java/time/chrono/TestChronologyPerf.java rename jdk/test/java/time/test/java/time/{temporal => chrono}/TestJapaneseChronoImpl.java (97%) rename jdk/test/java/time/test/java/time/{temporal => chrono}/TestThaiBuddhistChronoImpl.java (97%) create mode 100644 jdk/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java create mode 100644 jdk/test/java/time/test/java/time/temporal/TestChronoField.java diff --git a/jdk/make/java/java/Makefile b/jdk/make/java/java/Makefile index 54f4dbdebfa..2fe764112fe 100644 --- a/jdk/make/java/java/Makefile +++ b/jdk/make/java/java/Makefile @@ -312,6 +312,12 @@ PROPS = content-types.properties # CAL_PROPS = calendars.properties +# +# Rule to copy Hijrah-umalqura calendar properties file. +# +HIJRAH_UMALQURA_PROPS = hijrah-config-umalqura.properties + + # # Rule to copy tzmappings file on Windows # @@ -324,7 +330,7 @@ $(TZMAP): $(TZMAPFILE) $(call chmod-file, 444) endif -build: $(LIBDIR)/$(PROPS) $(LIBDIR)/$(CAL_PROPS) $(TZMAP) +build: $(LIBDIR)/$(PROPS) $(LIBDIR)/$(CAL_PROPS) $(LIBDIR)/$(HIJRAH_UMALQURA_PROPS) $(TZMAP) $(LIBDIR)/$(PROPS): $(PLATFORM_SRC)/lib/$(PROPS) $(install-file) @@ -332,6 +338,9 @@ $(LIBDIR)/$(PROPS): $(PLATFORM_SRC)/lib/$(PROPS) $(LIBDIR)/$(CAL_PROPS): $(SHARE_SRC)/lib/$(CAL_PROPS) $(install-file) +$(LIBDIR)/$(HIJRAH_UMALQURA_PROPS): $(SHARE_SRC)/lib/$(HIJRAH_UMALQURA_PROPS) + $(install-file) + clean:: $(RM) -r $(LIBDIR)/$(PROPS) $(TZMAP) diff --git a/jdk/make/java/text/base/FILES_java.gmk b/jdk/make/java/text/base/FILES_java.gmk index dc1d9df0b45..c2e0f479c6b 100644 --- a/jdk/make/java/text/base/FILES_java.gmk +++ b/jdk/make/java/text/base/FILES_java.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1996, 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 @@ -105,5 +105,7 @@ FILES_java = \ sun/text/resources/CollationData.java \ \ sun/text/resources/FormatData.java \ + sun/text/resources/JavaTimeSupplementary.java \ sun/text/resources/en/FormatData_en.java \ - sun/text/resources/en/FormatData_en_US.java + sun/text/resources/en/FormatData_en_US.java \ + sun/text/resources/en/JavaTimeSupplementary_en.java \ diff --git a/jdk/make/java/util/FILES_java.gmk b/jdk/make/java/util/FILES_java.gmk index 9b0209a80db..677a97c52cb 100644 --- a/jdk/make/java/util/FILES_java.gmk +++ b/jdk/make/java/util/FILES_java.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 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 @@ -26,6 +26,7 @@ FILES_java = \ sun/util/resources/LocaleData.java \ sun/util/resources/OpenListResourceBundle.java \ + sun/util/resources/ParallelListResourceBundle.java \ sun/util/resources/LocaleNamesBundle.java \ sun/util/resources/TimeZoneNamesBundle.java \ sun/util/resources/TimeZoneNames.java \ diff --git a/jdk/make/sun/text/FILES_java.gmk b/jdk/make/sun/text/FILES_java.gmk index 7f2623188a4..2f15ec33612 100644 --- a/jdk/make/sun/text/FILES_java.gmk +++ b/jdk/make/sun/text/FILES_java.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 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 @@ -227,5 +227,54 @@ FILES_java = \ sun/util/resources/sv/TimeZoneNames_sv.java \ sun/util/resources/zh/TimeZoneNames_zh_CN.java \ sun/util/resources/zh/TimeZoneNames_zh_TW.java \ - sun/util/resources/zh/TimeZoneNames_zh_HK.java + sun/util/resources/zh/TimeZoneNames_zh_HK.java \ + \ + sun/text/resources/ar/JavaTimeSupplementary_ar.java \ + sun/text/resources/be/JavaTimeSupplementary_be.java \ + sun/text/resources/bg/JavaTimeSupplementary_bg.java \ + sun/text/resources/ca/JavaTimeSupplementary_ca.java \ + sun/text/resources/cs/JavaTimeSupplementary_cs.java \ + sun/text/resources/da/JavaTimeSupplementary_da.java \ + sun/text/resources/de/JavaTimeSupplementary_de.java \ + sun/text/resources/el/JavaTimeSupplementary_el.java \ + sun/text/resources/en/JavaTimeSupplementary_en_GB.java \ + sun/text/resources/en/JavaTimeSupplementary_en_SG.java \ + sun/text/resources/es/JavaTimeSupplementary_es.java \ + sun/text/resources/et/JavaTimeSupplementary_et.java \ + sun/text/resources/fi/JavaTimeSupplementary_fi.java \ + sun/text/resources/fr/JavaTimeSupplementary_fr.java \ + sun/text/resources/ga/JavaTimeSupplementary_ga.java \ + sun/text/resources/hi/JavaTimeSupplementary_hi_IN.java \ + sun/text/resources/hr/JavaTimeSupplementary_hr.java \ + sun/text/resources/hu/JavaTimeSupplementary_hu.java \ + sun/text/resources/is/JavaTimeSupplementary_is.java \ + sun/text/resources/it/JavaTimeSupplementary_it.java \ + sun/text/resources/iw/JavaTimeSupplementary_iw.java \ + sun/text/resources/iw/JavaTimeSupplementary_iw_IL.java \ + sun/text/resources/ja/JavaTimeSupplementary_ja.java \ + sun/text/resources/ko/JavaTimeSupplementary_ko.java \ + sun/text/resources/lt/JavaTimeSupplementary_lt.java \ + sun/text/resources/lv/JavaTimeSupplementary_lv.java \ + sun/text/resources/mk/JavaTimeSupplementary_mk.java \ + sun/text/resources/ms/JavaTimeSupplementary_ms.java \ + sun/text/resources/mt/JavaTimeSupplementary_mt.java \ + sun/text/resources/nl/JavaTimeSupplementary_nl.java \ + sun/text/resources/no/JavaTimeSupplementary_no.java \ + sun/text/resources/pl/JavaTimeSupplementary_pl.java \ + sun/text/resources/pt/JavaTimeSupplementary_pt.java \ + sun/text/resources/pt/JavaTimeSupplementary_pt_PT.java \ + sun/text/resources/ro/JavaTimeSupplementary_ro.java \ + sun/text/resources/ru/JavaTimeSupplementary_ru.java \ + sun/text/resources/sk/JavaTimeSupplementary_sk.java \ + sun/text/resources/sl/JavaTimeSupplementary_sl.java \ + sun/text/resources/sq/JavaTimeSupplementary_sq.java \ + sun/text/resources/sr/JavaTimeSupplementary_sr.java \ + sun/text/resources/sr/JavaTimeSupplementary_sr_Latn.java \ + sun/text/resources/sv/JavaTimeSupplementary_sv.java \ + sun/text/resources/th/JavaTimeSupplementary_th.java \ + sun/text/resources/tr/JavaTimeSupplementary_tr.java \ + sun/text/resources/uk/JavaTimeSupplementary_uk.java \ + sun/text/resources/vi/JavaTimeSupplementary_vi.java \ + sun/text/resources/zh/JavaTimeSupplementary_zh.java \ + sun/text/resources/zh/JavaTimeSupplementary_zh_TW.java diff --git a/jdk/make/sun/tzdb/Makefile b/jdk/make/sun/tzdb/Makefile index 14fd87a5e69..03e904818cf 100644 --- a/jdk/make/sun/tzdb/Makefile +++ b/jdk/make/sun/tzdb/Makefile @@ -42,7 +42,6 @@ BUILD_MANIFEST=true # Time zone data file creation # TZDATA_DIR := ../javazic/tzdata -TZDATA_VER := $(subst tzdata,,$(shell $(GREP) '^tzdata' $(TZDATA_DIR)/VERSION)) TZFILE := \ africa antarctica asia australasia europe northamerica \ pacificnew southamerica backward etcetera \ @@ -50,9 +49,7 @@ TZFILE := \ TZFILES := $(addprefix $(TZDATA_DIR)/,$(TZFILE)) - - -TZDB_JAR = tzdb.jar +TZDB_DAT = $(LIBDIR)/tzdb.dat # # Rules @@ -62,13 +59,12 @@ include $(BUILDDIR)/common/Classes.gmk # # Add to the build rule # -build: $(LIBDIR)/$(TZDB_JAR) +build: $(TZDB_DAT) -$(LIBDIR)/$(TZDB_JAR): $(TZFILES) +$(TZDB_DAT): $(TZFILES) $(prep-target) - echo build tzdb from version $(TZDATA_VER) $(BOOT_JAVA_CMD) -jar $(BUILDTOOLJARDIR)/tzdb.jar \ - -version $(TZDATA_VER) -srcdir $(TZDATA_DIR) -dstdir $(LIBDIR) $(TZFILE) + -srcdir $(TZDATA_DIR) -dstfile $(TZDB_DAT) $(TZFILE) clean clobber:: - $(RM) $(LIBDIR)/$(TZDB_JAR) + $(RM) $(TZDB_DAT) diff --git a/jdk/make/tools/src/build/tools/cldrconverter/AbstractLDMLHandler.java b/jdk/make/tools/src/build/tools/cldrconverter/AbstractLDMLHandler.java index 43c7bd8f11a..fd974809fa9 100644 --- a/jdk/make/tools/src/build/tools/cldrconverter/AbstractLDMLHandler.java +++ b/jdk/make/tools/src/build/tools/cldrconverter/AbstractLDMLHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -25,6 +25,7 @@ package build.tools.cldrconverter; +import build.tools.cldrconverter.CLDRConverter.DraftType; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -88,7 +89,7 @@ abstract class AbstractLDMLHandler extends DefaultHandler { } String draftValue = attributes.getValue("draft"); if (draftValue != null) { - return CLDRConverter.draftType > CLDRConverter.DRAFT_MAP.get(draftValue); + return DraftType.getDefault().ordinal() > DraftType.forKeyword(draftValue).ordinal(); } return false; } diff --git a/jdk/make/tools/src/build/tools/cldrconverter/Bundle.java b/jdk/make/tools/src/build/tools/cldrconverter/Bundle.java index fbd95f32226..4bb55d0687c 100644 --- a/jdk/make/tools/src/build/tools/cldrconverter/Bundle.java +++ b/jdk/make/tools/src/build/tools/cldrconverter/Bundle.java @@ -266,6 +266,9 @@ class Bundle { handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "DayNarrows"); handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "AmPmMarkers"); handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "narrow.AmPmMarkers"); + handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "QuarterNames"); + handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "QuarterAbbreviations"); + handleMultipleInheritance(myMap, parentsMap, calendarPrefix + "QuarterNarrows"); adjustEraNames(myMap, calendarType); @@ -484,25 +487,33 @@ class Bundle { for (String k : patternKeys) { if (myMap.containsKey(calendarPrefix + k)) { int len = patternKeys.length; - List rawPatterns = new ArrayList<>(); - List patterns = new ArrayList<>(); + List rawPatterns = new ArrayList<>(len); + List patterns = new ArrayList<>(len); for (int i = 0; i < len; i++) { String key = calendarPrefix + patternKeys[i]; String pattern = (String) myMap.remove(key); if (pattern == null) { pattern = (String) parentsMap.remove(key); } + rawPatterns.add(i, pattern); if (pattern != null) { - rawPatterns.add(i, pattern); patterns.add(i, translateDateFormatLetters(calendarType, pattern)); + } else { + patterns.add(i, null); } } + // If patterns is empty or has any nulls, discard patterns. if (patterns.isEmpty()) { return; } + for (String p : patterns) { + if (p == null) { + return; + } + } String key = calendarPrefix + name; if (!rawPatterns.equals(patterns)) { - myMap.put("cldr." + key, rawPatterns.toArray(new String[len])); + myMap.put("java.time." + key, rawPatterns.toArray(new String[len])); } myMap.put(key, patterns.toArray(new String[len])); break; diff --git a/jdk/make/tools/src/build/tools/cldrconverter/CLDRConverter.java b/jdk/make/tools/src/build/tools/cldrconverter/CLDRConverter.java index 069afb84d1f..f1185f18978 100644 --- a/jdk/make/tools/src/build/tools/cldrconverter/CLDRConverter.java +++ b/jdk/make/tools/src/build/tools/cldrconverter/CLDRConverter.java @@ -68,25 +68,43 @@ public class CLDRConverter { static MetaZonesParseHandler handlerMetaZones; private static BundleGenerator bundleGenerator; - static int draftType; - private static final String DRAFT_UNCONFIRMED = "unconfirmed"; - private static final String DRAFT_PROVISIONAL = "provisional"; - private static final String DRAFT_CONTRIBUTED = "contributed"; - private static final String DRAFT_APPROVED = "approved"; - private static final String DRAFT_TRUE = "true"; - private static final String DRAFT_FALSE = "false"; - private static final String DRAFT_DEFAULT = DRAFT_APPROVED; - static final Map DRAFT_MAP = new HashMap<>(); + static enum DraftType { + UNCONFIRMED, + PROVISIONAL, + CONTRIBUTED, + APPROVED; - static { - DRAFT_MAP.put(DRAFT_UNCONFIRMED, 0); - DRAFT_MAP.put(DRAFT_PROVISIONAL, 1); - DRAFT_MAP.put(DRAFT_CONTRIBUTED, 2); - DRAFT_MAP.put(DRAFT_APPROVED, 3); - DRAFT_MAP.put(DRAFT_TRUE, 0); - DRAFT_MAP.put(DRAFT_FALSE, 2); - draftType = DRAFT_MAP.get(DRAFT_DEFAULT); - }; + private static final Map map = new HashMap<>(); + static { + for (DraftType dt : values()) { + map.put(dt.getKeyword(), dt); + } + } + static private DraftType defaultType = CONTRIBUTED; + + private final String keyword; + + private DraftType() { + keyword = this.name().toLowerCase(Locale.ROOT); + + } + + static DraftType forKeyword(String keyword) { + return map.get(keyword); + } + + static DraftType getDefault() { + return defaultType; + } + + static void setDefault(String keyword) { + defaultType = Objects.requireNonNull(forKeyword(keyword)); + } + + String getKeyword() { + return keyword; + } + } static boolean USE_UTF8 = false; private static boolean verbose; @@ -106,7 +124,7 @@ public class CLDRConverter { case "-draft": String draftDataType = args[++i]; try { - draftType = DRAFT_MAP.get(draftDataType); + DraftType.setDefault(draftDataType); } catch (NullPointerException e) { severe("Error: incorrect draft value: %s%n", draftDataType); System.exit(1); @@ -525,7 +543,7 @@ public class CLDRConverter { "standalone.MonthNames", "MonthAbbreviations", "standalone.MonthAbbreviations", - "MonthNarrow", + "MonthNarrows", "standalone.MonthNarrows", "DayNames", "standalone.DayNames", @@ -533,6 +551,12 @@ public class CLDRConverter { "standalone.DayAbbreviations", "DayNarrows", "standalone.DayNarrows", + "QuarterNames", + "standalone.QuarterNames", + "QuarterAbbreviations", + "standalone.QuarterAbbreviations", + "QuarterNarrows", + "standalone.QuarterNarrows", "AmPmMarkers", "narrow.AmPmMarkers", "long.Eras", @@ -560,7 +584,7 @@ public class CLDRConverter { String prefix = calendarType.keyElementName(); for (String element : FORMAT_DATA_ELEMENTS) { String key = prefix + element; - copyIfPresent(map, "cldr." + key, formatData); + copyIfPresent(map, "java.time." + key, formatData); copyIfPresent(map, key, formatData); } } diff --git a/jdk/make/tools/src/build/tools/cldrconverter/LDMLParseHandler.java b/jdk/make/tools/src/build/tools/cldrconverter/LDMLParseHandler.java index 695312408f8..7deae4e6845 100644 --- a/jdk/make/tools/src/build/tools/cldrconverter/LDMLParseHandler.java +++ b/jdk/make/tools/src/build/tools/cldrconverter/LDMLParseHandler.java @@ -356,6 +356,44 @@ class LDMLParseHandler extends AbstractLDMLHandler { } } break; + case "quarterContext": + { + // for FormatData + // need to keep stand-alone and format, to allow for inheritance in CLDR + String type = attributes.getValue("type"); + if ("stand-alone".equals(type) || "format".equals(type)) { + pushKeyContainer(qName, attributes, type); + } else { + pushIgnoredContainer(qName); + } + } + break; + case "quarterWidth": + { + // for FormatData + // keep info about the context type so we can sort out inheritance later + String prefix = (currentCalendarType == null) ? "" : currentCalendarType.keyElementName(); + switch (attributes.getValue("type")) { + case "wide": + pushStringArrayEntry(qName, attributes, prefix + "QuarterNames/" + getContainerKey(), 4); + break; + case "abbreviated": + pushStringArrayEntry(qName, attributes, prefix + "QuarterAbbreviations/" + getContainerKey(), 4); + break; + case "narrow": + pushStringArrayEntry(qName, attributes, prefix + "QuarterNarrows/" + getContainerKey(), 4); + break; + default: + pushIgnoredContainer(qName); + break; + } + } + break; + case "quarter": + // for FormatData + // add to string array entry of quarterWidth element + pushStringArrayElement(qName, attributes, Integer.parseInt(attributes.getValue("type")) - 1); + break; // // Time zone names diff --git a/jdk/make/tools/src/build/tools/tzdb/TzdbZoneRulesCompiler.java b/jdk/make/tools/src/build/tools/tzdb/TzdbZoneRulesCompiler.java index 6f42dd9f600..be0204eeeef 100644 --- a/jdk/make/tools/src/build/tools/tzdb/TzdbZoneRulesCompiler.java +++ b/jdk/make/tools/src/build/tools/tzdb/TzdbZoneRulesCompiler.java @@ -58,12 +58,12 @@ package build.tools.tzdb; import static build.tools.tzdb.Utils.*; -import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.ParsePosition; import java.util.ArrayList; import java.util.Arrays; @@ -71,132 +71,131 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; +import java.util.NoSuchElementException; +import java.util.Scanner; import java.util.SortedMap; -import java.util.StringTokenizer; import java.util.TreeMap; -import java.util.TreeSet; -import java.util.jar.JarOutputStream; -import java.util.zip.ZipEntry; import java.util.regex.Matcher; +import java.util.regex.MatchResult; import java.util.regex.Pattern; /** - * A builder that can read the TZDB time-zone files and build {@code ZoneRules} instances. + * A compiler that reads a set of TZDB time-zone files and builds a single + * combined TZDB data file. * * @since 1.8 */ public final class TzdbZoneRulesCompiler { - private static final Matcher YEAR = Pattern.compile("(?i)(?min)|(?max)|(?only)|(?[0-9]+)").matcher(""); - private static final Matcher MONTH = Pattern.compile("(?i)(jan)|(feb)|(mar)|(apr)|(may)|(jun)|(jul)|(aug)|(sep)|(oct)|(nov)|(dec)").matcher(""); - private static final Matcher DOW = Pattern.compile("(?i)(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)").matcher(""); - private static final Matcher TIME = Pattern.compile("(?-)?+(?[0-9]{1,2})(:(?[0-5][0-9]))?+(:(?[0-5][0-9]))?+").matcher(""); - - /** - * Constant for MJD 1972-01-01. - */ - private static final long MJD_1972_01_01 = 41317L; - - /** - * Reads a set of TZDB files and builds a single combined data file. - * - * @param args the arguments - */ public static void main(String[] args) { + new TzdbZoneRulesCompiler().compile(args); + } + + private void compile(String[] args) { if (args.length < 2) { outputHelp(); return; } - - // parse args + Path srcDir = null; + Path dstFile = null; String version = null; - File baseSrcDir = null; - File dstDir = null; - boolean verbose = false; - - // parse options + // parse args/options int i; for (i = 0; i < args.length; i++) { String arg = args[i]; - if (arg.startsWith("-") == false) { + if (!arg.startsWith("-")) { break; } if ("-srcdir".equals(arg)) { - if (baseSrcDir == null && ++i < args.length) { - baseSrcDir = new File(args[i]); + if (srcDir == null && ++i < args.length) { + srcDir = Paths.get(args[i]); continue; } - } else if ("-dstdir".equals(arg)) { - if (dstDir == null && ++i < args.length) { - dstDir = new File(args[i]); - continue; - } - } else if ("-version".equals(arg)) { - if (version == null && ++i < args.length) { - version = args[i]; + } else if ("-dstfile".equals(arg)) { + if (dstFile == null && ++i < args.length) { + dstFile = Paths.get(args[i]); continue; } } else if ("-verbose".equals(arg)) { - if (verbose == false) { + if (!verbose) { verbose = true; continue; } - } else if ("-help".equals(arg) == false) { + } else if (!"-help".equals(arg)) { System.out.println("Unrecognised option: " + arg); } outputHelp(); return; } - // check source directory - if (baseSrcDir == null) { - System.out.println("Source directory must be specified using -srcdir: " + baseSrcDir); - return; + if (srcDir == null) { + System.err.println("Source directory must be specified using -srcdir"); + System.exit(1); } - if (baseSrcDir.isDirectory() == false) { - System.out.println("Source does not exist or is not a directory: " + baseSrcDir); - return; + if (!Files.isDirectory(srcDir)) { + System.err.println("Source does not exist or is not a directory: " + srcDir); + System.exit(1); } - dstDir = (dstDir != null ? dstDir : baseSrcDir); - // parse source file names - List srcFileNames = Arrays.asList(Arrays.copyOfRange(args, i, args.length)); - if (srcFileNames.isEmpty()) { - System.out.println("Source filenames not specified, using default set"); - System.out.println("(africa antarctica asia australasia backward etcetera europe northamerica southamerica)"); - srcFileNames = Arrays.asList("africa", "antarctica", "asia", "australasia", "backward", - "etcetera", "europe", "northamerica", "southamerica"); + if (i == args.length) { + i = 0; + args = new String[] {"africa", "antarctica", "asia", "australasia", "europe", + "northamerica","southamerica", "backward", "etcetera" }; + System.out.println("Source filenames not specified, using default set ( "); + for (String name : args) { + System.out.printf(name + " "); + } + System.out.println(")"); } - - // find source directories to process - List srcDirs = new ArrayList<>(); - if (version != null) { - // if the "version" specified, as in jdk repo, the "baseSrcDir" is - // the "srcDir" that contains the tzdb data. - srcDirs.add(baseSrcDir); - } else { - File[] dirs = baseSrcDir.listFiles(); - for (File dir : dirs) { - if (dir.isDirectory() && dir.getName().matches("[12][0-9]{3}[A-Za-z0-9._-]+")) { - srcDirs.add(dir); - } + // source files in this directory + List srcFiles = new ArrayList<>(); + for (; i < args.length; i++) { + Path file = srcDir.resolve(args[i]); + if (Files.exists(file)) { + srcFiles.add(file); + } else { + System.err.println("Source directory does not contain source file: " + args[i]); + System.exit(1); } } - if (srcDirs.isEmpty()) { - System.out.println("Source directory contains no valid source folders: " + baseSrcDir); - return; + // check destination file + if (dstFile == null) { + dstFile = srcDir.resolve("tzdb.dat"); + } else { + Path parent = dstFile.getParent(); + if (parent != null && !Files.exists(parent)) { + System.err.println("Destination directory does not exist: " + parent); + System.exit(1); + } } - // check destination directory - if (dstDir.exists() == false && dstDir.mkdirs() == false) { - System.out.println("Destination directory could not be created: " + dstDir); - return; + try { + // get tzdb source version + Matcher m = Pattern.compile("tzdata(?[0-9]{4}[A-z])") + .matcher(new String(Files.readAllBytes(srcDir.resolve("VERSION")), + "ISO-8859-1")); + if (m.find()) { + version = m.group("ver"); + } else { + System.exit(1); + System.err.println("Source directory does not contain file: VERSION"); + } + printVerbose("Compiling TZDB version " + version); + // parse source files + for (Path file : srcFiles) { + printVerbose("Parsing file: " + file); + parseFile(file); + } + // build zone rules + printVerbose("Building rules"); + buildZoneRules(); + // output to file + printVerbose("Outputting tzdb file: " + dstFile); + outputFile(dstFile, version, builtZones, links); + } catch (Exception ex) { + System.out.println("Failed: " + ex.toString()); + ex.printStackTrace(); + System.exit(1); } - if (dstDir.isDirectory() == false) { - System.out.println("Destination is not a directory: " + dstDir); - return; - } - process(srcDirs, srcFileNames, dstDir, version, verbose); System.exit(0); } @@ -206,145 +205,35 @@ public final class TzdbZoneRulesCompiler { private static void outputHelp() { System.out.println("Usage: TzdbZoneRulesCompiler "); System.out.println("where options include:"); - System.out.println(" -srcdir Where to find source directories (required)"); - System.out.println(" -dstdir Where to output generated files (default srcdir)"); - System.out.println(" -version Specify the version, such as 2009a (optional)"); + System.out.println(" -srcdir Where to find tzdb source directory (required)"); + System.out.println(" -dstfile Where to output generated file (default srcdir/tzdb.dat)"); System.out.println(" -help Print this usage message"); System.out.println(" -verbose Output verbose information during compilation"); - System.out.println(" There must be one directory for each version in srcdir"); - System.out.println(" Each directory must have the name of the version, such as 2009a"); - System.out.println(" Each directory must contain the unpacked tzdb files, such as asia or europe"); - System.out.println(" Directories must match the regex [12][0-9][0-9][0-9][A-Za-z0-9._-]+"); - System.out.println(" There will be one jar file for each version and one combined jar in dstdir"); - System.out.println(" If the version is specified, only that version is processed"); - } - - /** - * Process to create the jar files. - */ - private static void process(List srcDirs, List srcFileNames, File dstDir, String version, boolean verbose) { - // build actual jar files - Map> allBuiltZones = new TreeMap<>(); - Set allRegionIds = new TreeSet(); - Set allRules = new HashSet(); - Map> allLinks = new TreeMap<>(); - - for (File srcDir : srcDirs) { - // source files in this directory - List srcFiles = new ArrayList<>(); - for (String srcFileName : srcFileNames) { - File file = new File(srcDir, srcFileName); - if (file.exists()) { - srcFiles.add(file); - } - } - if (srcFiles.isEmpty()) { - continue; // nothing to process - } - - // compile - String loopVersion = (srcDirs.size() == 1 && version != null) - ? version : srcDir.getName(); - TzdbZoneRulesCompiler compiler = new TzdbZoneRulesCompiler(loopVersion, srcFiles, verbose); - try { - // compile - compiler.compile(); - SortedMap builtZones = compiler.getZones(); - - // output version-specific file - File dstFile = version == null ? new File(dstDir, "tzdb" + loopVersion + ".jar") - : new File(dstDir, "tzdb.jar"); - if (verbose) { - System.out.println("Outputting file: " + dstFile); - } - outputFile(dstFile, loopVersion, builtZones, compiler.links); - - // create totals - allBuiltZones.put(loopVersion, builtZones); - allRegionIds.addAll(builtZones.keySet()); - allRules.addAll(builtZones.values()); - allLinks.put(loopVersion, compiler.links); - } catch (Exception ex) { - System.out.println("Failed: " + ex.toString()); - ex.printStackTrace(); - System.exit(1); - } - } - - // output merged file - if (version == null) { - File dstFile = new File(dstDir, "tzdb-all.jar"); - if (verbose) { - System.out.println("Outputting combined file: " + dstFile); - } - outputFile(dstFile, allBuiltZones, allRegionIds, allRules, allLinks); - } + System.out.println(" The source directory must contain the unpacked tzdb files, such as asia or europe"); } /** * Outputs the file. */ - private static void outputFile(File dstFile, - String version, - SortedMap builtZones, - Map links) { - Map> loopAllBuiltZones = new TreeMap<>(); - loopAllBuiltZones.put(version, builtZones); - Set loopAllRegionIds = new TreeSet(builtZones.keySet()); - Set loopAllRules = new HashSet(builtZones.values()); - Map> loopAllLinks = new TreeMap<>(); - loopAllLinks.put(version, links); - outputFile(dstFile, loopAllBuiltZones, loopAllRegionIds, loopAllRules, loopAllLinks); - } - - /** - * Outputs the file. - */ - private static void outputFile(File dstFile, - Map> allBuiltZones, - Set allRegionIds, - Set allRules, - Map> allLinks) { - try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(dstFile))) { - outputTZEntry(jos, allBuiltZones, allRegionIds, allRules, allLinks); - } catch (Exception ex) { - System.out.println("Failed: " + ex.toString()); - ex.printStackTrace(); - System.exit(1); - } - } - - /** - * Outputs the timezone entry in the JAR file. - */ - private static void outputTZEntry(JarOutputStream jos, - Map> allBuiltZones, - Set allRegionIds, - Set allRules, - Map> allLinks) { - // this format is not publicly specified - try { - jos.putNextEntry(new ZipEntry("TZDB.dat")); - DataOutputStream out = new DataOutputStream(jos); - + private void outputFile(Path dstFile, String version, + SortedMap builtZones, + Map links) { + try (DataOutputStream out = new DataOutputStream(Files.newOutputStream(dstFile))) { // file version out.writeByte(1); // group out.writeUTF("TZDB"); // versions - String[] versionArray = allBuiltZones.keySet().toArray(new String[allBuiltZones.size()]); - out.writeShort(versionArray.length); - for (String version : versionArray) { - out.writeUTF(version); - } + out.writeShort(1); + out.writeUTF(version); // regions - String[] regionArray = allRegionIds.toArray(new String[allRegionIds.size()]); + String[] regionArray = builtZones.keySet().toArray(new String[builtZones.size()]); out.writeShort(regionArray.length); for (String regionId : regionArray) { out.writeUTF(regionId); } - // rules - List rulesList = new ArrayList<>(allRules); + // rules -- hashset -> remove the dup + List rulesList = new ArrayList<>(new HashSet<>(builtZones.values())); out.writeShort(rulesList.size()); ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); for (ZoneRules rules : rulesList) { @@ -357,27 +246,22 @@ public final class TzdbZoneRulesCompiler { out.write(bytes); } // link version-region-rules - for (String version : allBuiltZones.keySet()) { - out.writeShort(allBuiltZones.get(version).size()); - for (Map.Entry entry : allBuiltZones.get(version).entrySet()) { - int regionIndex = Arrays.binarySearch(regionArray, entry.getKey()); - int rulesIndex = rulesList.indexOf(entry.getValue()); - out.writeShort(regionIndex); - out.writeShort(rulesIndex); - } + out.writeShort(builtZones.size()); + for (Map.Entry entry : builtZones.entrySet()) { + int regionIndex = Arrays.binarySearch(regionArray, entry.getKey()); + int rulesIndex = rulesList.indexOf(entry.getValue()); + out.writeShort(regionIndex); + out.writeShort(rulesIndex); } // alias-region - for (String version : allLinks.keySet()) { - out.writeShort(allLinks.get(version).size()); - for (Map.Entry entry : allLinks.get(version).entrySet()) { - int aliasIndex = Arrays.binarySearch(regionArray, entry.getKey()); - int regionIndex = Arrays.binarySearch(regionArray, entry.getValue()); - out.writeShort(aliasIndex); - out.writeShort(regionIndex); - } + out.writeShort(links.size()); + for (Map.Entry entry : links.entrySet()) { + int aliasIndex = Arrays.binarySearch(regionArray, entry.getKey()); + int regionIndex = Arrays.binarySearch(regionArray, entry.getValue()); + out.writeShort(aliasIndex); + out.writeShort(regionIndex); } out.flush(); - jos.closeEntry(); } catch (Exception ex) { System.out.println("Failed: " + ex.toString()); ex.printStackTrace(); @@ -385,76 +269,30 @@ public final class TzdbZoneRulesCompiler { } } - //----------------------------------------------------------------------- + private static final Pattern YEAR = Pattern.compile("(?i)(?min)|(?max)|(?only)|(?[0-9]+)"); + private static final Pattern MONTH = Pattern.compile("(?i)(jan)|(feb)|(mar)|(apr)|(may)|(jun)|(jul)|(aug)|(sep)|(oct)|(nov)|(dec)"); + private static final Matcher DOW = Pattern.compile("(?i)(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)").matcher(""); + private static final Matcher TIME = Pattern.compile("(?-)?+(?[0-9]{1,2})(:(?[0-5][0-9]))?+(:(?[0-5][0-9]))?+").matcher(""); + /** The TZDB rules. */ private final Map> rules = new HashMap<>(); /** The TZDB zones. */ private final Map> zones = new HashMap<>(); - /** The TZDB links. */ + /** The TZDB links. */ private final Map links = new HashMap<>(); /** The built zones. */ private final SortedMap builtZones = new TreeMap<>(); - - /** The version to produce. */ - private final String version; - - /** The source files. */ - - private final List sourceFiles; - - /** The version to produce. */ - private final boolean verbose; + /** Whether to output verbose messages. */ + private boolean verbose; /** - * Creates an instance if you want to invoke the compiler manually. - * - * @param version the version, such as 2009a, not null - * @param sourceFiles the list of source files, not empty, not null - * @param verbose whether to output verbose messages + * private contructor */ - public TzdbZoneRulesCompiler(String version, List sourceFiles, boolean verbose) { - this.version = version; - this.sourceFiles = sourceFiles; - this.verbose = verbose; - } - - /** - * Compile the rules file. - *

- * Use {@link #getZones()} to retrieve the parsed data. - * - * @throws Exception if an error occurs - */ - public void compile() throws Exception { - printVerbose("Compiling TZDB version " + version); - parseFiles(); - buildZoneRules(); - printVerbose("Compiled TZDB version " + version); - } - - /** - * Gets the parsed zone rules. - * - * @return the parsed zone rules, not null - */ - public SortedMap getZones() { - return builtZones; - } - - /** - * Parses the source files. - * - * @throws Exception if an error occurs - */ - private void parseFiles() throws Exception { - for (File file : sourceFiles) { - printVerbose("Parsing file: " + file); - parseFile(file); - } + private TzdbZoneRulesCompiler() { } /** @@ -463,14 +301,14 @@ public final class TzdbZoneRulesCompiler { * @param file the file being read, not null * @throws Exception if an error occurs */ - private void parseFile(File file) throws Exception { + private void parseFile(Path file) throws Exception { int lineNumber = 1; String line = null; - BufferedReader in = null; try { - in = new BufferedReader(new FileReader(file)); + List lines = Files.readAllLines(file, StandardCharsets.ISO_8859_1); List openZone = null; - for ( ; (line = in.readLine()) != null; lineNumber++) { + for (; lineNumber < lines.size(); lineNumber++) { + line = lines.get(lineNumber); int index = line.indexOf('#'); // remove comments (doesn't handle # in quotes) if (index >= 0) { line = line.substring(0, index); @@ -478,41 +316,43 @@ public final class TzdbZoneRulesCompiler { if (line.trim().length() == 0) { // ignore blank lines continue; } - StringTokenizer st = new StringTokenizer(line, " \t"); - if (openZone != null && Character.isWhitespace(line.charAt(0)) && st.hasMoreTokens()) { - if (parseZoneLine(st, openZone)) { + Scanner s = new Scanner(line); + if (openZone != null && Character.isWhitespace(line.charAt(0)) && s.hasNext()) { + if (parseZoneLine(s, openZone)) { openZone = null; } } else { - if (st.hasMoreTokens()) { - String first = st.nextToken(); + if (s.hasNext()) { + String first = s.next(); if (first.equals("Zone")) { - if (st.countTokens() < 3) { + openZone = new ArrayList<>(); + try { + zones.put(s.next(), openZone); + if (parseZoneLine(s, openZone)) { + openZone = null; + } + } catch (NoSuchElementException x) { printVerbose("Invalid Zone line in file: " + file + ", line: " + line); throw new IllegalArgumentException("Invalid Zone line"); } - openZone = new ArrayList<>(); - zones.put(st.nextToken(), openZone); - if (parseZoneLine(st, openZone)) { - openZone = null; - } } else { openZone = null; if (first.equals("Rule")) { - if (st.countTokens() < 9) { + try { + parseRuleLine(s); + } catch (NoSuchElementException x) { printVerbose("Invalid Rule line in file: " + file + ", line: " + line); throw new IllegalArgumentException("Invalid Rule line"); } - parseRuleLine(st); - } else if (first.equals("Link")) { - if (st.countTokens() < 2) { + try { + String realId = s.next(); + String aliasId = s.next(); + links.put(aliasId, realId); + } catch (NoSuchElementException x) { printVerbose("Invalid Link line in file: " + file + ", line: " + line); throw new IllegalArgumentException("Invalid Link line"); } - String realId = st.nextToken(); - String aliasId = st.nextToken(); - links.put(aliasId, realId); } else { throw new IllegalArgumentException("Unknown line"); @@ -522,52 +362,44 @@ public final class TzdbZoneRulesCompiler { } } } catch (Exception ex) { - throw new Exception("Failed while processing file '" + file + "' on line " + lineNumber + " '" + line + "'", ex); - } finally { - try { - if (in != null) { - in.close(); - } - } catch (Exception ex) { - // ignore NPE and IOE - } + throw new Exception("Failed while parsing file '" + file + "' on line " + lineNumber + " '" + line + "'", ex); } } /** * Parses a Rule line. * - * @param st the tokenizer, not null + * @param s the line scanner, not null */ - private void parseRuleLine(StringTokenizer st) { + private void parseRuleLine(Scanner s) { TZDBRule rule = new TZDBRule(); - String name = st.nextToken(); + String name = s.next(); if (rules.containsKey(name) == false) { rules.put(name, new ArrayList()); } rules.get(name).add(rule); - rule.startYear = parseYear(st.nextToken(), 0); - rule.endYear = parseYear(st.nextToken(), rule.startYear); + rule.startYear = parseYear(s, 0); + rule.endYear = parseYear(s, rule.startYear); if (rule.startYear > rule.endYear) { throw new IllegalArgumentException("Year order invalid: " + rule.startYear + " > " + rule.endYear); } - parseOptional(st.nextToken()); // type is unused - parseMonthDayTime(st, rule); - rule.savingsAmount = parsePeriod(st.nextToken()); - rule.text = parseOptional(st.nextToken()); + parseOptional(s.next()); // type is unused + parseMonthDayTime(s, rule); + rule.savingsAmount = parsePeriod(s.next()); + rule.text = parseOptional(s.next()); } /** * Parses a Zone line. * - * @param st the tokenizer, not null + * @param s the line scanner, not null * @return true if the zone is complete */ - private boolean parseZoneLine(StringTokenizer st, List zoneList) { + private boolean parseZoneLine(Scanner s, List zoneList) { TZDBZone zone = new TZDBZone(); zoneList.add(zone); - zone.standardOffset = parseOffset(st.nextToken()); - String savingsRule = parseOptional(st.nextToken()); + zone.standardOffset = parseOffset(s.next()); + String savingsRule = parseOptional(s.next()); if (savingsRule == null) { zone.fixedSavingsSecs = 0; zone.savingsRule = null; @@ -580,11 +412,11 @@ public final class TzdbZoneRulesCompiler { zone.savingsRule = savingsRule; } } - zone.text = st.nextToken(); - if (st.hasMoreTokens()) { - zone.year = Integer.parseInt(st.nextToken()); - if (st.hasMoreTokens()) { - parseMonthDayTime(st, zone); + zone.text = s.next(); + if (s.hasNext()) { + zone.year = Integer.parseInt(s.next()); + if (s.hasNext()) { + parseMonthDayTime(s, zone); } return false; } else { @@ -595,13 +427,13 @@ public final class TzdbZoneRulesCompiler { /** * Parses a Rule line. * - * @param st the tokenizer, not null + * @param s the line scanner, not null * @param mdt the object to parse into, not null */ - private void parseMonthDayTime(StringTokenizer st, TZDBMonthDayTime mdt) { - mdt.month = parseMonth(st.nextToken()); - if (st.hasMoreTokens()) { - String dayRule = st.nextToken(); + private void parseMonthDayTime(Scanner s, TZDBMonthDayTime mdt) { + mdt.month = parseMonth(s); + if (s.hasNext()) { + String dayRule = s.next(); if (dayRule.startsWith("last")) { mdt.dayOfMonth = -1; mdt.dayOfWeek = parseDayOfWeek(dayRule.substring(4)); @@ -621,8 +453,8 @@ public final class TzdbZoneRulesCompiler { } mdt.dayOfMonth = Integer.parseInt(dayRule); } - if (st.hasMoreTokens()) { - String timeStr = st.nextToken(); + if (s.hasNext()) { + String timeStr = s.next(); int secsOfDay = parseSecs(timeStr); if (secsOfDay == 86400) { mdt.endOfDay = true; @@ -635,30 +467,43 @@ public final class TzdbZoneRulesCompiler { } } - private int parseYear(String str, int defaultYear) { - if (YEAR.reset(str).matches()) { - if (YEAR.group("min") != null) { - //return YEAR_MIN_VALUE; + private int parseYear(Scanner s, int defaultYear) { + if (s.hasNext(YEAR)) { + s.next(YEAR); + MatchResult mr = s.match(); + if (mr.group(1) != null) { return 1900; // systemv has min - } else if (YEAR.group("max") != null) { + } else if (mr.group(2) != null) { return YEAR_MAX_VALUE; - } else if (YEAR.group("only") != null) { + } else if (mr.group(3) != null) { return defaultYear; } - return Integer.parseInt(YEAR.group("year")); + return Integer.parseInt(mr.group(4)); + /* + if (mr.group("min") != null) { + //return YEAR_MIN_VALUE; + return 1900; // systemv has min + } else if (mr.group("max") != null) { + return YEAR_MAX_VALUE; + } else if (mr.group("only") != null) { + return defaultYear; + } + return Integer.parseInt(mr.group("year")); + */ } - throw new IllegalArgumentException("Unknown year: " + str); + throw new IllegalArgumentException("Unknown year: " + s.next()); } - private int parseMonth(String str) { - if (MONTH.reset(str).matches()) { + private int parseMonth(Scanner s) { + if (s.hasNext(MONTH)) { + s.next(MONTH); for (int moy = 1; moy < 13; moy++) { - if (MONTH.group(moy) != null) { + if (s.match().group(moy) != null) { return moy; } } } - throw new IllegalArgumentException("Unknown month: " + str); + throw new IllegalArgumentException("Unknown month: " + s.next()); } private int parseDayOfWeek(String str) { @@ -729,7 +574,6 @@ public final class TzdbZoneRulesCompiler { } } - //----------------------------------------------------------------------- /** * Build the rules, zones and links into real zones. * @@ -744,8 +588,7 @@ public final class TzdbZoneRulesCompiler { for (TZDBZone tzdbZone : tzdbZones) { bld = tzdbZone.addToBuilder(bld, rules); } - ZoneRules buildRules = bld.toRules(zoneId); - builtZones.put(zoneId, buildRules); + builtZones.put(zoneId, bld.toRules(zoneId)); } // build aliases @@ -758,25 +601,25 @@ public final class TzdbZoneRulesCompiler { printVerbose("Relinking alias " + aliasId + " to " + realId); realRules = builtZones.get(realId); if (realRules == null) { - throw new IllegalArgumentException("Alias '" + aliasId + "' links to invalid zone '" + realId + "' for '" + version + "'"); + throw new IllegalArgumentException("Alias '" + aliasId + "' links to invalid zone '" + realId); } links.put(aliasId, realId); - } builtZones.put(aliasId, realRules); } - // remove UTC and GMT - //builtZones.remove("UTC"); - //builtZones.remove("GMT"); - //builtZones.remove("GMT0"); + // builtZones.remove("UTC"); + // builtZones.remove("GMT"); + // builtZones.remove("GMT0"); builtZones.remove("GMT+0"); builtZones.remove("GMT-0"); links.remove("GMT+0"); links.remove("GMT-0"); + // remove ROC, which is not supported in j.u.tz + builtZones.remove("ROC"); + links.remove("ROC"); } - //----------------------------------------------------------------------- /** * Prints a verbose message. * @@ -788,7 +631,6 @@ public final class TzdbZoneRulesCompiler { } } - //----------------------------------------------------------------------- /** * Class representing a month-day-time in the TZDB file. */ @@ -893,5 +735,4 @@ public final class TzdbZoneRulesCompiler { return ldt; } } - } diff --git a/jdk/makefiles/CopyFiles.gmk b/jdk/makefiles/CopyFiles.gmk index 6b15e677b32..9ed6da26987 100644 --- a/jdk/makefiles/CopyFiles.gmk +++ b/jdk/makefiles/CopyFiles.gmk @@ -174,6 +174,13 @@ $(LIBDIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties COPY_FILES += $(LIBDIR)/calendars.properties +$(LIBDIR)/hijrah-config-umalqura.properties: $(CALENDARS_SRC)/hijrah-config-umalqura.properties + $(MKDIR) -p $(@D) + $(RM) $@ + $(CP) $< $@ + +COPY_FILES += $(LIBDIR)/hijrah-config-umalqura.properties + ########################################################################################## ifeq ($(OPENJDK_TARGET_OS),windows) diff --git a/jdk/makefiles/CreateJars.gmk b/jdk/makefiles/CreateJars.gmk index 523af3dc90f..8127b054459 100644 --- a/jdk/makefiles/CreateJars.gmk +++ b/jdk/makefiles/CreateJars.gmk @@ -73,11 +73,6 @@ $(eval $(call SetupArchive,BUILD_DNS_JAR,,\ ########################################################################################## -$(IMAGES_OUTPUTDIR)/lib/tzdb.jar: $(JDK_OUTPUTDIR)/lib/tzdb.jar - $(install-file) - -########################################################################################## - LOCALEDATA_INCLUDE_LOCALES := ar be bg ca cs da de el es et fi fr ga hi hr hu in is it \ iw ja ko lt lv mk ms mt nl no pl pt ro ru sk sl sq sr sv \ th tr uk vi zh diff --git a/jdk/makefiles/GendataTZDB.gmk b/jdk/makefiles/GendataTZDB.gmk index 51289dd1b6c..802b3e5b30a 100644 --- a/jdk/makefiles/GendataTZDB.gmk +++ b/jdk/makefiles/GendataTZDB.gmk @@ -29,16 +29,13 @@ GENDATA_TZDB := # Time zone data file creation # TZDATA_DIR := $(JDK_TOPDIR)/make/sun/javazic/tzdata -TZDATA_VER := $(subst tzdata,,$(shell $(GREP) '^tzdata' $(TZDATA_DIR)/VERSION)) TZDATA_TZFILE := africa antarctica asia australasia europe northamerica pacificnew southamerica backward etcetera gmt jdk11_backward TZDATA_TZFILES := $(addprefix $(TZDATA_DIR)/,$(TZDATA_TZFILE)) -GENDATA_TZDB_DST := $(JDK_OUTPUTDIR)/lib -GENDATA_TZDB_JAR := tzdb.jar +GENDATA_TZDB_DAT := $(JDK_OUTPUTDIR)/lib/tzdb.dat -$(GENDATA_TZDB_DST)/$(GENDATA_TZDB_JAR) : $(TZDATA_TZFILES) - $(RM) $(GENDATA_TZDB_DST)/$(GENDATA_TZDB_JAR) - echo building tzdb from version $(TZDATA_VER) - $(TOOL_TZDB) -version $(TZDATA_VER) -srcdir $(TZDATA_DIR) -dstdir $(GENDATA_TZDB_DST) $(TZDATA_TZFILE) +$(GENDATA_TZDB_DAT) : $(TZDATA_TZFILES) + $(RM) $(GENDATA_TZDB_DAT) + $(TOOL_TZDB) -srcdir $(TZDATA_DIR) -dstfile $(GENDATA_TZDB_DAT) $(TZDATA_TZFILE) -GENDATA_TZDB += $(GENDATA_TZDB_DST)/$(GENDATA_TZDB_JAR) +GENDATA_TZDB += $(GENDATA_TZDB_DAT) diff --git a/jdk/makefiles/profile-includes.txt b/jdk/makefiles/profile-includes.txt index 17e554f4223..0a6ada9ae15 100644 --- a/jdk/makefiles/profile-includes.txt +++ b/jdk/makefiles/profile-includes.txt @@ -80,7 +80,7 @@ PROFILE_1_JRE_LIB_FILES := \ security/java.security \ security/local_policy.jar \ security/trusted.libraries \ - tzdb.jar + tzdb.dat PROFILE_1_JRE_OTHER_FILES := \ COPYRIGHT \ @@ -100,9 +100,7 @@ PROFILE_1_JRE_JAR_FILES := \ resources.jar \ rt.jar \ security/US_export_policy.jar \ - security/local_policy.jar \ - tzdb.jar - + security/local_policy.jar PROFILE_2_JRE_BIN_FILES := \ rmid$(EXE_SUFFIX) \ diff --git a/jdk/src/share/classes/java/time/DayOfWeek.java b/jdk/src/share/classes/java/time/DayOfWeek.java index c616a31431d..767058ba328 100644 --- a/jdk/src/share/classes/java/time/DayOfWeek.java +++ b/jdk/src/share/classes/java/time/DayOfWeek.java @@ -61,13 +61,13 @@ */ package java.time; +import java.time.temporal.UnsupportedTemporalTypeException; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoUnit.DAYS; import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -259,7 +259,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { *

* If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * range of the day-of-week, from 1 to 7, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

* If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -269,6 +269,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -288,7 +289,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { *

* If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * value of the day-of-week, from 1 to 7, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

* If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -297,7 +298,10 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { * * @param field the field to get, not null * @return the value for the field, within the valid range of values - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -317,7 +321,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { *

* If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the * value of the day-of-week, from 1 to 7, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

* If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -327,6 +331,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -334,7 +339,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { if (field == DAY_OF_WEEK) { return getValue(); } else if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -393,7 +398,7 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.precision()) { + if (query == TemporalQuery.precision()) { return (R) DAYS; } return TemporalAccessor.super.query(query); @@ -409,8 +414,8 @@ public enum DayOfWeek implements TemporalAccessor, TemporalAdjuster { * passing {@link ChronoField#DAY_OF_WEEK} as the field. * Note that this adjusts forwards or backwards within a Monday to Sunday week. * See {@link WeekFields#dayOfWeek} for localized week start days. - * See {@link java.time.temporal.Adjusters Adjusters} for other adjusters - * with more control, such as {@code next(MONDAY)}. + * See {@code TemporalAdjuster} for other adjusters with more control, + * such as {@code next(MONDAY)}. *

* In most cases, it is clearer to reverse the calling pattern by using * {@link Temporal#with(TemporalAdjuster)}: diff --git a/jdk/src/share/classes/java/time/Duration.java b/jdk/src/share/classes/java/time/Duration.java index 86e410f2b30..73c04fde27e 100644 --- a/jdk/src/share/classes/java/time/Duration.java +++ b/jdk/src/share/classes/java/time/Duration.java @@ -85,6 +85,7 @@ import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -302,31 +303,32 @@ public final class Duration //----------------------------------------------------------------------- /** - * Obtains a {@code Duration} representing the duration between two instants. + * Obtains an instance of {@code Duration} from a temporal amount. *

- * This calculates the duration between two temporal objects of the same type. - * The difference in seconds is calculated using - * {@link Temporal#periodUntil(Temporal, TemporalUnit)}. - * The difference in nanoseconds is calculated using by querying the - * {@link ChronoField#NANO_OF_SECOND NANO_OF_SECOND} field. + * This obtains a duration based on the specified amount. + * A {@code TemporalAmount} represents an amount of time, which may be + * date-based or time-based, which this factory extracts to a duration. *

- * The result of this method can be a negative period if the end is before the start. - * To guarantee to obtain a positive duration call {@link #abs()} on the result. + * The conversion loops around the set of units from the amount and uses + * the {@linkplain TemporalUnit#getDuration() duration} of the unit to + * calculate the total {@code Duration}. + * Only a subset of units are accepted by this method. The unit must either + * have an {@linkplain TemporalUnit#isDurationEstimated() exact duration} + * or be {@link ChronoUnit#DAYS} which is treated as 24 hours. + * If any other units are found then an exception is thrown. * - * @param startInclusive the start instant, inclusive, not null - * @param endExclusive the end instant, exclusive, not null - * @return a {@code Duration}, not null - * @throws ArithmeticException if the calculation exceeds the capacity of {@code Duration} + * @param amount the temporal amount to convert, not null + * @return the equivalent duration, not null + * @throws DateTimeException if unable to convert to a {@code Duration} + * @throws ArithmeticException if numeric overflow occurs */ - public static Duration between(Temporal startInclusive, Temporal endExclusive) { - long secs = startInclusive.periodUntil(endExclusive, SECONDS); - long nanos; - try { - nanos = endExclusive.getLong(NANO_OF_SECOND) - startInclusive.getLong(NANO_OF_SECOND); - } catch (DateTimeException ex) { - nanos = 0; + public static Duration from(TemporalAmount amount) { + Objects.requireNonNull(amount, "amount"); + Duration duration = ZERO; + for (TemporalUnit unit : amount.getUnits()) { + duration = duration.plus(amount.get(unit), unit); } - return ofSeconds(secs, nanos); + return duration; } //----------------------------------------------------------------------- @@ -360,14 +362,14 @@ public final class Duration *

* Examples: *

-     *    "PT20.345S" -> parses as "20.345 seconds"
-     *    "PT15M"     -> parses as "15 minutes" (where a minute is 60 seconds)
-     *    "PT10H"     -> parses as "10 hours" (where an hour is 3600 seconds)
-     *    "P2D"       -> parses as "2 days" (where a day is 24 hours or 86400 seconds)
-     *    "P2DT3H4M"  -> parses as "2 days, 3 hours and 4 minutes"
-     *    "P-6H3M"    -> parses as "-6 hours and +3 minutes"
-     *    "-P6H3M"    -> parses as "-6 hours and -3 minutes"
-     *    "-P-6H+3M"  -> parses as "+6 hours and -3 minutes"
+     *    "PT20.345S" -- parses as "20.345 seconds"
+     *    "PT15M"     -- parses as "15 minutes" (where a minute is 60 seconds)
+     *    "PT10H"     -- parses as "10 hours" (where an hour is 3600 seconds)
+     *    "P2D"       -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
+     *    "P2DT3H4M"  -- parses as "2 days, 3 hours and 4 minutes"
+     *    "P-6H3M"    -- parses as "-6 hours and +3 minutes"
+     *    "-P6H3M"    -- parses as "-6 hours and -3 minutes"
+     *    "-P-6H+3M"  -- parses as "+6 hours and -3 minutes"
      * 
* * @param text the text to parse, not null @@ -437,6 +439,44 @@ public final class Duration return ofSeconds(seconds, nanos); } + //----------------------------------------------------------------------- + /** + * Obtains a {@code Duration} representing the duration between two instants. + *

+ * This calculates the duration between two temporal objects of the same type. + * The specified temporal objects must support the {@link ChronoUnit#SECONDS SECONDS} unit. + * For full accuracy, either the {@link ChronoUnit#NANOS NANOS} unit or the + * {@link ChronoField#NANO_OF_SECOND NANO_OF_SECOND} field should be supported. + *

+ * The result of this method can be a negative period if the end is before the start. + * To guarantee to obtain a positive duration call {@link #abs()} on the result. + * + * @param startInclusive the start instant, inclusive, not null + * @param endExclusive the end instant, exclusive, not null + * @return a {@code Duration}, not null + * @throws DateTimeException if the seconds between the temporals cannot be obtained + * @throws ArithmeticException if the calculation exceeds the capacity of {@code Duration} + */ + public static Duration between(Temporal startInclusive, Temporal endExclusive) { + try { + return ofNanos(startInclusive.periodUntil(endExclusive, NANOS)); + } catch (DateTimeException | ArithmeticException ex) { + long secs = startInclusive.periodUntil(endExclusive, SECONDS); + long nanos; + try { + nanos = endExclusive.getLong(NANO_OF_SECOND) - startInclusive.getLong(NANO_OF_SECOND); + if (secs > 0 && nanos < 0) { + secs++; + } else if (secs < 0 && nanos > 0) { + secs--; + } + } catch (DateTimeException ex2) { + nanos = 0; + } + return ofSeconds(secs, nanos); + } + } + //----------------------------------------------------------------------- /** * Obtains an instance of {@code Duration} using seconds and nanoseconds. @@ -474,6 +514,7 @@ public final class Duration * @param unit the {@code TemporalUnit} for which to return the value * @return the long value of the unit * @throws DateTimeException if the unit is not supported + * @throws UnsupportedTemporalTypeException if the unit is not supported */ @Override public long get(TemporalUnit unit) { @@ -482,7 +523,7 @@ public final class Duration } else if (unit == NANOS) { return nanos; } else { - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } } @@ -637,6 +678,7 @@ public final class Duration * @param amountToAdd the amount of the period, measured in terms of the unit, positive or negative * @param unit the unit that the period is measured in, must have an exact duration, not null * @return a {@code Duration} based on this duration with the specified duration added, not null + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ public Duration plus(long amountToAdd, TemporalUnit unit) { @@ -645,7 +687,7 @@ public final class Duration return plus(Math.multiplyExact(amountToAdd, SECONDS_PER_DAY), 0); } if (unit.isDurationEstimated()) { - throw new DateTimeException("Unit must not have an estimated duration"); + throw new UnsupportedTemporalTypeException("Unit must not have an estimated duration"); } if (amountToAdd == 0) { return this; @@ -1130,9 +1172,9 @@ public final class Duration * @throws ArithmeticException if numeric overflow occurs */ public long toNanos() { - long millis = Math.multiplyExact(seconds, NANOS_PER_SECOND); - millis = Math.addExact(millis, nanos); - return millis; + long totalNanos = Math.multiplyExact(seconds, NANOS_PER_SECOND); + totalNanos = Math.addExact(totalNanos, nanos); + return totalNanos; } //----------------------------------------------------------------------- @@ -1199,10 +1241,10 @@ public final class Duration *

* Examples: *

-     *    "20.345 seconds"                 -> "PT20.345S
-     *    "15 minutes" (15 * 60 seconds)   -> "PT15M"
-     *    "10 hours" (10 * 3600 seconds)   -> "PT10H"
-     *    "2 days" (2 * 86400 seconds)     -> "PT48H"
+     *    "20.345 seconds"                 -- "PT20.345S
+     *    "15 minutes" (15 * 60 seconds)   -- "PT15M"
+     *    "10 hours" (10 * 3600 seconds)   -- "PT10H"
+     *    "2 days" (2 * 86400 seconds)     -- "PT48H"
      * 
* Note that multiples of 24 hours are not output as days to avoid confusion * with {@code Period}. diff --git a/jdk/src/share/classes/java/time/Instant.java b/jdk/src/share/classes/java/time/Instant.java index 81b74eb0722..bacdba0f498 100644 --- a/jdk/src/share/classes/java/time/Instant.java +++ b/jdk/src/share/classes/java/time/Instant.java @@ -81,7 +81,6 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -89,6 +88,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -148,6 +148,8 @@ import java.util.Objects; *
  • other times during the day will be broadly in line with the agreed international civil time
  • *
  • the day will be divided into exactly 86400 subdivisions, referred to as "seconds"
  • *
  • the Java "second" may differ from an SI second
  • + *
  • a well-defined algorithm must be specified to map each second in the accurate agreed + * international civil time to each "second" in this time-scale
  • *

    * Agreed international civil time is the base time-scale agreed by international convention, * which in 2012 is UTC (with leap-seconds). @@ -155,6 +157,14 @@ import java.util.Objects; * In 2012, the definition of the Java time-scale is the same as UTC for all days except * those where a leap-second occurs. On days where a leap-second does occur, the time-scale * effectively eliminates the leap-second, maintaining the fiction of 86400 seconds in the day. + * The approved well-defined algorithm to eliminate leap-seconds is specified as + * UTC-SLS. + *

    + * UTC-SLS is a simple algorithm that smoothes the leap-second over the last 1000 seconds of + * the day, making each of the last 1000 seconds 1/1000th longer or shorter than an SI second. + * Implementations built on an accurate leap-second aware time source should use UTC-SLS. + * Use of a different algorithm risks confusion and misinterpretation of instants around a + * leap-second and is discouraged. *

    * The main benefit of always dividing the day into 86400 subdivisions is that it matches the * expectations of most users of the API. The alternative is to force every user to understand @@ -163,16 +173,10 @@ import java.util.Objects; * Most applications also do not have a problem with a second being a very small amount longer or * shorter than a real SI second during a leap-second. *

    - * If an application does have access to an accurate clock that reports leap-seconds, then the - * recommended technique to implement the Java time-scale is to use the UTC-SLS convention. - * UTC-SLS effectively smoothes the - * leap-second over the last 1000 seconds of the day, making each of the last 1000 "seconds" - * 1/1000th longer or shorter than a real SI second. - *

    * One final problem is the definition of the agreed international civil time before the * introduction of modern UTC in 1972. This includes the Java epoch of {@code 1970-01-01}. * It is intended that instants before 1972 be interpreted based on the solar day divided - * into 86400 subdivisions. + * into 86400 subdivisions, as per the principles of UT1. *

    * The Java time-scale is used for all date-time classes. * This includes {@code Instant}, {@code LocalDate}, {@code LocalTime}, {@code OffsetDateTime}, @@ -210,7 +214,7 @@ public final class Instant */ public static final Instant MIN = Instant.ofEpochSecond(MIN_SECOND, 0); /** - * The minimum supported {@code Instant}, '-1000000000-01-01T00:00Z'. + * The maximum supported {@code Instant}, '1000000000-12-31T23:59:59.999999999Z'. * This could be used by an application as a "far future" instant. *

    * This is one year later than the maximum {@code LocalDateTime}. @@ -292,9 +296,9 @@ public final class Instant * to ensure that the stored nanosecond is in the range 0 to 999,999,999. * For example, the following will result in the exactly the same instant: *

    -     *  Instant.ofSeconds(3, 1);
    -     *  Instant.ofSeconds(4, -999_999_999);
    -     *  Instant.ofSeconds(2, 1000_000_001);
    +     *  Instant.ofEpochSecond(3, 1);
    +     *  Instant.ofEpochSecond(4, -999_999_999);
    +     *  Instant.ofEpochSecond(2, 1000_000_001);
          * 
    * * @param epochSecond the number of seconds from 1970-01-01T00:00:00Z @@ -441,7 +445,7 @@ public final class Instant * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -451,6 +455,7 @@ public final class Instant * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override // override for Javadoc public ValueRange range(TemporalField field) { @@ -469,7 +474,7 @@ public final class Instant * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time, except {@code INSTANT_SECONDS} which is too * large to fit in an {@code int} and throws a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -478,7 +483,10 @@ public final class Instant * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance @@ -490,7 +498,7 @@ public final class Instant case MILLI_OF_SECOND: return nanos / 1000_000; case INSTANT_SECONDS: INSTANT_SECONDS.checkValidIntValue(seconds); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return range(field).checkValidIntValue(field.getFrom(this), field); } @@ -505,7 +513,7 @@ public final class Instant * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -515,6 +523,7 @@ public final class Instant * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -526,7 +535,7 @@ public final class Instant case MILLI_OF_SECOND: return nanos / 1000_000; case INSTANT_SECONDS: return seconds; } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -610,7 +619,7 @@ public final class Instant * In all cases, if the new value is outside the valid range of values for the field * then a {@code DateTimeException} will be thrown. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -623,6 +632,7 @@ public final class Instant * @param newValue the new value of the field in the result * @return an {@code Instant} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -642,7 +652,7 @@ public final class Instant case NANO_OF_SECOND: return (newValue != nanos ? create(seconds, (int) newValue) : this); case INSTANT_SECONDS: return (newValue != seconds ? create(newValue, nanos) : this); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -668,6 +678,7 @@ public final class Instant * @param unit the unit to truncate to, not null * @return an {@code Instant} based on this instant with the time truncated, not null * @throws DateTimeException if the unit is invalid for truncation + * @throws UnsupportedTemporalTypeException if the unit is not supported */ public Instant truncatedTo(TemporalUnit unit) { if (unit == ChronoUnit.NANOS) { @@ -675,11 +686,11 @@ public final class Instant } Duration unitDur = unit.getDuration(); if (unitDur.getSeconds() > LocalTime.SECONDS_PER_DAY) { - throw new DateTimeException("Unit is too large to be used for truncation"); + throw new UnsupportedTemporalTypeException("Unit is too large to be used for truncation"); } long dur = unitDur.toNanos(); if ((LocalTime.NANOS_PER_DAY % dur) != 0) { - throw new DateTimeException("Unit must divide into a standard day without remainder"); + throw new UnsupportedTemporalTypeException("Unit must divide into a standard day without remainder"); } long nod = (seconds % LocalTime.SECONDS_PER_DAY) * LocalTime.NANOS_PER_SECOND + nanos; long result = (nod / dur) * dur; @@ -754,7 +765,7 @@ public final class Instant * multiplied by 86,400 (24 hours). * *

    - * All other {@code ChronoUnit} instances will throw a {@code DateTimeException}. + * All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -767,6 +778,7 @@ public final class Instant * @param unit the unit of the amount to add, not null * @return an {@code Instant} based on this instant with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -782,7 +794,7 @@ public final class Instant case HALF_DAYS: return plusSeconds(Math.multiplyExact(amountToAdd, SECONDS_PER_DAY / 2)); case DAYS: return plusSeconds(Math.multiplyExact(amountToAdd, SECONDS_PER_DAY)); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } @@ -894,6 +906,7 @@ public final class Instant * @param unit the unit of the amount to subtract, not null * @return an {@code Instant} based on this instant with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -975,11 +988,12 @@ public final class Instant @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.precision()) { + if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization - if (query == Queries.chronology() || query == Queries.zoneId() || query == Queries.zone() || query == Queries.offset()) { + if (query == TemporalQuery.chronology() || query == TemporalQuery.zoneId() || + query == TemporalQuery.zone() || query == TemporalQuery.offset()) { return null; } return query.queryFrom(this); @@ -1028,14 +1042,15 @@ public final class Instant * For example, the period in days between two dates can be calculated * using {@code startInstant.periodUntil(endInstant, SECONDS)}. *

    - * This method operates in association with {@link TemporalUnit#between}. - * The result of this method is a {@code long} representing the amount of - * the specified unit. By contrast, the result of {@code between} is an - * object that can be used directly in addition/subtraction: + * There are two equivalent ways of using this method. + * The first is to invoke this method. + * The second is to use {@link TemporalUnit#between(Temporal, Temporal)}: *

    -     *   long period = start.periodUntil(end, SECONDS);   // this method
    -     *   dateTime.plus(SECONDS.between(start, end));      // use in plus/minus
    +     *   // these two lines are equivalent
    +     *   amount = start.periodUntil(end, SECONDS);
    +     *   amount = SECONDS.between(start, end);
          * 
    + * The choice should be made based on which makes the code more readable. *

    * The calculation is implemented in this method for {@link ChronoUnit}. * The units {@code NANOS}, {@code MICROS}, {@code MILLIS}, {@code SECONDS}, @@ -1053,6 +1068,7 @@ public final class Instant * @param unit the unit to measure the period in, not null * @return the amount of the period between this date and the end date * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1074,18 +1090,26 @@ public final class Instant case HALF_DAYS: return secondsUntil(end) / (12 * SECONDS_PER_HOUR); case DAYS: return secondsUntil(end) / (SECONDS_PER_DAY); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endInstant); } private long nanosUntil(Instant end) { - long secs = Math.multiplyExact(secondsUntil(end), NANOS_PER_SECOND); - return Math.addExact(secs, end.nanos - nanos); + long secsDiff = Math.subtractExact(end.seconds, seconds); + long totalNanos = Math.multiplyExact(secsDiff, NANOS_PER_SECOND); + return Math.addExact(totalNanos, end.nanos - nanos); } private long secondsUntil(Instant end) { - return Math.subtractExact(end.seconds, seconds); + long secsDiff = Math.subtractExact(end.seconds, seconds); + long nanosDiff = end.nanos - nanos; + if (secsDiff > 0 && nanosDiff < 0) { + secsDiff--; + } else if (secsDiff < 0 && nanosDiff > 0) { + secsDiff++; + } + return secsDiff; } //----------------------------------------------------------------------- diff --git a/jdk/src/share/classes/java/time/LocalDate.java b/jdk/src/share/classes/java/time/LocalDate.java index 65287898ac1..cb1219bdb81 100644 --- a/jdk/src/share/classes/java/time/LocalDate.java +++ b/jdk/src/share/classes/java/time/LocalDate.java @@ -69,9 +69,9 @@ import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR; import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import java.io.DataInput; @@ -87,7 +87,6 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -95,6 +94,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.time.zone.ZoneOffsetTransition; import java.time.zone.ZoneRules; @@ -238,7 +238,7 @@ public final class LocalDate YEAR.checkValidValue(year); Objects.requireNonNull(month, "month"); DAY_OF_MONTH.checkValidValue(dayOfMonth); - return create(year, month, dayOfMonth); + return create(year, month.getValue(), dayOfMonth); } /** @@ -258,7 +258,7 @@ public final class LocalDate YEAR.checkValidValue(year); MONTH_OF_YEAR.checkValidValue(month); DAY_OF_MONTH.checkValidValue(dayOfMonth); - return create(year, Month.of(month), dayOfMonth); + return create(year, month, dayOfMonth); } //----------------------------------------------------------------------- @@ -287,7 +287,7 @@ public final class LocalDate moy = moy.plus(1); } int dom = dayOfYear - moy.firstDayOfYear(leap) + 1; - return create(year, moy, dom); + return new LocalDate(year, moy.getValue(), dom); } //----------------------------------------------------------------------- @@ -342,7 +342,7 @@ public final class LocalDate * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code LocalDate}. *

    - * The conversion uses the {@link Queries#localDate()} query, which relies + * The conversion uses the {@link TemporalQuery#localDate()} query, which relies * on extracting the {@link ChronoField#EPOCH_DAY EPOCH_DAY} field. *

    * This method matches the signature of the functional interface {@link TemporalQuery} @@ -353,7 +353,7 @@ public final class LocalDate * @throws DateTimeException if unable to convert to a {@code LocalDate} */ public static LocalDate from(TemporalAccessor temporal) { - LocalDate date = temporal.query(Queries.localDate()); + LocalDate date = temporal.query(TemporalQuery.localDate()); if (date == null) { throw new DateTimeException("Unable to obtain LocalDate from TemporalAccessor: " + temporal.getClass()); } @@ -395,20 +395,34 @@ public final class LocalDate * Creates a local date from the year, month and day fields. * * @param year the year to represent, validated from MIN_YEAR to MAX_YEAR - * @param month the month-of-year to represent, validated not null + * @param month the month-of-year to represent, from 1 to 12, validated * @param dayOfMonth the day-of-month to represent, validated from 1 to 31 * @return the local date, not null * @throws DateTimeException if the day-of-month is invalid for the month-year */ - private static LocalDate create(int year, Month month, int dayOfMonth) { - if (dayOfMonth > 28 && dayOfMonth > month.length(IsoChronology.INSTANCE.isLeapYear(year))) { - if (dayOfMonth == 29) { - throw new DateTimeException("Invalid date 'February 29' as '" + year + "' is not a leap year"); - } else { - throw new DateTimeException("Invalid date '" + month.name() + " " + dayOfMonth + "'"); + private static LocalDate create(int year, int month, int dayOfMonth) { + if (dayOfMonth > 28) { + int dom = 31; + switch (month) { + case 2: + dom = (IsoChronology.INSTANCE.isLeapYear(year) ? 29 : 28); + break; + case 4: + case 6: + case 9: + case 11: + dom = 30; + break; + } + if (dayOfMonth > dom) { + if (dayOfMonth == 29) { + throw new DateTimeException("Invalid date 'February 29' as '" + year + "' is not a leap year"); + } else { + throw new DateTimeException("Invalid date '" + Month.of(month).name() + " " + dayOfMonth + "'"); + } } } - return new LocalDate(year, month.getValue(), dayOfMonth); + return new LocalDate(year, month, dayOfMonth); } /** @@ -431,7 +445,7 @@ public final class LocalDate day = Math.min(day, 30); break; } - return LocalDate.of(year, month, day); + return new LocalDate(year, month, day); } /** @@ -467,7 +481,7 @@ public final class LocalDate *

  • {@code ALIGNED_WEEK_OF_MONTH} *
  • {@code ALIGNED_WEEK_OF_YEAR} *
  • {@code MONTH_OF_YEAR} - *
  • {@code EPOCH_MONTH} + *
  • {@code PROLEPTIC_MONTH} *
  • {@code YEAR_OF_ERA} *
  • {@code YEAR} *
  • {@code ERA} @@ -498,7 +512,7 @@ public final class LocalDate * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -508,12 +522,13 @@ public final class LocalDate * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - if (f.isDateField()) { + if (f.isDateBased()) { switch (f) { case DAY_OF_MONTH: return ValueRange.of(1, lengthOfMonth()); case DAY_OF_YEAR: return ValueRange.of(1, lengthOfYear()); @@ -523,7 +538,7 @@ public final class LocalDate } return field.range(); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } @@ -538,9 +553,9 @@ public final class LocalDate *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid - * values based on this date, except {@code EPOCH_DAY} and {@code EPOCH_MONTH} + * values based on this date, except {@code EPOCH_DAY} and {@code PROLEPTIC_MONTH} * which are too large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -549,7 +564,10 @@ public final class LocalDate * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance @@ -570,7 +588,7 @@ public final class LocalDate * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -580,6 +598,7 @@ public final class LocalDate * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -588,8 +607,8 @@ public final class LocalDate if (field == EPOCH_DAY) { return toEpochDay(); } - if (field == EPOCH_MONTH) { - return getEpochMonth(); + if (field == PROLEPTIC_MONTH) { + return getProlepticMonth(); } return get0(field); } @@ -603,20 +622,20 @@ public final class LocalDate case ALIGNED_DAY_OF_WEEK_IN_YEAR: return ((getDayOfYear() - 1) % 7) + 1; case DAY_OF_MONTH: return day; case DAY_OF_YEAR: return getDayOfYear(); - case EPOCH_DAY: throw new DateTimeException("Field too large for an int: " + field); + case EPOCH_DAY: throw new UnsupportedTemporalTypeException("Invalid field 'EpochDay' for get() method, use getLong() instead"); case ALIGNED_WEEK_OF_MONTH: return ((day - 1) / 7) + 1; case ALIGNED_WEEK_OF_YEAR: return ((getDayOfYear() - 1) / 7) + 1; case MONTH_OF_YEAR: return month; - case EPOCH_MONTH: throw new DateTimeException("Field too large for an int: " + field); + case PROLEPTIC_MONTH: throw new UnsupportedTemporalTypeException("Invalid field 'ProlepticMonth' for get() method, use getLong() instead"); case YEAR_OF_ERA: return (year >= 1 ? year : 1 - year); case YEAR: return year; case ERA: return (year >= 1 ? 1 : 0); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } - private long getEpochMonth() { - return ((year - 1970) * 12L) + (month - 1); + private long getProlepticMonth() { + return (year * 12L + month - 1); } //----------------------------------------------------------------------- @@ -626,7 +645,7 @@ public final class LocalDate * The {@code Chronology} represents the calendar system in use. * The ISO-8601 calendar system is the modern civil calendar system used today * in most of the world. It is equivalent to the proleptic Gregorian calendar - * system, in which todays's rules for leap years are applied for all time. + * system, in which today's rules for leap years are applied for all time. * * @return the ISO chronology, not null */ @@ -810,7 +829,7 @@ public final class LocalDate *

    * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link java.time.temporal.Adjusters}. + * A selection of common adjustments is provided in {@link TemporalAdjuster}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -908,8 +927,8 @@ public final class LocalDate * The year will be unchanged. The day-of-month will also be unchanged, * unless it would be invalid for the new month and year. In that case, the * day-of-month is adjusted to the maximum valid value for the new month and year. - *

  • {@code EPOCH_MONTH} - - * Returns a {@code LocalDate} with the specified epoch-month. + *
  • {@code PROLEPTIC_MONTH} - + * Returns a {@code LocalDate} with the specified proleptic-month. * The day-of-month will be unchanged, unless it would be invalid for the new month * and year. In that case, the day-of-month is adjusted to the maximum valid value * for the new month and year. @@ -933,7 +952,7 @@ public final class LocalDate * In all cases, if the new value is outside the valid range of values for the field * then a {@code DateTimeException} will be thrown. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -946,6 +965,7 @@ public final class LocalDate * @param newValue the new value of the field in the result * @return a {@code LocalDate} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -963,12 +983,12 @@ public final class LocalDate case ALIGNED_WEEK_OF_MONTH: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_MONTH)); case ALIGNED_WEEK_OF_YEAR: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_YEAR)); case MONTH_OF_YEAR: return withMonth((int) newValue); - case EPOCH_MONTH: return plusMonths(newValue - getLong(EPOCH_MONTH)); + case PROLEPTIC_MONTH: return plusMonths(newValue - getProlepticMonth()); case YEAR_OF_ERA: return withYear((int) (year >= 1 ? newValue : 1 - newValue)); case YEAR: return withYear((int) newValue); case ERA: return (getLong(ERA) == newValue ? this : withYear(1 - year)); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -1137,7 +1157,7 @@ public final class LocalDate * valid value for the new month and year. * *

    - * All other {@code ChronoUnit} instances will throw a {@code DateTimeException}. + * All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -1150,6 +1170,7 @@ public final class LocalDate * @param unit the unit of the amount to add, not null * @return a {@code LocalDate} based on this date with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1166,7 +1187,7 @@ public final class LocalDate case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); case ERAS: return with(ERA, Math.addExact(getLong(ERA), amountToAdd)); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } @@ -1315,6 +1336,7 @@ public final class LocalDate * @param unit the unit of the amount to subtract, not null * @return a {@code LocalDate} based on this date with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1431,7 +1453,7 @@ public final class LocalDate @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.localDate()) { + if (query == TemporalQuery.localDate()) { return (R) this; } return ChronoLocalDate.super.query(query); @@ -1508,10 +1530,12 @@ public final class LocalDate * @param unit the unit to measure the period in, not null * @return the amount of the period between this date and the end date * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override public long periodUntil(Temporal endDate, TemporalUnit unit) { + Objects.requireNonNull(unit, "unit"); if (endDate instanceof LocalDate == false) { Objects.requireNonNull(endDate, "endDate"); throw new DateTimeException("Unable to calculate period between objects of two different types"); @@ -1528,7 +1552,7 @@ public final class LocalDate case MILLENNIA: return monthsUntil(end) / 12000; case ERAS: return end.getLong(ERA) - getLong(ERA); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endDate); } @@ -1538,8 +1562,8 @@ public final class LocalDate } private long monthsUntil(LocalDate end) { - long packed1 = getEpochMonth() * 32L + getDayOfMonth(); // no overflow - long packed2 = end.getEpochMonth() * 32L + end.getDayOfMonth(); // no overflow + long packed1 = getProlepticMonth() * 32L + getDayOfMonth(); // no overflow + long packed2 = end.getProlepticMonth() * 32L + end.getDayOfMonth(); // no overflow return (packed2 - packed1) / 32; } @@ -1549,6 +1573,7 @@ public final class LocalDate * This calculates the period between two dates in terms of years, months and days. * The start and end points are {@code this} and the specified date. * The result will be negative if the end is before the start. + * The negative sign will be the same in each of year, month and day. *

    * The calculation is performed using the ISO calendar system. * If necessary, the input date will be converted to ISO. @@ -1561,9 +1586,6 @@ public final class LocalDate * than or equal to the start day-of-month. * For example, from {@code 2010-01-15} to {@code 2011-03-18} is "1 year, 2 months and 3 days". *

    - * The result of this method can be a negative period if the end is before the start. - * The negative sign will be the same in each of year, month and day. - *

    * There are two equivalent ways of using this method. * The first is to invoke this method. * The second is to use {@link Period#between(LocalDate, LocalDate)}: @@ -1580,7 +1602,7 @@ public final class LocalDate @Override public Period periodUntil(ChronoLocalDate endDate) { LocalDate end = LocalDate.from(endDate); - long totalMonths = end.getEpochMonth() - this.getEpochMonth(); // safe + long totalMonths = end.getProlepticMonth() - this.getProlepticMonth(); // safe int days = end.day - this.day; if (totalMonths > 0 && days < 0) { totalMonths--; @@ -1595,6 +1617,21 @@ public final class LocalDate return Period.of(Math.toIntExact(years), months, days); } + /** + * Formats this date using the specified formatter. + *

    + * This date will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted date string, not null + * @throws DateTimeException if an error occurs during printing + */ + @Override // override for Javadoc and performance + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this date with a time to create a {@code LocalDateTime}. @@ -1800,7 +1837,7 @@ public final class LocalDate * This method only considers the position of the two dates on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDate)}, - * but is the same approach as {@link #DATE_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDate#timeLineOrder()}. * * @param other the other date to compare to, not null * @return true if this date is after the specified date @@ -1829,7 +1866,7 @@ public final class LocalDate * This method only considers the position of the two dates on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDate)}, - * but is the same approach as {@link #DATE_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDate#timeLineOrder()}. * * @param other the other date to compare to, not null * @return true if this date is before the specified date @@ -1858,7 +1895,7 @@ public final class LocalDate * This method only considers the position of the two dates on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDate)} - * but is the same approach as {@link #DATE_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDate#timeLineOrder()}. * * @param other the other date to compare to, not null * @return true if this date is equal to the specified date @@ -1912,7 +1949,7 @@ public final class LocalDate /** * Outputs this date as a {@code String}, such as {@code 2007-12-03}. *

    - * The output will be in the ISO-8601 format {@code yyyy-MM-dd}. + * The output will be in the ISO-8601 format {@code uuuu-MM-dd}. * * @return a string representation of this date, not null */ @@ -1942,21 +1979,6 @@ public final class LocalDate .toString(); } - /** - * Outputs this date as a {@code String} using the formatter. - *

    - * This date will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted date string, not null - * @throws DateTimeException if an error occurs during printing - */ - @Override // override for Javadoc - public String toString(DateTimeFormatter formatter) { - return ChronoLocalDate.super.toString(formatter); - } - //----------------------------------------------------------------------- /** * Writes the object using a diff --git a/jdk/src/share/classes/java/time/LocalDateTime.java b/jdk/src/share/classes/java/time/LocalDateTime.java index b69e88bf4ba..2921d399edd 100644 --- a/jdk/src/share/classes/java/time/LocalDateTime.java +++ b/jdk/src/share/classes/java/time/LocalDateTime.java @@ -79,12 +79,10 @@ import java.io.InvalidObjectException; import java.io.ObjectStreamException; import java.io.Serializable; import java.time.chrono.ChronoLocalDateTime; -import java.time.chrono.IsoChronology; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -92,6 +90,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.time.zone.ZoneRules; import java.util.Objects; @@ -546,7 +545,7 @@ public final class LocalDateTime *

  • {@code ALIGNED_WEEK_OF_MONTH} *
  • {@code ALIGNED_WEEK_OF_YEAR} *
  • {@code MONTH_OF_YEAR} - *
  • {@code EPOCH_MONTH} + *
  • {@code PROLEPTIC_MONTH} *
  • {@code YEAR_OF_ERA} *
  • {@code YEAR} *
  • {@code ERA} @@ -565,7 +564,7 @@ public final class LocalDateTime public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return f.isDateField() || f.isTimeField(); + return f.isDateBased() || f.isTimeBased(); } return field != null && field.isSupportedBy(this); } @@ -581,7 +580,7 @@ public final class LocalDateTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -591,12 +590,13 @@ public final class LocalDateTime * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.range(field) : date.range(field)); + return (f.isTimeBased() ? time.range(field) : date.range(field)); } return field.rangeRefinedBy(this); } @@ -612,9 +612,9 @@ public final class LocalDateTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time, except {@code NANO_OF_DAY}, {@code MICRO_OF_DAY}, - * {@code EPOCH_DAY} and {@code EPOCH_MONTH} which are too large to fit in + * {@code EPOCH_DAY} and {@code PROLEPTIC_MONTH} which are too large to fit in * an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -623,14 +623,17 @@ public final class LocalDateTime * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override public int get(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.get(field) : date.get(field)); + return (f.isTimeBased() ? time.get(field) : date.get(field)); } return ChronoLocalDateTime.super.get(field); } @@ -645,7 +648,7 @@ public final class LocalDateTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -655,13 +658,14 @@ public final class LocalDateTime * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.getLong(field) : date.getLong(field)); + return (f.isTimeBased() ? time.getLong(field) : date.getLong(field)); } return field.getFrom(this); } @@ -822,7 +826,7 @@ public final class LocalDateTime *

    * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link java.time.temporal.Adjusters}. + * A selection of common adjustments is provided in {@link TemporalAdjuster}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -886,7 +890,7 @@ public final class LocalDateTime * The {@link #isSupported(TemporalField) supported fields} will behave as per * the matching method on {@link LocalDate#with(TemporalField, long) LocalDate} * or {@link LocalTime#with(TemporalField, long) LocalTime}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -899,13 +903,14 @@ public final class LocalDateTime * @param newValue the new value of the field in the result * @return a {@code LocalDateTime} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override public LocalDateTime with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - if (f.isTimeField()) { + if (f.isTimeBased()) { return with(date, time.with(field, newValue)); } else { return with(date.with(field, newValue), time); @@ -1052,6 +1057,7 @@ public final class LocalDateTime * @param unit the unit to truncate to, not null * @return a {@code LocalDateTime} based on this date-time with the time truncated, not null * @throws DateTimeException if unable to truncate + * @throws UnsupportedTemporalTypeException if the field is not supported */ public LocalDateTime truncatedTo(TemporalUnit unit) { return with(date, time.truncatedTo(unit)); @@ -1106,6 +1112,7 @@ public final class LocalDateTime * @param unit the unit of the amount to add, not null * @return a {@code LocalDateTime} based on this date-time with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1312,6 +1319,7 @@ public final class LocalDateTime * @param unit the unit of the amount to subtract, not null * @return a {@code LocalDateTime} based on this date-time with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1517,7 +1525,7 @@ public final class LocalDateTime @SuppressWarnings("unchecked") @Override // override for Javadoc public R query(TemporalQuery query) { - if (query == Queries.localDate()) { + if (query == TemporalQuery.localDate()) { return (R) date; } return ChronoLocalDateTime.super.query(query); @@ -1597,6 +1605,7 @@ public final class LocalDateTime * @param unit the unit to measure the period in, not null * @return the amount of the period between this date-time and the end date-time * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1610,31 +1619,79 @@ public final class LocalDateTime ChronoUnit f = (ChronoUnit) unit; if (f.isTimeUnit()) { long amount = date.daysUntil(end.date); - switch (f) { - case NANOS: amount = Math.multiplyExact(amount, NANOS_PER_DAY); break; - case MICROS: amount = Math.multiplyExact(amount, MICROS_PER_DAY); break; - case MILLIS: amount = Math.multiplyExact(amount, MILLIS_PER_DAY); break; - case SECONDS: amount = Math.multiplyExact(amount, SECONDS_PER_DAY); break; - case MINUTES: amount = Math.multiplyExact(amount, MINUTES_PER_DAY); break; - case HOURS: amount = Math.multiplyExact(amount, HOURS_PER_DAY); break; - case HALF_DAYS: amount = Math.multiplyExact(amount, 2); break; + if (amount == 0) { + return time.periodUntil(end.time, unit); } - return Math.addExact(amount, time.periodUntil(end.time, unit)); + long timePart = end.time.toNanoOfDay() - time.toNanoOfDay(); + if (amount > 0) { + amount--; // safe + timePart += NANOS_PER_DAY; // safe + } else { + amount++; // safe + timePart -= NANOS_PER_DAY; // safe + } + switch (f) { + case NANOS: + amount = Math.multiplyExact(amount, NANOS_PER_DAY); + break; + case MICROS: + amount = Math.multiplyExact(amount, MICROS_PER_DAY); + timePart = timePart / 1000; + break; + case MILLIS: + amount = Math.multiplyExact(amount, MILLIS_PER_DAY); + timePart = timePart / 1_000_000; + break; + case SECONDS: + amount = Math.multiplyExact(amount, SECONDS_PER_DAY); + timePart = timePart / NANOS_PER_SECOND; + break; + case MINUTES: + amount = Math.multiplyExact(amount, MINUTES_PER_DAY); + timePart = timePart / NANOS_PER_MINUTE; + break; + case HOURS: + amount = Math.multiplyExact(amount, HOURS_PER_DAY); + timePart = timePart / NANOS_PER_HOUR; + break; + case HALF_DAYS: + amount = Math.multiplyExact(amount, 2); + timePart = timePart / (NANOS_PER_HOUR * 12); + break; + } + return Math.addExact(amount, timePart); } LocalDate endDate = end.date; - if (end.time.isBefore(time)) { + if (endDate.isAfter(date) && end.time.isBefore(time)) { endDate = endDate.minusDays(1); + } else if (endDate.isBefore(date) && end.time.isAfter(time)) { + endDate = endDate.plusDays(1); } return date.periodUntil(endDate, unit); } return unit.between(this, endDateTime); } + /** + * Formats this date-time using the specified formatter. + *

    + * This date-time will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted date-time string, not null + * @throws DateTimeException if an error occurs during printing + */ + @Override // override for Javadoc and performance + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** - * Combines this time with a date to create an {@code OffsetTime}. + * Combines this date-time with an offset to create an {@code OffsetDateTime}. *

    - * This returns an {@code OffsetTime} formed from this time at the specified offset. + * This returns an {@code OffsetDateTime} formed from this date-time at the specified offset. * All possible combinations of date-time and offset are valid. * * @param offset the offset to combine with, not null @@ -1645,7 +1702,7 @@ public final class LocalDateTime } /** - * Combines this time with a time-zone to create a {@code ZonedDateTime}. + * Combines this date-time with a time-zone to create a {@code ZonedDateTime}. *

    * This returns a {@code ZonedDateTime} formed from this date-time at the * specified time-zone. The result will match this date-time as closely as possible. @@ -1725,7 +1782,7 @@ public final class LocalDateTime * This method only considers the position of the two date-times on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDateTime)}, - * but is the same approach as {@link #DATE_TIME_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDateTime#timeLineOrder()}. * * @param other the other date-time to compare to, not null * @return true if this date-time is after the specified date-time @@ -1754,7 +1811,7 @@ public final class LocalDateTime * This method only considers the position of the two date-times on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDateTime)}, - * but is the same approach as {@link #DATE_TIME_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDateTime#timeLineOrder()}. * * @param other the other date-time to compare to, not null * @return true if this date-time is before the specified date-time @@ -1783,7 +1840,7 @@ public final class LocalDateTime * This method only considers the position of the two date-times on the local time-line. * It does not take into account the chronology, or calendar system. * This is different from the comparison in {@link #compareTo(ChronoLocalDateTime)}, - * but is the same approach as {@link #DATE_TIME_COMPARATOR}. + * but is the same approach as {@link ChronoLocalDateTime#timeLineOrder()}. * * @param other the other date-time to compare to, not null * @return true if this date-time is equal to the specified date-time @@ -1834,11 +1891,11 @@ public final class LocalDateTime *

    * The output will be one of the following ISO-8601 formats: *

      - *
    • {@code yyyy-MM-dd'T'HH:mm}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSS}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSSSSS}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSS}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSSSSS}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSS}
    • *

    * The format used will be the shortest that outputs the full value of * the time where the omitted parts are implied to be zero. @@ -1850,21 +1907,6 @@ public final class LocalDateTime return date.toString() + 'T' + time.toString(); } - /** - * Outputs this date-time as a {@code String} using the formatter. - *

    - * This date-time will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted date-time string, not null - * @throws DateTimeException if an error occurs during printing - */ - @Override // override for Javadoc - public String toString(DateTimeFormatter formatter) { - return ChronoLocalDateTime.super.toString(formatter); - } - //----------------------------------------------------------------------- /** * Writes the object using a diff --git a/jdk/src/share/classes/java/time/LocalTime.java b/jdk/src/share/classes/java/time/LocalTime.java index c1884eb75d5..1e909f891b0 100644 --- a/jdk/src/share/classes/java/time/LocalTime.java +++ b/jdk/src/share/classes/java/time/LocalTime.java @@ -80,7 +80,6 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -88,6 +87,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -383,7 +383,7 @@ public final class LocalTime * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code LocalTime}. *

    - * The conversion uses the {@link Queries#localTime()} query, which relies + * The conversion uses the {@link TemporalQuery#localTime()} query, which relies * on extracting the {@link ChronoField#NANO_OF_DAY NANO_OF_DAY} field. *

    * This method matches the signature of the functional interface {@link TemporalQuery} @@ -394,7 +394,7 @@ public final class LocalTime * @throws DateTimeException if unable to convert to a {@code LocalTime} */ public static LocalTime from(TemporalAccessor temporal) { - LocalTime time = temporal.query(Queries.localTime()); + LocalTime time = temporal.query(TemporalQuery.localTime()); if (time == null) { throw new DateTimeException("Unable to obtain LocalTime from TemporalAccessor: " + temporal.getClass()); } @@ -505,7 +505,7 @@ public final class LocalTime @Override public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { - return ((ChronoField) field).isTimeField(); + return field.isTimeBased(); } return field != null && field.isSupportedBy(this); } @@ -521,7 +521,7 @@ public final class LocalTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -531,6 +531,7 @@ public final class LocalTime * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override // override for Javadoc public ValueRange range(TemporalField field) { @@ -549,7 +550,7 @@ public final class LocalTime * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this time, except {@code NANO_OF_DAY} and {@code MICRO_OF_DAY} * which are too large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -558,7 +559,10 @@ public final class LocalTime * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance @@ -579,7 +583,7 @@ public final class LocalTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -589,6 +593,7 @@ public final class LocalTime * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -608,9 +613,9 @@ public final class LocalTime private int get0(TemporalField field) { switch ((ChronoField) field) { case NANO_OF_SECOND: return nano; - case NANO_OF_DAY: throw new DateTimeException("Field too large for an int: " + field); + case NANO_OF_DAY: throw new UnsupportedTemporalTypeException("Invalid field 'NanoOfDay' for get() method, use getLong() instead"); case MICRO_OF_SECOND: return nano / 1000; - case MICRO_OF_DAY: throw new DateTimeException("Field too large for an int: " + field); + case MICRO_OF_DAY: throw new UnsupportedTemporalTypeException("Invalid field 'MicroOfDay' for get() method, use getLong() instead"); case MILLI_OF_SECOND: return nano / 1000_000; case MILLI_OF_DAY: return (int) (toNanoOfDay() / 1000_000); case SECOND_OF_MINUTE: return second; @@ -623,7 +628,7 @@ public final class LocalTime case CLOCK_HOUR_OF_DAY: return (hour == 0 ? 24 : hour); case AMPM_OF_DAY: return hour / 12; } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } //----------------------------------------------------------------------- @@ -760,7 +765,7 @@ public final class LocalTime * In all cases, if the new value is outside the valid range of values for the field * then a {@code DateTimeException} will be thrown. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -773,6 +778,7 @@ public final class LocalTime * @param newValue the new value of the field in the result * @return a {@code LocalTime} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -797,7 +803,7 @@ public final class LocalTime case CLOCK_HOUR_OF_DAY: return withHour((int) (newValue == 24 ? 0 : newValue)); case AMPM_OF_DAY: return plusHours((newValue - (hour / 12)) * 12); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -890,6 +896,7 @@ public final class LocalTime * @param unit the unit to truncate to, not null * @return a {@code LocalTime} based on this time with the time truncated, not null * @throws DateTimeException if unable to truncate + * @throws UnsupportedTemporalTypeException if the unit is not supported */ public LocalTime truncatedTo(TemporalUnit unit) { if (unit == ChronoUnit.NANOS) { @@ -897,11 +904,11 @@ public final class LocalTime } Duration unitDur = unit.getDuration(); if (unitDur.getSeconds() > SECONDS_PER_DAY) { - throw new DateTimeException("Unit is too large to be used for truncation"); + throw new UnsupportedTemporalTypeException("Unit is too large to be used for truncation"); } long dur = unitDur.toNanos(); if ((NANOS_PER_DAY % dur) != 0) { - throw new DateTimeException("Unit must divide into a standard day without remainder"); + throw new UnsupportedTemporalTypeException("Unit must divide into a standard day without remainder"); } long nod = toNanoOfDay(); return ofNanoOfDay((nod / dur) * dur); @@ -972,7 +979,7 @@ public final class LocalTime * This returns {@code this} time. * *

    - * All other {@code ChronoUnit} instances will throw a {@code DateTimeException}. + * All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -985,6 +992,7 @@ public final class LocalTime * @param unit the unit of the amount to add, not null * @return a {@code LocalTime} based on this time with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1001,7 +1009,7 @@ public final class LocalTime case HALF_DAYS: return plusHours((amountToAdd % 2) * 12); case DAYS: return this; } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } @@ -1147,6 +1155,7 @@ public final class LocalTime * @param unit the unit of the amount to subtract, not null * @return a {@code LocalTime} based on this time with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1237,13 +1246,14 @@ public final class LocalTime @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology() || query == Queries.zoneId() || query == Queries.zone() || query == Queries.offset()) { + if (query == TemporalQuery.chronology() || query == TemporalQuery.zoneId() || + query == TemporalQuery.zone() || query == TemporalQuery.offset()) { return null; - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return (R) this; - } else if (query == Queries.localDate()) { + } else if (query == TemporalQuery.localDate()) { return null; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -1322,6 +1332,7 @@ public final class LocalTime * @param unit the unit to measure the period in, not null * @return the amount of the period between this time and the end time * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1342,11 +1353,25 @@ public final class LocalTime case HOURS: return nanosUntil / NANOS_PER_HOUR; case HALF_DAYS: return nanosUntil / (12 * NANOS_PER_HOUR); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endTime); } + /** + * Formats this time using the specified formatter. + *

    + * This time will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted time string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this time with a date to create a {@code LocalDateTime}. @@ -1362,7 +1387,7 @@ public final class LocalTime } /** - * Combines this time with a date to create an {@code OffsetTime}. + * Combines this time with an offset to create an {@code OffsetTime}. *

    * This returns an {@code OffsetTime} formed from this time at the specified offset. * All possible combinations of time and offset are valid. @@ -1533,21 +1558,6 @@ public final class LocalTime return buf.toString(); } - /** - * Outputs this time as a {@code String} using the formatter. - *

    - * This time will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted time string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - //----------------------------------------------------------------------- /** * Writes the object using a diff --git a/jdk/src/share/classes/java/time/Month.java b/jdk/src/share/classes/java/time/Month.java index 8b4fe9267da..175d0517e2b 100644 --- a/jdk/src/share/classes/java/time/Month.java +++ b/jdk/src/share/classes/java/time/Month.java @@ -61,6 +61,7 @@ */ package java.time; +import java.time.temporal.UnsupportedTemporalTypeException; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoUnit.MONTHS; @@ -69,7 +70,6 @@ import java.time.chrono.IsoChronology; import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -290,7 +290,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { *

    * If the field is {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} then the * range of the month-of-year, from 1 to 12, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -300,6 +300,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -319,7 +320,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { *

    * If the field is {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} then the * value of the month-of-year, from 1 to 12, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -328,7 +329,10 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { * * @param field the field to get, not null * @return the value for the field, within the valid range of values - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -348,7 +352,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { *

    * If the field is {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} then the * value of the month-of-year, from 1 to 12, will be returned. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -358,6 +362,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -365,7 +370,7 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { if (field == MONTH_OF_YEAR) { return getValue(); } else if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -554,9 +559,9 @@ public enum Month implements TemporalAccessor, TemporalAdjuster { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology()) { + if (query == TemporalQuery.chronology()) { return (R) IsoChronology.INSTANCE; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) MONTHS; } return TemporalAccessor.super.query(query); diff --git a/jdk/src/share/classes/java/time/MonthDay.java b/jdk/src/share/classes/java/time/MonthDay.java index 33692d04576..276e869d10e 100644 --- a/jdk/src/share/classes/java/time/MonthDay.java +++ b/jdk/src/share/classes/java/time/MonthDay.java @@ -76,12 +76,12 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -354,7 +354,7 @@ public final class MonthDay * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -364,6 +364,7 @@ public final class MonthDay * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -386,7 +387,7 @@ public final class MonthDay * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this month-day. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -395,7 +396,10 @@ public final class MonthDay * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc @@ -413,7 +417,7 @@ public final class MonthDay * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this month-day. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -423,6 +427,7 @@ public final class MonthDay * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -433,7 +438,7 @@ public final class MonthDay case DAY_OF_MONTH: return day; case MONTH_OF_YEAR: return month; } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -575,7 +580,7 @@ public final class MonthDay @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology()) { + if (query == TemporalQuery.chronology()) { return (R) IsoChronology.INSTANCE; } return TemporalAccessor.super.query(query); @@ -617,6 +622,20 @@ public final class MonthDay return temporal.with(DAY_OF_MONTH, Math.min(temporal.range(DAY_OF_MONTH).getMaximum(), day)); } + /** + * Formats this month-day using the specified formatter. + *

    + * This month-day will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted month-day string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this month-day with a year to create a {@code LocalDate}. @@ -722,21 +741,6 @@ public final class MonthDay .toString(); } - /** - * Outputs this month-day as a {@code String} using the formatter. - *

    - * This month-day will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted month-day string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - //----------------------------------------------------------------------- /** * Writes the object using a diff --git a/jdk/src/share/classes/java/time/OffsetDateTime.java b/jdk/src/share/classes/java/time/OffsetDateTime.java index aef0a42a33a..aa4c7281c95 100644 --- a/jdk/src/share/classes/java/time/OffsetDateTime.java +++ b/jdk/src/share/classes/java/time/OffsetDateTime.java @@ -78,7 +78,6 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -86,6 +85,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.time.zone.ZoneRules; import java.util.Comparator; @@ -436,7 +436,7 @@ public final class OffsetDateTime *

  • {@code ALIGNED_WEEK_OF_MONTH} *
  • {@code ALIGNED_WEEK_OF_YEAR} *
  • {@code MONTH_OF_YEAR} - *
  • {@code EPOCH_MONTH} + *
  • {@code PROLEPTIC_MONTH} *
  • {@code YEAR_OF_ERA} *
  • {@code YEAR} *
  • {@code ERA} @@ -469,7 +469,7 @@ public final class OffsetDateTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -479,6 +479,7 @@ public final class OffsetDateTime * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -502,9 +503,9 @@ public final class OffsetDateTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time, except {@code NANO_OF_DAY}, {@code MICRO_OF_DAY}, - * {@code EPOCH_DAY}, {@code EPOCH_MONTH} and {@code INSTANT_SECONDS} which are too + * {@code EPOCH_DAY}, {@code PROLEPTIC_MONTH} and {@code INSTANT_SECONDS} which are too * large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -513,15 +514,20 @@ public final class OffsetDateTime * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override public int get(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { - case INSTANT_SECONDS: throw new DateTimeException("Field too large for an int: " + field); - case OFFSET_SECONDS: return getOffset().getTotalSeconds(); + case INSTANT_SECONDS: + throw new UnsupportedTemporalTypeException("Invalid field 'InstantSeconds' for get() method, use getLong() instead"); + case OFFSET_SECONDS: + return getOffset().getTotalSeconds(); } return dateTime.get(field); } @@ -538,7 +544,7 @@ public final class OffsetDateTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -548,6 +554,7 @@ public final class OffsetDateTime * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -790,7 +797,7 @@ public final class OffsetDateTime *

    * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link java.time.temporal.Adjusters}. + * A selection of common adjustments is provided in {@link TemporalAdjuster}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -867,7 +874,7 @@ public final class OffsetDateTime * the matching method on {@link LocalDateTime#with(TemporalField, long) LocalDateTime}. * In this case, the offset is not part of the calculation and will be unchanged. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -880,6 +887,7 @@ public final class OffsetDateTime * @param newValue the new value of the field in the result * @return an {@code OffsetDateTime} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1041,6 +1049,7 @@ public final class OffsetDateTime * @param unit the unit to truncate to, not null * @return an {@code OffsetDateTime} based on this date-time with the time truncated, not null * @throws DateTimeException if unable to truncate + * @throws UnsupportedTemporalTypeException if the unit is not supported */ public OffsetDateTime truncatedTo(TemporalUnit unit) { return with(dateTime.truncatedTo(unit), offset); @@ -1094,6 +1103,7 @@ public final class OffsetDateTime * @param unit the unit of the amount to add, not null * @return an {@code OffsetDateTime} based on this date-time with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1285,6 +1295,7 @@ public final class OffsetDateTime * @param unit the unit of the amount to subtract, not null * @return an {@code OffsetDateTime} based on this date-time with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1453,17 +1464,17 @@ public final class OffsetDateTime @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.offset() || query == Queries.zone()) { + if (query == TemporalQuery.offset() || query == TemporalQuery.zone()) { return (R) getOffset(); - } else if (query == Queries.zoneId()) { + } else if (query == TemporalQuery.zoneId()) { return null; - } else if (query == Queries.localDate()) { + } else if (query == TemporalQuery.localDate()) { return (R) toLocalDate(); - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return (R) toLocalTime(); - } else if (query == Queries.chronology()) { + } else if (query == TemporalQuery.chronology()) { return (R) IsoChronology.INSTANCE; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -1479,8 +1490,8 @@ public final class OffsetDateTime * with the offset, date and time changed to be the same as this. *

    * The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)} - * three times, passing {@link ChronoField#OFFSET_SECONDS}, - * {@link ChronoField#EPOCH_DAY} and {@link ChronoField#NANO_OF_DAY} as the fields. + * three times, passing {@link ChronoField#EPOCH_DAY}, + * {@link ChronoField#NANO_OF_DAY} and {@link ChronoField#OFFSET_SECONDS} as the fields. *

    * In most cases, it is clearer to reverse the calling pattern by using * {@link Temporal#with(TemporalAdjuster)}: @@ -1499,10 +1510,14 @@ public final class OffsetDateTime */ @Override public Temporal adjustInto(Temporal temporal) { + // OffsetDateTime is treated as three separate fields, not an instant + // this produces the most consistent set of results overall + // the offset is set after the date and time, as it is typically a small + // tweak to the result, with ZonedDateTime frequently ignoring the offset return temporal - .with(OFFSET_SECONDS, getOffset().getTotalSeconds()) .with(EPOCH_DAY, toLocalDate().toEpochDay()) - .with(NANO_OF_DAY, toLocalTime().toNanoOfDay()); + .with(NANO_OF_DAY, toLocalTime().toNanoOfDay()) + .with(OFFSET_SECONDS, getOffset().getTotalSeconds()); } /** @@ -1552,6 +1567,7 @@ public final class OffsetDateTime * @param unit the unit to measure the period in, not null * @return the amount of the period between this date-time and the end date-time * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1568,6 +1584,20 @@ public final class OffsetDateTime return unit.between(this, endDateTime); } + /** + * Formats this date-time using the specified formatter. + *

    + * This date-time will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted date-time string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this date-time with a time-zone to create a {@code ZonedDateTime} @@ -1796,11 +1826,11 @@ public final class OffsetDateTime *

    * The output will be one of the following ISO-8601 formats: *

      - *
    • {@code yyyy-MM-dd'T'HH:mmXXXXX}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ssXXXXX}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXXXX}
    • - *
    • {@code yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSXXXXX}
    • + *
    • {@code uuuu-MM-dd'T'HH:mmXXXXX}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ssXXXXX}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSSXXXXX}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSSSSSXXXXX}
    • + *
    • {@code uuuu-MM-dd'T'HH:mm:ss.SSSSSSSSSXXXXX}
    • *

    * The format used will be the shortest that outputs the full value of * the time where the omitted parts are implied to be zero. @@ -1812,21 +1842,6 @@ public final class OffsetDateTime return dateTime.toString() + offset.toString(); } - /** - * Outputs this date-time as a {@code String} using the formatter. - *

    - * This date-time will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted date-time string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - //----------------------------------------------------------------------- /** * Writes the object using a diff --git a/jdk/src/share/classes/java/time/OffsetTime.java b/jdk/src/share/classes/java/time/OffsetTime.java index ed60dee92c0..c6afcb26e49 100644 --- a/jdk/src/share/classes/java/time/OffsetTime.java +++ b/jdk/src/share/classes/java/time/OffsetTime.java @@ -79,7 +79,6 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -87,6 +86,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.time.zone.ZoneRules; import java.util.Objects; @@ -384,7 +384,7 @@ public final class OffsetTime @Override public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { - return ((ChronoField) field).isTimeField() || field == OFFSET_SECONDS; + return field.isTimeBased() || field == OFFSET_SECONDS; } return field != null && field.isSupportedBy(this); } @@ -400,7 +400,7 @@ public final class OffsetTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -410,6 +410,7 @@ public final class OffsetTime * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -434,7 +435,7 @@ public final class OffsetTime * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this time, except {@code NANO_OF_DAY} and {@code MICRO_OF_DAY} * which are too large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -443,7 +444,10 @@ public final class OffsetTime * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc @@ -461,7 +465,7 @@ public final class OffsetTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -471,6 +475,7 @@ public final class OffsetTime * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -655,7 +660,7 @@ public final class OffsetTime * the matching method on {@link LocalTime#with(TemporalField, long)} LocalTime}. * In this case, the offset is not part of the calculation and will be unchanged. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -668,6 +673,7 @@ public final class OffsetTime * @param newValue the new value of the field in the result * @return an {@code OffsetTime} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -764,6 +770,7 @@ public final class OffsetTime * @param unit the unit to truncate to, not null * @return an {@code OffsetTime} based on this time with the time truncated, not null * @throws DateTimeException if unable to truncate + * @throws UnsupportedTemporalTypeException if the unit is not supported */ public OffsetTime truncatedTo(TemporalUnit unit) { return with(time.truncatedTo(unit), offset); @@ -817,6 +824,7 @@ public final class OffsetTime * @param unit the unit of the amount to add, not null * @return an {@code OffsetTime} based on this time with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -930,6 +938,7 @@ public final class OffsetTime * @param unit the unit of the amount to subtract, not null * @return an {@code OffsetTime} based on this time with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1020,13 +1029,13 @@ public final class OffsetTime @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.offset() || query == Queries.zone()) { + if (query == TemporalQuery.offset() || query == TemporalQuery.zone()) { return (R) offset; - } else if (query == Queries.zoneId() | query == Queries.chronology() || query == Queries.localDate()) { + } else if (query == TemporalQuery.zoneId() | query == TemporalQuery.chronology() || query == TemporalQuery.localDate()) { return null; - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return (R) time; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -1042,8 +1051,8 @@ public final class OffsetTime * with the offset and time changed to be the same as this. *

    * The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)} - * twice, passing {@link ChronoField#OFFSET_SECONDS} and - * {@link ChronoField#NANO_OF_DAY} as the fields. + * twice, passing {@link ChronoField#NANO_OF_DAY} and + * {@link ChronoField#OFFSET_SECONDS} as the fields. *

    * In most cases, it is clearer to reverse the calling pattern by using * {@link Temporal#with(TemporalAdjuster)}: @@ -1063,8 +1072,8 @@ public final class OffsetTime @Override public Temporal adjustInto(Temporal temporal) { return temporal - .with(OFFSET_SECONDS, offset.getTotalSeconds()) - .with(NANO_OF_DAY, time.toNanoOfDay()); + .with(NANO_OF_DAY, time.toNanoOfDay()) + .with(OFFSET_SECONDS, offset.getTotalSeconds()); } /** @@ -1112,6 +1121,7 @@ public final class OffsetTime * @param unit the unit to measure the period in, not null * @return the amount of the period between this time and the end time * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1132,14 +1142,28 @@ public final class OffsetTime case HOURS: return nanosUntil / NANOS_PER_HOUR; case HALF_DAYS: return nanosUntil / (12 * NANOS_PER_HOUR); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endTime); } + /** + * Formats this time using the specified formatter. + *

    + * This time will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted time string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** - * Combines this date with a time to create an {@code OffsetDateTime}. + * Combines this time with a date to create an {@code OffsetDateTime}. *

    * This returns an {@code OffsetDateTime} formed from this time and the specified date. * All possible combinations of date and time are valid. @@ -1307,27 +1331,12 @@ public final class OffsetTime return time.toString() + offset.toString(); } - /** - * Outputs this time as a {@code String} using the formatter. - *

    - * This time will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted time string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - - // ----------------------------------------------------------------------- + //----------------------------------------------------------------------- /** * Writes the object using a * dedicated serialized form. *

    -     *  out.writeByte(9);  // identifies this as a OffsetDateTime
    +     *  out.writeByte(9);  // identifies this as a OffsetTime
          *  out.writeObject(time);
          *  out.writeObject(offset);
          * 
    diff --git a/jdk/src/share/classes/java/time/Period.java b/jdk/src/share/classes/java/time/Period.java index 88efaec4193..85980d9d874 100644 --- a/jdk/src/share/classes/java/time/Period.java +++ b/jdk/src/share/classes/java/time/Period.java @@ -79,6 +79,7 @@ import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Arrays; import java.util.Collections; @@ -215,26 +216,40 @@ public final class Period //----------------------------------------------------------------------- /** - * Obtains a {@code Period} consisting of the number of years, months, - * and days between two dates. + * Obtains an instance of {@code Period} from a temporal amount. *

    - * The start date is included, but the end date is not. - * The period is calculated by removing complete months, then calculating - * the remaining number of days, adjusting to ensure that both have the same sign. - * The number of months is then split into years and months based on a 12 month year. - * A month is considered if the end day-of-month is greater than or equal to the start day-of-month. - * For example, from {@code 2010-01-15} to {@code 2011-03-18} is one year, two months and three days. + * This obtains a period based on the specified amount. + * A {@code TemporalAmount} represents an amount of time, which may be + * date-based or time-based, which this factory extracts to a period. *

    - * The result of this method can be a negative period if the end is before the start. - * The negative sign will be the same in each of year, month and day. + * The conversion loops around the set of units from the amount and uses + * the {@link ChronoUnit#YEARS YEARS}, {@link ChronoUnit#MONTHS MONTHS} + * and {@link ChronoUnit#DAYS DAYS} units to create a period. + * If any other units are found then an exception is thrown. * - * @param startDate the start date, inclusive, not null - * @param endDate the end date, exclusive, not null - * @return the period between this date and the end date, not null - * @see ChronoLocalDate#periodUntil(ChronoLocalDate) + * @param amount the temporal amount to convert, not null + * @return the equivalent period, not null + * @throws DateTimeException if unable to convert to a {@code Period} + * @throws ArithmeticException if the amount of years, months or days exceeds an int */ - public static Period between(LocalDate startDate, LocalDate endDate) { - return startDate.periodUntil(endDate); + public static Period from(TemporalAmount amount) { + Objects.requireNonNull(amount, "amount"); + int years = 0; + int months = 0; + int days = 0; + for (TemporalUnit unit : amount.getUnits()) { + long unitAmount = amount.get(unit); + if (unit == ChronoUnit.YEARS) { + years = Math.toIntExact(unitAmount); + } else if (unit == ChronoUnit.MONTHS) { + months = Math.toIntExact(unitAmount); + } else if (unit == ChronoUnit.DAYS) { + days = Math.toIntExact(unitAmount); + } else { + throw new DateTimeException("Unit must be Years, Months or Days, but was " + unit); + } + } + return create(years, months, days); } //----------------------------------------------------------------------- @@ -296,6 +311,30 @@ public final class Period } } + //----------------------------------------------------------------------- + /** + * Obtains a {@code Period} consisting of the number of years, months, + * and days between two dates. + *

    + * The start date is included, but the end date is not. + * The period is calculated by removing complete months, then calculating + * the remaining number of days, adjusting to ensure that both have the same sign. + * The number of months is then split into years and months based on a 12 month year. + * A month is considered if the end day-of-month is greater than or equal to the start day-of-month. + * For example, from {@code 2010-01-15} to {@code 2011-03-18} is one year, two months and three days. + *

    + * The result of this method can be a negative period if the end is before the start. + * The negative sign will be the same in each of year, month and day. + * + * @param startDate the start date, inclusive, not null + * @param endDate the end date, exclusive, not null + * @return the period between this date and the end date, not null + * @see ChronoLocalDate#periodUntil(ChronoLocalDate) + */ + public static Period between(LocalDate startDate, LocalDate endDate) { + return startDate.periodUntil(endDate); + } + //----------------------------------------------------------------------- /** * Creates an instance. @@ -336,6 +375,7 @@ public final class Period * @param unit the {@code TemporalUnit} for which to return the value * @return the long value of the unit * @throws DateTimeException if the unit is not supported + * @throws UnsupportedTemporalTypeException if the unit is not supported */ @Override public long get(TemporalUnit unit) { @@ -346,7 +386,7 @@ public final class Period } else if (unit == ChronoUnit.DAYS) { return getDays(); } else { - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } } @@ -499,8 +539,7 @@ public final class Period /** * Returns a copy of this period with the specified period added. *

    - * This operates separately on the years, months, days and the normalized time. - * There is no further normalization beyond the normalized time. + * This operates separately on the years, months and days. *

    * For example, "1 year, 6 months and 3 days" plus "2 years, 2 months and 2 days" * returns "3 years, 8 months and 5 days". @@ -582,8 +621,7 @@ public final class Period /** * Returns a copy of this period with the specified period subtracted. *

    - * This operates separately on the years, months, days and the normalized time. - * There is no further normalization beyond the normalized time. + * This operates separately on the years, months and days. *

    * For example, "1 year, 6 months and 3 days" minus "2 years, 2 months and 2 days" * returns "-1 years, 4 months and 1 day". @@ -845,9 +883,11 @@ public final class Period * @return the month range, negative if not fixed range */ private long monthRange(Temporal temporal) { - ValueRange startRange = Chronology.from(temporal).range(MONTH_OF_YEAR); - if (startRange.isFixed() && startRange.isIntValue()) { - return startRange.getMaximum() - startRange.getMinimum() + 1; + if (temporal.isSupported(MONTH_OF_YEAR)) { + ValueRange startRange = Chronology.from(temporal).range(MONTH_OF_YEAR); + if (startRange.isFixed() && startRange.isIntValue()) { + return startRange.getMaximum() - startRange.getMinimum() + 1; + } } return -1; } diff --git a/jdk/src/share/classes/java/time/Year.java b/jdk/src/share/classes/java/time/Year.java index 017b74dc1f9..2ef92b53885 100644 --- a/jdk/src/share/classes/java/time/Year.java +++ b/jdk/src/share/classes/java/time/Year.java @@ -80,7 +80,6 @@ import java.time.format.DateTimeParseException; import java.time.format.SignStyle; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -88,6 +87,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -368,7 +368,7 @@ public final class Year * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -378,6 +378,7 @@ public final class Year * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -398,7 +399,7 @@ public final class Year * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this year. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -407,7 +408,10 @@ public final class Year * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc @@ -425,7 +429,7 @@ public final class Year * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this year. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -435,6 +439,7 @@ public final class Year * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -445,7 +450,7 @@ public final class Year case YEAR: return year; case ERA: return (year < 1 ? 0 : 1); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -544,7 +549,7 @@ public final class Year * In all cases, if the new value is outside the valid range of values for the field * then a {@code DateTimeException} will be thrown. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -557,6 +562,7 @@ public final class Year * @param newValue the new value of the field in the result * @return a {@code Year} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -569,7 +575,7 @@ public final class Year case YEAR: return Year.of((int) newValue); case ERA: return (getLong(ERA) == newValue ? this : Year.of(1 - year)); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -632,7 +638,7 @@ public final class Year * is unchanged. * *

    - * All other {@code ChronoUnit} instances will throw a {@code DateTimeException}. + * All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -645,6 +651,7 @@ public final class Year * @param unit the unit of the amount to add, not null * @return a {@code Year} based on this year with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -657,7 +664,7 @@ public final class Year case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); case ERAS: return with(ERA, Math.addExact(getLong(ERA), amountToAdd)); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } @@ -705,9 +712,9 @@ public final class Year } /** - * Returns a copy of this year-month with the specified amount subtracted. + * Returns a copy of this year with the specified amount subtracted. *

    - * This returns a {@code YearMonth}, based on this one, with the amount + * This returns a {@code Year}, based on this one, with the amount * in terms of the unit subtracted. If it is not possible to subtract the amount, * because the unit is not supported or for some other reason, an exception is thrown. *

    @@ -718,8 +725,9 @@ public final class Year * * @param amountToSubtract the amount of the unit to subtract from the result, may be negative * @param unit the unit of the amount to subtract, not null - * @return a {@code YearMonth} based on this year-month with the specified amount subtracted, not null + * @return a {@code Year} based on this year with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -762,9 +770,9 @@ public final class Year @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology()) { + if (query == TemporalQuery.chronology()) { return (R) IsoChronology.INSTANCE; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) YEARS; } return Temporal.super.query(query); @@ -846,6 +854,7 @@ public final class Year * @param unit the unit to measure the period in, not null * @return the amount of the period between this year and the end year * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -864,11 +873,25 @@ public final class Year case MILLENNIA: return yearsUntil / 1000; case ERAS: return end.getLong(ERA) - getLong(ERA); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endYear); } + /** + * Formats this year using the specified formatter. + *

    + * This year will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted year string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this year with a day-of-year to create a {@code LocalDate}. @@ -1014,21 +1037,6 @@ public final class Year return Integer.toString(year); } - /** - * Outputs this year as a {@code String} using the formatter. - *

    - * This year will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted year string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - //----------------------------------------------------------------------- /** * Writes the object using a diff --git a/jdk/src/share/classes/java/time/YearMonth.java b/jdk/src/share/classes/java/time/YearMonth.java index 076983fbcf9..312a36cd3f7 100644 --- a/jdk/src/share/classes/java/time/YearMonth.java +++ b/jdk/src/share/classes/java/time/YearMonth.java @@ -61,9 +61,9 @@ */ package java.time; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; import static java.time.temporal.ChronoUnit.MONTHS; @@ -82,7 +82,6 @@ import java.time.format.DateTimeParseException; import java.time.format.SignStyle; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -90,6 +89,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -255,7 +255,7 @@ public final class YearMonth * Obtains an instance of {@code YearMonth} from a text string such as {@code 2007-12}. *

    * The string must represent a valid year-month. - * The format must be {@code yyyy-MM}. + * The format must be {@code uuuu-MM}. * Years outside the range 0000 to 9999 must be prefixed by the plus or minus symbol. * * @param text the text to parse such as "2007-12", not null @@ -320,7 +320,7 @@ public final class YearMonth * The supported fields are: *

      *
    • {@code MONTH_OF_YEAR} - *
    • {@code EPOCH_MONTH} + *
    • {@code PROLEPTIC_MONTH} *
    • {@code YEAR_OF_ERA} *
    • {@code YEAR} *
    • {@code ERA} @@ -339,7 +339,7 @@ public final class YearMonth public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { return field == YEAR || field == MONTH_OF_YEAR || - field == EPOCH_MONTH || field == YEAR_OF_ERA || field == ERA; + field == PROLEPTIC_MONTH || field == YEAR_OF_ERA || field == ERA; } return field != null && field.isSupportedBy(this); } @@ -355,7 +355,7 @@ public final class YearMonth * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

      * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -365,6 +365,7 @@ public final class YearMonth * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -384,9 +385,9 @@ public final class YearMonth *

      * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid - * values based on this year-month, except {@code EPOCH_MONTH} which is too + * values based on this year-month, except {@code PROLEPTIC_MONTH} which is too * large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

      * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -395,7 +396,10 @@ public final class YearMonth * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc @@ -413,7 +417,7 @@ public final class YearMonth * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this year-month. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

      * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -423,6 +427,7 @@ public final class YearMonth * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -430,18 +435,18 @@ public final class YearMonth if (field instanceof ChronoField) { switch ((ChronoField) field) { case MONTH_OF_YEAR: return month; - case EPOCH_MONTH: return getEpochMonth(); + case PROLEPTIC_MONTH: return getProlepticMonth(); case YEAR_OF_ERA: return (year < 1 ? 1 - year : year); case YEAR: return year; case ERA: return (year < 1 ? 0 : 1); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } - private long getEpochMonth() { - return ((year - 1970) * 12L) + (month - 1); + private long getProlepticMonth() { + return (year * 12L + month - 1); } //----------------------------------------------------------------------- @@ -589,8 +594,8 @@ public final class YearMonth *

    • {@code MONTH_OF_YEAR} - * Returns a {@code YearMonth} with the specified month-of-year. * The year will be unchanged. - *
    • {@code EPOCH_MONTH} - - * Returns a {@code YearMonth} with the specified epoch-month. + *
    • {@code PROLEPTIC_MONTH} - + * Returns a {@code YearMonth} with the specified proleptic-month. * This completely replaces the year and month of this object. *
    • {@code YEAR_OF_ERA} - * Returns a {@code YearMonth} with the specified year-of-era @@ -606,7 +611,7 @@ public final class YearMonth * In all cases, if the new value is outside the valid range of values for the field * then a {@code DateTimeException} will be thrown. *

      - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

      * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -619,6 +624,7 @@ public final class YearMonth * @param newValue the new value of the field in the result * @return a {@code YearMonth} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -628,12 +634,12 @@ public final class YearMonth f.checkValidValue(newValue); switch (f) { case MONTH_OF_YEAR: return withMonth((int) newValue); - case EPOCH_MONTH: return plusMonths(newValue - getLong(EPOCH_MONTH)); + case PROLEPTIC_MONTH: return plusMonths(newValue - getProlepticMonth()); case YEAR_OF_ERA: return withYear((int) (year < 1 ? 1 - newValue : newValue)); case YEAR: return withYear((int) newValue); case ERA: return (getLong(ERA) == newValue ? this : withYear(1 - year)); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -728,7 +734,7 @@ public final class YearMonth * is unchanged. *

    *

    - * All other {@code ChronoUnit} instances will throw a {@code DateTimeException}. + * All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -741,6 +747,7 @@ public final class YearMonth * @param unit the unit of the amount to add, not null * @return a {@code YearMonth} based on this year-month with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -754,7 +761,7 @@ public final class YearMonth case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); case ERAS: return with(ERA, Math.addExact(getLong(ERA), amountToAdd)); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } @@ -838,6 +845,7 @@ public final class YearMonth * @param unit the unit of the amount to subtract, not null * @return a {@code YearMonth} based on this year-month with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -893,9 +901,9 @@ public final class YearMonth @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology()) { + if (query == TemporalQuery.chronology()) { return (R) IsoChronology.INSTANCE; - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) MONTHS; } return Temporal.super.query(query); @@ -908,7 +916,7 @@ public final class YearMonth * with the year and month changed to be the same as this. *

    * The adjustment is equivalent to using {@link Temporal#with(TemporalField, long)} - * passing {@link ChronoField#EPOCH_MONTH} as the field. + * passing {@link ChronoField#PROLEPTIC_MONTH} as the field. * If the specified temporal object does not use the ISO calendar system then * a {@code DateTimeException} is thrown. *

    @@ -932,7 +940,7 @@ public final class YearMonth if (Chronology.from(temporal).equals(IsoChronology.INSTANCE) == false) { throw new DateTimeException("Adjustment only supported on ISO date-time"); } - return temporal.with(EPOCH_MONTH, getEpochMonth()); + return temporal.with(PROLEPTIC_MONTH, getProlepticMonth()); } /** @@ -977,6 +985,7 @@ public final class YearMonth * @param unit the unit to measure the period in, not null * @return the amount of the period between this year-month and the end year-month * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -987,7 +996,7 @@ public final class YearMonth } YearMonth end = (YearMonth) endYearMonth; if (unit instanceof ChronoUnit) { - long monthsUntil = end.getEpochMonth() - getEpochMonth(); // no overflow + long monthsUntil = end.getProlepticMonth() - getProlepticMonth(); // no overflow switch ((ChronoUnit) unit) { case MONTHS: return monthsUntil; case YEARS: return monthsUntil / 12; @@ -996,11 +1005,25 @@ public final class YearMonth case MILLENNIA: return monthsUntil / 12000; case ERAS: return end.getLong(ERA) - getLong(ERA); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endYearMonth); } + /** + * Formats this year-month using the specified formatter. + *

    + * This year-month will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted year-month string, not null + * @throws DateTimeException if an error occurs during printing + */ + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this year-month with a day-of-month to create a {@code LocalDate}. @@ -1115,7 +1138,7 @@ public final class YearMonth /** * Outputs this year-month as a {@code String}, such as {@code 2007-12}. *

    - * The output will be in the format {@code yyyy-MM}: + * The output will be in the format {@code uuuu-MM}: * * @return a string representation of this year-month, not null */ @@ -1137,21 +1160,6 @@ public final class YearMonth .toString(); } - /** - * Outputs this year-month as a {@code String} using the formatter. - *

    - * This year-month will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted year-month string, not null - * @throws DateTimeException if an error occurs during printing - */ - public String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - //----------------------------------------------------------------------- /** * Writes the object using a diff --git a/jdk/src/share/classes/java/time/ZoneId.java b/jdk/src/share/classes/java/time/ZoneId.java index 43283f041e5..38a2a7ca289 100644 --- a/jdk/src/share/classes/java/time/ZoneId.java +++ b/jdk/src/share/classes/java/time/ZoneId.java @@ -66,10 +66,10 @@ import java.io.IOException; import java.io.Serializable; import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.zone.ZoneRules; import java.time.zone.ZoneRulesException; import java.time.zone.ZoneRulesProvider; @@ -78,6 +78,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.TimeZone; /** @@ -93,6 +94,8 @@ import java.util.TimeZone; * the offset from UTC/Greenwich apply *

    * Most fixed offsets are represented by {@link ZoneOffset}. + * Calling {@link #normalized()} on any {@code ZoneId} will ensure that a + * fixed offset ID will be represented as a {@code ZoneOffset}. *

    * The actual rules, describing when and how the offset changes, are defined by {@link ZoneRules}. * This class is simply an ID used to obtain the underlying rules. @@ -103,28 +106,29 @@ import java.util.TimeZone; * the ID, whereas serializing the rules sends the entire data set. * Similarly, a comparison of two IDs only examines the ID, whereas * a comparison of two rules examines the entire data set. - *

    - * The code supports loading a {@code ZoneId} on a JVM which does not have available rules - * for that ID. This allows the date-time object, such as {@link ZonedDateTime}, - * to still be queried. * *

    Time-zone IDs

    * The ID is unique within the system. - * The formats for offset and region IDs differ. + * There are three types of ID. *

    - * An ID is parsed as an offset ID if it starts with 'UTC', 'GMT', 'UT' '+' or '-', or - * is a single letter. For example, 'Z', '+02:00', '-05:00', 'UTC+05', 'GMT-6' and - * 'UT+01:00' are all valid offset IDs. - * Note that some IDs, such as 'D' or '+ABC' meet the criteria to be parsed as offset IDs, - * but have an invalid offset. + * The simplest type of ID is that from {@code ZoneOffset}. + * This consists of 'Z' and IDs starting with '+' or '-'. *

    - * All other IDs are considered to be region IDs. + * The next type of ID are offset-style IDs with some form of prefix, + * such as 'GMT+2' or 'UTC+01:00'. + * The recognised prefixes are 'UTC', 'GMT' and 'UT'. + * The offset is the suffix and will be normalized during creation. + * These IDs can be normalized to a {@code ZoneOffset} using {@code normalized()}. *

    - * Region IDs are defined by configuration, which can be thought of as a {@code Map} - * from region ID to {@code ZoneRules}, see {@link ZoneRulesProvider}. + * The third type of ID are region-based IDs. A region-based ID must be of + * two or more characters, and not start with 'UTC', 'GMT', 'UT' '+' or '-'. + * Region-based IDs are defined by configuration, see {@link ZoneRulesProvider}. + * The configuration focuses on providing the lookup from the ID to the + * underlying {@code ZoneRules}. *

    - * Time-zones are defined by governments and change frequently. There are a number of - * organizations, known here as groups, that monitor time-zone changes and collate them. + * Time-zone rules are defined by governments and change frequently. + * There are a number of organizations, known here as groups, that monitor + * time-zone changes and collate them. * The default group is the IANA Time Zone Database (TZDB). * Other organizations include IATA (the airline industry body) and Microsoft. *

    @@ -139,6 +143,20 @@ import java.util.TimeZone; * The recommended format for region IDs from groups other than TZDB is 'group~region'. * Thus if IATA data were defined, Utrecht airport would be 'IATA~UTC'. * + *

    Serialization

    + * This class can be serialized and stores the string zone ID in the external form. + * The {@code ZoneOffset} subclass uses a dedicated format that only stores the + * offset from UTC/Greenwich. + *

    + * A {@code ZoneId} can be deserialized in a Java Runtime where the ID is unknown. + * For example, if a server-side Java Runtime has been updated with a new zone ID, but + * the client-side Java Runtime has not been updated. In this case, the {@code ZoneId} + * object will exist, and can be queried using {@code getId}, {@code equals}, + * {@code hashCode}, {@code toString}, {@code getDisplayName} and {@code normalized}. + * However, any call to {@code getRules} will fail with {@code ZoneRulesException}. + * This approach is designed to allow a {@link ZonedDateTime} to be loaded and + * queried, but not modified, on a Java Runtime with incomplete time-zone information. + * *

    Specification for implementors

    * This abstract class has two implementations, both of which are immutable and thread-safe. * One implementation models region-based IDs, the other is {@code ZoneOffset} modelling @@ -149,7 +167,15 @@ import java.util.TimeZone; public abstract class ZoneId implements Serializable { /** - * A map of zone overrides to enable the older US time-zone names to be used. + * A map of zone overrides to enable the older short time-zone names to be used. + *

    + * Use of short zone IDs has been deprecated in {@code java.util.TimeZone}. + * This map allows the IDs to continue to be used via the + * {@link #of(String, Map)} factory method. + *

    + * This map contains an older mapping of the IDs, where 'EST', 'MST' and 'HST' + * map to IDs which include daylight savings. + * This is in line with versions of TZDB before 2005r. *

    * This maps as follows: *

      @@ -184,9 +210,17 @@ public abstract class ZoneId implements Serializable { *

    * The map is unmodifiable. */ - public static final Map OLD_IDS_PRE_2005; + public static final Map OLD_SHORT_IDS; /** - * A map of zone overrides to enable the older US time-zone names to be used. + * A map of zone overrides to enable the short time-zone names to be used. + *

    + * Use of short zone IDs has been deprecated in {@code java.util.TimeZone}. + * This map allows the IDs to continue to be used via the + * {@link #of(String, Map)} factory method. + *

    + * This map contains a newer mapping of the IDs, where 'EST', 'MST' and 'HST' + * map to IDs which do not include daylight savings + * This is in line with TZDB 2005r and later. *

    * This maps as follows: *

      @@ -221,7 +255,7 @@ public abstract class ZoneId implements Serializable { *

    * The map is unmodifiable. */ - public static final Map OLD_IDS_POST_2005; + public static final Map SHORT_IDS; static { Map base = new HashMap<>(); base.put("ACT", "Australia/Darwin"); @@ -253,12 +287,12 @@ public abstract class ZoneId implements Serializable { pre.put("EST", "America/New_York"); pre.put("MST", "America/Denver"); pre.put("HST", "Pacific/Honolulu"); - OLD_IDS_PRE_2005 = Collections.unmodifiableMap(pre); + OLD_SHORT_IDS = Collections.unmodifiableMap(pre); Map post = new HashMap<>(base); post.put("EST", "-05:00"); post.put("MST", "-07:00"); post.put("HST", "-10:00"); - OLD_IDS_POST_2005 = Collections.unmodifiableMap(post); + SHORT_IDS = Collections.unmodifiableMap(post); } /** * Serialization version. @@ -278,7 +312,23 @@ public abstract class ZoneId implements Serializable { * @throws ZoneRulesException if the converted zone region ID cannot be found */ public static ZoneId systemDefault() { - return ZoneId.of(TimeZone.getDefault().getID(), OLD_IDS_POST_2005); + return ZoneId.of(TimeZone.getDefault().getID(), SHORT_IDS); + } + + /** + * Gets the set of available zone IDs. + *

    + * This set includes the string form of all available region-based IDs. + * Offset-based zone IDs are not included in the returned set. + * The ID can be passed to {@link #of(String)} to create a {@code ZoneId}. + *

    + * The set of zone IDs can increase over time, although in a typical application + * the set of IDs is fixed. Each call to this method is thread-safe. + * + * @return a modifiable copy of the set of zone IDs, not null + */ + public static Set getAvailableZoneIds() { + return ZoneRulesProvider.getAvailableZoneIds(); } //----------------------------------------------------------------------- @@ -310,31 +360,36 @@ public abstract class ZoneId implements Serializable { * Obtains an instance of {@code ZoneId} from an ID ensuring that the * ID is valid and available for use. *

    - * This method parses the ID, applies any appropriate normalization, and validates it - * against the known set of IDs for which rules are available. + * This method parses the ID producing a {@code ZoneId} or {@code ZoneOffset}. + * A {@code ZoneOffset} is returned if the ID is 'Z', or starts with '+' or '-'. + * The result will always be a valid ID for which {@link ZoneRules} can be obtained. *

    - * An ID is parsed as though it is an offset ID if it starts with 'UTC', 'GMT', 'UT', '+' - * or '-', or if it has less then two letters. - * The offset of {@linkplain ZoneOffset#UTC zero} may be represented in multiple ways, - * including 'Z', 'UTC', 'GMT', 'UT', 'UTC0', 'GMT0', 'UT0', '+00:00', '-00:00' and 'UTC+00:00'. - *

    - * Six forms of ID are recognized: - *

      - *
    • Z - an offset of zero, which is {@code ZoneOffset.UTC} - *
    • {offset} - a {@code ZoneOffset} ID, such as '+02:00' - *
    • {utcPrefix} - a {@code ZoneOffset} ID equal to 'Z' - *
    • {utcPrefix}0 - a {@code ZoneOffset} ID equal to 'Z' - *
    • {utcPrefix}{offset} - a {@code ZoneOffset} ID equal to '{offset}' - *
    • {regionID} - full region ID, loaded from configuration - *

    - * The {offset} is a valid format for {@link ZoneOffset#of(String)}, excluding 'Z'. - * The {utcPrefix} is 'UTC', 'GMT' or 'UT'. - * Region IDs must match the regular expression [A-Za-z][A-Za-z0-9~/._+-]+. - *

    - * The detailed format of the region ID depends on the group supplying the data. - * The default set of data is supplied by the IANA Time Zone Database (TZDB) - * This has region IDs of the form '{area}/{city}', such as 'Europe/Paris' or 'America/New_York'. - * This is compatible with most IDs from {@link java.util.TimeZone}. + * Parsing matches the zone ID step by step as follows. + *

      + *
    • If the zone ID equals 'Z', the result is {@code ZoneOffset.UTC}. + *
    • If the zone ID consists of a single letter, the zone ID is invalid + * and {@code DateTimeException} is thrown. + *
    • If the zone ID starts with '+' or '-', the ID is parsed as a + * {@code ZoneOffset} using {@link ZoneOffset#of(String)}. + *
    • If the zone ID equals 'GMT', 'UTC' or 'UT' then the result is a {@code ZoneId} + * with the same ID and rules equivalent to {@code ZoneOffset.UTC}. + *
    • If the zone ID starts with 'UTC+', 'UTC-', 'GMT+', 'GMT-', 'UT+' or 'UT-' + * then the ID is a prefixed offset-based ID. The ID is split in two, with + * a two or three letter prefix and a suffix starting with the sign. + * The suffix is parsed as a {@link ZoneOffset#of(String) ZoneOffset}. + * The result will be a {@code ZoneId} with the specified UTC/GMT/UT prefix + * and the normalized offset ID as per {@link ZoneOffset#getId()}. + * The rules of the returned {@code ZoneId} will be equivalent to the + * parsed {@code ZoneOffset}. + *
    • All other IDs are parsed as region-based zone IDs. Region IDs must + * match the regular expression [A-Za-z][A-Za-z0-9~/._+-]+ + * otherwise a {@code DateTimeException} is thrown. If the zone ID is not + * in the configured set of IDs, {@code ZoneRulesException} is thrown. + * The detailed format of the region ID depends on the group supplying the data. + * The default set of data is supplied by the IANA Time Zone Database (TZDB). + * This has region IDs of the form '{area}/{city}', such as 'Europe/Paris' or 'America/New_York'. + * This is compatible with most IDs from {@link java.util.TimeZone}. + *
    * * @param zoneId the time-zone ID, not null * @return the zone ID, not null @@ -342,15 +397,29 @@ public abstract class ZoneId implements Serializable { * @throws ZoneRulesException if the zone ID is a region ID that cannot be found */ public static ZoneId of(String zoneId) { + return of(zoneId, true); + } + + /** + * Parses the ID, taking a flag to indicate whether {@code ZoneRulesException} + * should be thrown or not, used in deserialization. + * + * @param zoneId the time-zone ID, not null + * @param checkAvailable whether to check if the zone ID is available + * @return the zone ID, not null + * @throws DateTimeException if the ID format is invalid + * @throws ZoneRulesException if checking availability and the ID cannot be found + */ + static ZoneId of(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); if (zoneId.length() <= 1 || zoneId.startsWith("+") || zoneId.startsWith("-")) { return ZoneOffset.of(zoneId); } else if (zoneId.startsWith("UTC") || zoneId.startsWith("GMT")) { - return ofWithPrefix(zoneId, 3); + return ofWithPrefix(zoneId, 3, checkAvailable); } else if (zoneId.startsWith("UT")) { - return ofWithPrefix(zoneId, 2); + return ofWithPrefix(zoneId, 2, checkAvailable); } - return ZoneRegion.ofId(zoneId, true); + return ZoneRegion.ofId(zoneId, checkAvailable); } /** @@ -359,22 +428,25 @@ public abstract class ZoneId implements Serializable { * @param zoneId the time-zone ID, not null * @param prefixLength the length of the prefix, 2 or 3 * @return the zone ID, not null - * @return the zone ID, not null * @throws DateTimeException if the zone ID has an invalid format */ - private static ZoneId ofWithPrefix(String zoneId, int prefixLength) { - if (zoneId.length() == prefixLength || - (zoneId.length() == prefixLength + 1 && zoneId.charAt(prefixLength) == '0')) { - return ZoneOffset.UTC; + private static ZoneId ofWithPrefix(String zoneId, int prefixLength, boolean checkAvailable) { + String prefix = zoneId.substring(0, prefixLength); + if (zoneId.length() == prefixLength) { + return ZoneRegion.ofPrefixedOffset(prefix, ZoneOffset.UTC); } - if (zoneId.charAt(prefixLength) == '+' || zoneId.charAt(prefixLength) == '-') { - try { - return ZoneOffset.of(zoneId.substring(prefixLength)); - } catch (DateTimeException ex) { - throw new DateTimeException("Invalid ID for offset-based ZoneId: " + zoneId, ex); + if (zoneId.charAt(prefixLength) != '+' && zoneId.charAt(prefixLength) != '-') { + return ZoneRegion.ofId(zoneId, checkAvailable); // drop through to ZoneRulesProvider + } + try { + ZoneOffset offset = ZoneOffset.of(zoneId.substring(prefixLength)); + if (offset == ZoneOffset.UTC) { + return ZoneRegion.ofPrefixedOffset(prefix, offset); } + return ZoneRegion.ofPrefixedOffset(prefix + offset.toString(), offset); + } catch (DateTimeException ex) { + throw new DateTimeException("Invalid ID for offset-based ZoneId: " + zoneId, ex); } - throw new DateTimeException("Invalid ID for offset-based ZoneId: " + zoneId); } //----------------------------------------------------------------------- @@ -389,7 +461,7 @@ public abstract class ZoneId implements Serializable { * This factory converts the arbitrary temporal object to an instance of {@code ZoneId}. *

    * The conversion will try to obtain the zone in a way that favours region-based - * zones over offset-based zones using {@link Queries#zone()}. + * zones over offset-based zones using {@link TemporalQuery#zone()}. *

    * This method matches the signature of the functional interface {@link TemporalQuery} * allowing it to be used in queries via method reference, {@code ZoneId::from}. @@ -399,7 +471,7 @@ public abstract class ZoneId implements Serializable { * @throws DateTimeException if unable to convert to a {@code ZoneId} */ public static ZoneId from(TemporalAccessor temporal) { - ZoneId obj = temporal.query(Queries.zone()); + ZoneId obj = temporal.query(TemporalQuery.zone()); if (obj == null) { throw new DateTimeException("Unable to obtain ZoneId from TemporalAccessor: " + temporal.getClass()); } @@ -427,29 +499,6 @@ public abstract class ZoneId implements Serializable { */ public abstract String getId(); - //----------------------------------------------------------------------- - /** - * Gets the time-zone rules for this ID allowing calculations to be performed. - *

    - * The rules provide the functionality associated with a time-zone, - * such as finding the offset for a given instant or local date-time. - *

    - * A time-zone can be invalid if it is deserialized in a JVM which does not - * have the same rules loaded as the JVM that stored it. In this case, calling - * this method will throw an exception. - *

    - * The rules are supplied by {@link ZoneRulesProvider}. An advanced provider may - * support dynamic updates to the rules without restarting the JVM. - * If so, then the result of this method may change over time. - * Each individual call will be still remain thread-safe. - *

    - * {@link ZoneOffset} will always return a set of rules where the offset never changes. - * - * @return the rules, not null - * @throws ZoneRulesException if no rules are available for this ID - */ - public abstract ZoneRules getRules(); - //----------------------------------------------------------------------- /** * Gets the textual representation of the zone, such as 'British Time' or @@ -466,24 +515,88 @@ public abstract class ZoneId implements Serializable { * @return the text value of the zone, not null */ public String getDisplayName(TextStyle style, Locale locale) { - return new DateTimeFormatterBuilder().appendZoneText(style).toFormatter(locale).format(new TemporalAccessor() { + return new DateTimeFormatterBuilder().appendZoneText(style).toFormatter(locale).format(toTemporal()); + } + + /** + * Converts this zone to a {@code TemporalAccessor}. + *

    + * A {@code ZoneId} can be fully represented as a {@code TemporalAccessor}. + * However, the interface is not implemented by this class as most of the + * methods on the interface have no meaning to {@code ZoneId}. + *

    + * The returned temporal has no supported fields, with the query method + * supporting the return of the zone using {@link TemporalQuery#zoneId()}. + * + * @return a temporal equivalent to this zone, not null + */ + private TemporalAccessor toTemporal() { + return new TemporalAccessor() { @Override public boolean isSupported(TemporalField field) { return false; } @Override public long getLong(TemporalField field) { - throw new DateTimeException("Unsupported field: " + field); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { + if (query == TemporalQuery.zoneId()) { return (R) ZoneId.this; } return TemporalAccessor.super.query(query); } - }); + }; + } + + //----------------------------------------------------------------------- + /** + * Gets the time-zone rules for this ID allowing calculations to be performed. + *

    + * The rules provide the functionality associated with a time-zone, + * such as finding the offset for a given instant or local date-time. + *

    + * A time-zone can be invalid if it is deserialized in a Java Runtime which + * does not have the same rules loaded as the Java Runtime that stored it. + * In this case, calling this method will throw a {@code ZoneRulesException}. + *

    + * The rules are supplied by {@link ZoneRulesProvider}. An advanced provider may + * support dynamic updates to the rules without restarting the Java Runtime. + * If so, then the result of this method may change over time. + * Each individual call will be still remain thread-safe. + *

    + * {@link ZoneOffset} will always return a set of rules where the offset never changes. + * + * @return the rules, not null + * @throws ZoneRulesException if no rules are available for this ID + */ + public abstract ZoneRules getRules(); + + /** + * Normalizes the time-zone ID, returning a {@code ZoneOffset} where possible. + *

    + * The returns a normalized {@code ZoneId} that can be used in place of this ID. + * The result will have {@code ZoneRules} equivalent to those returned by this object, + * however the ID returned by {@code getId()} may be different. + *

    + * The normalization checks if the rules of this {@code ZoneId} have a fixed offset. + * If they do, then the {@code ZoneOffset} equal to that offset is returned. + * Otherwise {@code this} is returned. + * + * @return the time-zone unique ID, not null + */ + public ZoneId normalized() { + try { + ZoneRules rules = getRules(); + if (rules.isFixedOffset()) { + return rules.getOffset(Instant.EPOCH); + } + } catch (ZoneRulesException ex) { + // invalid ZoneRegion is not important to this method + } + return this; } //----------------------------------------------------------------------- @@ -536,6 +649,10 @@ public abstract class ZoneId implements Serializable { * out.writeByte(7); // identifies this as a ZoneId (not ZoneOffset) * out.writeUTF(zoneId); * + *

    + * When read back in, the {@code ZoneId} will be created as though using + * {@link #of(String)}, but without any exception in the case where the + * ID has a valid format, but is not in the known set of region-based IDs. * * @return the instance of {@code Ser}, not null */ diff --git a/jdk/src/share/classes/java/time/ZoneOffset.java b/jdk/src/share/classes/java/time/ZoneOffset.java index a468fbc691f..00f5dce485f 100644 --- a/jdk/src/share/classes/java/time/ZoneOffset.java +++ b/jdk/src/share/classes/java/time/ZoneOffset.java @@ -61,6 +61,7 @@ */ package java.time; +import java.time.temporal.UnsupportedTemporalTypeException; import static java.time.LocalTime.MINUTES_PER_HOUR; import static java.time.LocalTime.SECONDS_PER_HOUR; import static java.time.LocalTime.SECONDS_PER_MINUTE; @@ -73,7 +74,6 @@ import java.io.InvalidObjectException; import java.io.ObjectStreamException; import java.io.Serializable; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -322,7 +322,7 @@ public final class ZoneOffset * A {@code TemporalAccessor} represents some form of date and time information. * This factory converts the arbitrary temporal object to an instance of {@code ZoneOffset}. *

    - * The conversion uses the {@link Queries#offset()} query, which relies + * The conversion uses the {@link TemporalQuery#offset()} query, which relies * on extracting the {@link ChronoField#OFFSET_SECONDS OFFSET_SECONDS} field. *

    * This method matches the signature of the functional interface {@link TemporalQuery} @@ -333,7 +333,7 @@ public final class ZoneOffset * @throws DateTimeException if unable to convert to an {@code ZoneOffset} */ public static ZoneOffset from(TemporalAccessor temporal) { - ZoneOffset offset = temporal.query(Queries.offset()); + ZoneOffset offset = temporal.query(TemporalQuery.offset()); if (offset == null) { throw new DateTimeException("Unable to obtain ZoneOffset from TemporalAccessor: " + temporal.getClass()); } @@ -534,7 +534,7 @@ public final class ZoneOffset * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -544,6 +544,7 @@ public final class ZoneOffset * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override // override for Javadoc public ValueRange range(TemporalField field) { @@ -560,7 +561,7 @@ public final class ZoneOffset *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@code OFFSET_SECONDS} field returns the value of the offset. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -569,7 +570,10 @@ public final class ZoneOffset * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance @@ -577,7 +581,7 @@ public final class ZoneOffset if (field == OFFSET_SECONDS) { return totalSeconds; } else if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return range(field).checkValidIntValue(getLong(field), field); } @@ -591,7 +595,7 @@ public final class ZoneOffset *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@code OFFSET_SECONDS} field returns the value of the offset. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -601,6 +605,7 @@ public final class ZoneOffset * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -608,7 +613,7 @@ public final class ZoneOffset if (field == OFFSET_SECONDS) { return totalSeconds; } else if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -635,7 +640,7 @@ public final class ZoneOffset @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.offset() || query == Queries.zone()) { + if (query == TemporalQuery.offset() || query == TemporalQuery.zone()) { return (R) this; } return TemporalAccessor.super.query(query); diff --git a/jdk/src/share/classes/java/time/ZoneRegion.java b/jdk/src/share/classes/java/time/ZoneRegion.java index 2006703c8e8..912ee0499d3 100644 --- a/jdk/src/share/classes/java/time/ZoneRegion.java +++ b/jdk/src/share/classes/java/time/ZoneRegion.java @@ -94,11 +94,6 @@ final class ZoneRegion extends ZoneId implements Serializable { * Serialization version. */ private static final long serialVersionUID = 8386373296231747096L; - /** - * The regex pattern for region IDs. - */ - private static final Pattern PATTERN = Pattern.compile("[A-Za-z][A-Za-z0-9~/._+-]+"); - /** * The time-zone ID, not null. */ @@ -108,26 +103,6 @@ final class ZoneRegion extends ZoneId implements Serializable { */ private final transient ZoneRules rules; - /** - * Obtains an instance of {@code ZoneRegion} from an identifier without checking - * if the time-zone has available rules. - *

    - * This method parses the ID and applies any appropriate normalization. - * It does not validate the ID against the known set of IDs for which rules are available. - *

    - * This method is intended for advanced use cases. - * For example, consider a system that always retrieves time-zone rules from a remote server. - * Using this factory would allow a {@code ZoneRegion}, and thus a {@code ZonedDateTime}, - * to be created without loading the rules from the remote server. - * - * @param zoneId the time-zone ID, not null - * @return the zone ID, not null - * @throws DateTimeException if the ID format is invalid - */ - private static ZoneRegion ofLenient(String zoneId) { - return ofId(zoneId, false); - } - /** * Obtains an instance of {@code ZoneId} from an identifier. * @@ -139,12 +114,7 @@ final class ZoneRegion extends ZoneId implements Serializable { */ static ZoneRegion ofId(String zoneId, boolean checkAvailable) { Objects.requireNonNull(zoneId, "zoneId"); - if (zoneId.length() < 2 || - zoneId.startsWith("UT") || // includes UTC - zoneId.startsWith("GMT") || - (PATTERN.matcher(zoneId).matches() == false)) { - throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId); - } + checkName(zoneId); ZoneRules rules = null; try { // always attempt load for better behavior after deserialization @@ -157,6 +127,45 @@ final class ZoneRegion extends ZoneId implements Serializable { return new ZoneRegion(zoneId, rules); } + /** + * Checks that the given string is a legal ZondId name. + * + * @param zoneId the time-zone ID, not null + * @throws DateTimeException if the ID format is invalid + */ + private static void checkName(String zoneId) { + int n = zoneId.length(); + if (n < 2) { + throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId); + } + for (int i = 0; i < n; i++) { + char c = zoneId.charAt(i); + if (c >= 'a' && c <= 'z') continue; + if (c >= 'A' && c <= 'Z') continue; + if (c == '/' && i != 0) continue; + if (c >= '0' && c <= '9' && i != 0) continue; + if (c == '~' && i != 0) continue; + if (c == '.' && i != 0) continue; + if (c == '_' && i != 0) continue; + if (c == '+' && i != 0) continue; + if (c == '-' && i != 0) continue; + throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId); + } + } + + /** + * Obtains an instance of {@code ZoneId} wrapping an offset. + *

    + * For example, zone IDs like 'UTC', 'GMT', 'UT' and 'UTC+01:30' will be setup here. + * + * @param zoneId the time-zone ID, not null + * @param offset the offset, not null + * @return the zone ID, not null + */ + static ZoneRegion ofPrefixedOffset(String zoneId, ZoneOffset offset) { + return new ZoneRegion(zoneId, offset.getRules()); + } + //------------------------------------------------------------------------- /** * Constructor. @@ -218,7 +227,7 @@ final class ZoneRegion extends ZoneId implements Serializable { static ZoneId readExternal(DataInput in) throws IOException { String id = in.readUTF(); - return ofLenient(id); + return ZoneId.of(id, false); } } diff --git a/jdk/src/share/classes/java/time/ZonedDateTime.java b/jdk/src/share/classes/java/time/ZonedDateTime.java index d6e439b1bba..f5115c66873 100644 --- a/jdk/src/share/classes/java/time/ZonedDateTime.java +++ b/jdk/src/share/classes/java/time/ZonedDateTime.java @@ -72,7 +72,6 @@ import java.io.ObjectInput; import java.io.ObjectStreamException; import java.io.Serializable; import java.time.chrono.ChronoZonedDateTime; -import java.time.chrono.IsoChronology; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; @@ -84,6 +83,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.time.zone.ZoneOffsetTransition; import java.time.zone.ZoneRules; @@ -136,6 +136,11 @@ import java.util.Objects; * used, typically "summer" time.. Two additional methods, * {@link #withEarlierOffsetAtOverlap()} and {@link #withLaterOffsetAtOverlap()}, * help manage the case of an overlap. + *

    + * In terms of design, this class should be viewed primarily as the combination + * of a {@code LocalDateTime} and a {@code ZoneId}. The {@code ZoneOffset} is + * a vital, but secondary, piece of information, used to ensure that the class + * represents an instant, especially during a daylight savings overlap. * *

    Specification for implementors

    * A {@code ZonedDateTime} holds state equivalent to three separate objects, @@ -420,6 +425,9 @@ public final class ZonedDateTime Objects.requireNonNull(localDateTime, "localDateTime"); Objects.requireNonNull(offset, "offset"); Objects.requireNonNull(zone, "zone"); + if (zone.getRules().isValidOffset(localDateTime, offset)) { + return new ZonedDateTime(localDateTime, offset, zone); + } return create(localDateTime.toEpochSecond(offset), localDateTime.getNano(), zone); } @@ -615,17 +623,18 @@ public final class ZonedDateTime } /** - * Resolves the offset into this zoned date-time. + * Resolves the offset into this zoned date-time for the with methods. *

    - * This will use the new offset to find the instant, which is then looked up - * using the zone ID to find the actual offset to use. + * This typically ignores the offset, unless it can be used to switch offset in a DST overlap. * * @param offset the offset, not null * @return the zoned date-time, not null */ private ZonedDateTime resolveOffset(ZoneOffset offset) { - long epSec = dateTime.toEpochSecond(offset); - return create(epSec, dateTime.getNano(), zone); + if (offset.equals(this.offset) == false && zone.getRules().isValidOffset(dateTime, offset)) { + return new ZonedDateTime(dateTime, offset, zone); + } + return this; } //----------------------------------------------------------------------- @@ -663,7 +672,7 @@ public final class ZonedDateTime *

  • {@code ALIGNED_WEEK_OF_MONTH} *
  • {@code ALIGNED_WEEK_OF_YEAR} *
  • {@code MONTH_OF_YEAR} - *
  • {@code EPOCH_MONTH} + *
  • {@code PROLEPTIC_MONTH} *
  • {@code YEAR_OF_ERA} *
  • {@code YEAR} *
  • {@code ERA} @@ -696,7 +705,7 @@ public final class ZonedDateTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return * appropriate range instances. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} @@ -706,6 +715,7 @@ public final class ZonedDateTime * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ @Override public ValueRange range(TemporalField field) { @@ -729,9 +739,9 @@ public final class ZonedDateTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time, except {@code NANO_OF_DAY}, {@code MICRO_OF_DAY}, - * {@code EPOCH_DAY}, {@code EPOCH_MONTH} and {@code INSTANT_SECONDS} which are too + * {@code EPOCH_DAY}, {@code PROLEPTIC_MONTH} and {@code INSTANT_SECONDS} which are too * large to fit in an {@code int} and throw a {@code DateTimeException}. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -740,15 +750,20 @@ public final class ZonedDateTime * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance public int get(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { - case INSTANT_SECONDS: throw new DateTimeException("Field too large for an int: " + field); - case OFFSET_SECONDS: return getOffset().getTotalSeconds(); + case INSTANT_SECONDS: + throw new UnsupportedTemporalTypeException("Invalid field 'InstantSeconds' for get() method, use getLong() instead"); + case OFFSET_SECONDS: + return getOffset().getTotalSeconds(); } return dateTime.get(field); } @@ -765,7 +780,7 @@ public final class ZonedDateTime * If the field is a {@link ChronoField} then the query is implemented here. * The {@link #isSupported(TemporalField) supported fields} will return valid * values based on this date-time. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -775,6 +790,7 @@ public final class ZonedDateTime * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1115,7 +1131,7 @@ public final class ZonedDateTime *

    * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link java.time.temporal.Adjusters}. + * A selection of common adjustments is provided in {@link TemporalAdjuster}. * These include finding the "last day of the month" and "next Wednesday". * Key date-time classes also implement the {@code TemporalAdjuster} interface, * such as {@link Month} and {@link java.time.MonthDay MonthDay}. @@ -1137,15 +1153,12 @@ public final class ZonedDateTime * result = zonedDateTime.with(time); * *

    - * {@link ZoneOffset} also implements {@code TemporalAdjuster} however it is less likely - * that setting the offset will have the effect you expect. When an offset is passed in, - * the local date-time is combined with the new offset to form an {@code Instant}. - * The instant and original zone are then used to create the result. - * This algorithm means that it is quite likely that the output has a different offset - * to the specified offset. It will however work correctly when passing in the offset - * applicable for the instant of the zoned date-time, and will work correctly if passing - * one of the two valid offsets during a daylight savings overlap when the same local time - * occurs twice. + * {@link ZoneOffset} also implements {@code TemporalAdjuster} however using it + * as an argument typically has no effect. The offset of a {@code ZonedDateTime} is + * controlled primarily by the time-zone. As such, changing the offset does not generally + * make sense, because there is only one valid offset for the local date-time and zone. + * If the zoned date-time is in a daylight savings overlap, then the offset is used + * to switch between the two valid offsets. In all other cases, the offset is ignored. *

    * The result of this method is obtained by invoking the * {@link TemporalAdjuster#adjustInto(Temporal)} method on the @@ -1167,6 +1180,9 @@ public final class ZonedDateTime return resolveLocal(LocalDateTime.of(dateTime.toLocalDate(), (LocalTime) adjuster)); } else if (adjuster instanceof LocalDateTime) { return resolveLocal((LocalDateTime) adjuster); + } else if (adjuster instanceof OffsetDateTime) { + OffsetDateTime odt = (OffsetDateTime) adjuster; + return ofLocal(odt.toLocalDateTime(), zone, odt.getOffset()); } else if (adjuster instanceof Instant) { Instant instant = (Instant) adjuster; return create(instant.getEpochSecond(), instant.getNano(), zone); @@ -1197,15 +1213,13 @@ public final class ZonedDateTime * The result will have an offset derived from the new instant and original zone. * If the new instant value is outside the valid range then a {@code DateTimeException} will be thrown. *

    - * The {@code OFFSET_SECONDS} field will return a date-time calculated using the specified offset. - * The local date-time is combined with the new offset to form an {@code Instant}. - * The instant and original zone are then used to create the result. - * This algorithm means that it is quite likely that the output has a different offset - * to the specified offset. It will however work correctly when passing in the offset - * applicable for the instant of the zoned date-time, and will work correctly if passing - * one of the two valid offsets during a daylight savings overlap when the same local time - * occurs twice. If the new offset value is outside the valid range then a - * {@code DateTimeException} will be thrown. + * The {@code OFFSET_SECONDS} field will typically be ignored. + * The offset of a {@code ZonedDateTime} is controlled primarily by the time-zone. + * As such, changing the offset does not generally make sense, because there is only + * one valid offset for the local date-time and zone. + * If the zoned date-time is in a daylight savings overlap, then the offset is used + * to switch between the two valid offsets. In all other cases, the offset is ignored. + * If the new offset value is outside the valid range then a {@code DateTimeException} will be thrown. *

    * The other {@link #isSupported(TemporalField) supported fields} will behave as per * the matching method on {@link LocalDateTime#with(TemporalField, long) LocalDateTime}. @@ -1214,7 +1228,7 @@ public final class ZonedDateTime * then the offset will be retained if possible, otherwise the earlier offset will be used. * If in a gap, the local date-time will be adjusted forward by the length of the gap. *

    - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -1227,6 +1241,7 @@ public final class ZonedDateTime * @param newValue the new value of the field in the result * @return a {@code ZonedDateTime} based on {@code this} with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1234,11 +1249,11 @@ public final class ZonedDateTime if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; switch (f) { - case INSTANT_SECONDS: return create(newValue, getNano(), zone); - case OFFSET_SECONDS: { + case INSTANT_SECONDS: + return create(newValue, getNano(), zone); + case OFFSET_SECONDS: ZoneOffset offset = ZoneOffset.ofTotalSeconds(f.checkValidIntValue(newValue)); return resolveOffset(offset); - } } return resolveLocal(dateTime.with(field, newValue)); } @@ -1453,6 +1468,7 @@ public final class ZonedDateTime * @param unit the unit to truncate to, not null * @return a {@code ZonedDateTime} based on this date-time with the time truncated, not null * @throws DateTimeException if unable to truncate + * @throws UnsupportedTemporalTypeException if the unit is not supported */ public ZonedDateTime truncatedTo(TemporalUnit unit) { return resolveLocal(dateTime.truncatedTo(unit)); @@ -1518,6 +1534,7 @@ public final class ZonedDateTime * @param unit the unit of the amount to add, not null * @return a {@code ZonedDateTime} based on this date-time with the specified amount added, not null * @throws DateTimeException if the addition cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -1761,6 +1778,7 @@ public final class ZonedDateTime * @param unit the unit of the amount to subtract, not null * @return a {@code ZonedDateTime} based on this date-time with the specified amount subtracted, not null * @throws DateTimeException if the subtraction cannot be made + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -2025,6 +2043,7 @@ public final class ZonedDateTime * @param unit the unit to measure the period in, not null * @return the amount of the period between this date-time and the end date-time * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override @@ -2046,6 +2065,21 @@ public final class ZonedDateTime return unit.between(this, endDateTime); } + /** + * Formats this date-time using the specified formatter. + *

    + * This date-time will be passed to the formatter to produce a string. + * + * @param formatter the formatter to use, not null + * @return the formatted date-time string, not null + * @throws DateTimeException if an error occurs during printing + */ + @Override // override for Javadoc and performance + public String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Converts this date-time to an {@code OffsetDateTime}. @@ -2113,21 +2147,6 @@ public final class ZonedDateTime return str; } - /** - * Outputs this date-time as a {@code String} using the formatter. - *

    - * This date will be passed to the formatter - * {@link DateTimeFormatter#format(TemporalAccessor) format method}. - * - * @param formatter the formatter to use, not null - * @return the formatted date-time string, not null - * @throws DateTimeException if an error occurs during printing - */ - @Override // override for Javadoc - public String toString(DateTimeFormatter formatter) { - return ChronoZonedDateTime.super.toString(formatter); - } - //----------------------------------------------------------------------- /** * Writes the object using a diff --git a/jdk/src/share/classes/java/time/chrono/ChronoDateImpl.java b/jdk/src/share/classes/java/time/chrono/ChronoDateImpl.java index 29544a753ba..26203faa0af 100644 --- a/jdk/src/share/classes/java/time/chrono/ChronoDateImpl.java +++ b/jdk/src/share/classes/java/time/chrono/ChronoDateImpl.java @@ -59,19 +59,18 @@ package java.time.chrono; import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR_OF_ERA; import java.io.Serializable; import java.time.DateTimeException; -import java.time.LocalDate; -import java.time.LocalTime; -import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ChronoLocalDateTime; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.time.temporal.ValueRange; +import java.util.Objects; /** * A date expressed in terms of a standard year-month-day calendar system. @@ -97,12 +96,12 @@ import java.time.temporal.TemporalUnit; * // Enumerate the list of available calendars and print today for each * Set<Chronology> chronos = Chronology.getAvailableChronologies(); * for (Chronology chrono : chronos) { - * ChronoLocalDate date = chrono.dateNow(); + * ChronoLocalDate<?> date = chrono.dateNow(); * System.out.printf(" %20s: %s%n", chrono.getID(), date.toString()); * } * * // Print the Hijrah date and calendar - * ChronoLocalDate date = Chronology.of("Hijrah").dateNow(); + * ChronoLocalDate<?> date = Chronology.of("Hijrah").dateNow(); * int day = date.get(ChronoField.DAY_OF_MONTH); * int dow = date.get(ChronoField.DAY_OF_WEEK); * int month = date.get(ChronoField.MONTH_OF_YEAR); @@ -111,10 +110,10 @@ import java.time.temporal.TemporalUnit; * dow, day, month, year); * // Print today's date and the last day of the year - * ChronoLocalDate now1 = Chronology.of("Hijrah").dateNow(); - * ChronoLocalDate first = now1.with(ChronoField.DAY_OF_MONTH, 1) + * ChronoLocalDate<?> now1 = Chronology.of("Hijrah").dateNow(); + * ChronoLocalDate<?> first = now1.with(ChronoField.DAY_OF_MONTH, 1) * .with(ChronoField.MONTH_OF_YEAR, 1); - * ChronoLocalDate last = first.plus(1, ChronoUnit.YEARS) + * ChronoLocalDate<?> last = first.plus(1, ChronoUnit.YEARS) * .minus(1, ChronoUnit.DAYS); * System.out.printf(" Today is %s: start: %s; end: %s%n", last.getChronology().getID(), * first, last); @@ -168,7 +167,7 @@ abstract class ChronoDateImpl> case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); case ERAS: return with(ERA, Math.addExact(getLong(ERA), amountToAdd)); } - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return ChronoLocalDate.super.plus(amountToAdd, unit); } @@ -323,6 +322,8 @@ abstract class ChronoDateImpl> */ @Override public long periodUntil(Temporal endDateTime, TemporalUnit unit) { + Objects.requireNonNull(endDateTime, "endDateTime"); + Objects.requireNonNull(unit, "unit"); if (endDateTime instanceof ChronoLocalDate == false) { throw new DateTimeException("Unable to calculate period between objects of two different types"); } @@ -331,11 +332,35 @@ abstract class ChronoDateImpl> throw new DateTimeException("Unable to calculate period between two different chronologies"); } if (unit instanceof ChronoUnit) { - return LocalDate.from(this).periodUntil(end, unit); // TODO: this is wrong + switch ((ChronoUnit) unit) { + case DAYS: return daysUntil(end); + case WEEKS: return daysUntil(end) / 7; + case MONTHS: return monthsUntil(end); + case YEARS: return monthsUntil(end) / 12; + case DECADES: return monthsUntil(end) / 120; + case CENTURIES: return monthsUntil(end) / 1200; + case MILLENNIA: return monthsUntil(end) / 12000; + case ERAS: return end.getLong(ERA) - getLong(ERA); + } + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.between(this, endDateTime); } + private long daysUntil(ChronoLocalDate end) { + return end.toEpochDay() - toEpochDay(); // no overflow + } + + private long monthsUntil(ChronoLocalDate end) { + ValueRange range = getChronology().range(MONTH_OF_YEAR); + if (range.getMaximum() != 12) { + throw new IllegalStateException("ChronoDateImpl only supports Chronologies with 12 months per year"); + } + long packed1 = getLong(PROLEPTIC_MONTH) * 32L + get(DAY_OF_MONTH); // no overflow + long packed2 = end.getLong(PROLEPTIC_MONTH) * 32L + end.get(DAY_OF_MONTH); // no overflow + return (packed2 - packed1) / 32; + } + @Override public boolean equals(Object obj) { if (this == obj) { diff --git a/jdk/src/share/classes/java/time/chrono/ChronoLocalDate.java b/jdk/src/share/classes/java/time/chrono/ChronoLocalDate.java index 124885098b4..4f648c93725 100644 --- a/jdk/src/share/classes/java/time/chrono/ChronoLocalDate.java +++ b/jdk/src/share/classes/java/time/chrono/ChronoLocalDate.java @@ -73,7 +73,6 @@ import java.time.Period; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -81,6 +80,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.Comparator; import java.util.Objects; @@ -249,25 +249,55 @@ public interface ChronoLocalDate> extends Temporal, TemporalAdjuster, Comparable> { /** - * Comparator for two {@code ChronoLocalDate}s ignoring the chronology. + * Gets a comparator that compares {@code ChronoLocalDate} in + * time-line order ignoring the chronology. *

    * This comparator differs from the comparison in {@link #compareTo} in that it * only compares the underlying date and not the chronology. * This allows dates in different calendar systems to be compared based - * on the time-line position. - * This is equivalent to using {@code Long.compare(date1.toEpochDay(), date2.toEpochDay())}. + * on the position of the date on the local time-line. + * The underlying comparison is equivalent to comparing the epoch-day. * * @see #isAfter * @see #isBefore * @see #isEqual */ - public static final Comparator> DATE_COMPARATOR = - new Comparator>() { - @Override - public int compare(ChronoLocalDate date1, ChronoLocalDate date2) { - return Long.compare(date1.toEpochDay(), date2.toEpochDay()); + static Comparator> timeLineOrder() { + return Chronology.DATE_ORDER; + } + + //----------------------------------------------------------------------- + /** + * Obtains an instance of {@code ChronoLocalDate} from a temporal object. + *

    + * This obtains a local date based on the specified temporal. + * A {@code TemporalAccessor} represents an arbitrary set of date and time information, + * which this factory converts to an instance of {@code ChronoLocalDate}. + *

    + * The conversion extracts and combines the chronology and the date + * from the temporal object. The behavior is equivalent to using + * {@link Chronology#date(TemporalAccessor)} with the extracted chronology. + * Implementations are permitted to perform optimizations such as accessing + * those fields that are equivalent to the relevant objects. + *

    + * This method matches the signature of the functional interface {@link TemporalQuery} + * allowing it to be used as a query via method reference, {@code ChronoLocalDate::from}. + * + * @param temporal the temporal object to convert, not null + * @return the date, not null + * @throws DateTimeException if unable to convert to a {@code ChronoLocalDate} + * @see Chronology#date(TemporalAccessor) + */ + static ChronoLocalDate from(TemporalAccessor temporal) { + if (temporal instanceof ChronoLocalDate) { + return (ChronoLocalDate) temporal; } - }; + Chronology chrono = temporal.query(TemporalQuery.chronology()); + if (chrono == null) { + throw new DateTimeException("Unable to obtain ChronoLocalDate from TemporalAccessor: " + temporal.getClass()); + } + return chrono.date(temporal); + } //----------------------------------------------------------------------- /** @@ -295,7 +325,7 @@ public interface ChronoLocalDate> * * @return the chronology specific era constant applicable at this date, not null */ - public default Era getEra() { + default Era getEra() { return getChronology().eraOf(get(ERA)); } @@ -310,7 +340,7 @@ public interface ChronoLocalDate> * * @return true if this date is in a leap year, false otherwise */ - public default boolean isLeapYear() { + default boolean isLeapYear() { return getChronology().isLeapYear(getLong(YEAR)); } @@ -332,14 +362,14 @@ public interface ChronoLocalDate> * * @return the length of the year in days */ - public default int lengthOfYear() { + default int lengthOfYear() { return (isLeapYear() ? 366 : 365); } @Override - public default boolean isSupported(TemporalField field) { + default boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { - return ((ChronoField) field).isDateField(); + return field.isDateBased(); } return field != null && field.isSupportedBy(this); } @@ -352,19 +382,20 @@ public interface ChronoLocalDate> * @throws ArithmeticException {@inheritDoc} */ @Override - public default D with(TemporalAdjuster adjuster) { + default D with(TemporalAdjuster adjuster) { return (D) getChronology().ensureChronoLocalDate(Temporal.super.with(adjuster)); } /** * {@inheritDoc} * @throws DateTimeException {@inheritDoc} + * @throws UnsupportedTemporalTypeException {@inheritDoc} * @throws ArithmeticException {@inheritDoc} */ @Override - public default D with(TemporalField field, long newValue) { + default D with(TemporalField field, long newValue) { if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return (D) getChronology().ensureChronoLocalDate(field.adjustInto(this, newValue)); } @@ -375,7 +406,7 @@ public interface ChronoLocalDate> * @throws ArithmeticException {@inheritDoc} */ @Override - public default D plus(TemporalAmount amount) { + default D plus(TemporalAmount amount) { return (D) getChronology().ensureChronoLocalDate(Temporal.super.plus(amount)); } @@ -385,9 +416,9 @@ public interface ChronoLocalDate> * @throws ArithmeticException {@inheritDoc} */ @Override - public default D plus(long amountToAdd, TemporalUnit unit) { + default D plus(long amountToAdd, TemporalUnit unit) { if (unit instanceof ChronoUnit) { - throw new DateTimeException("Unsupported unit: " + unit.getName()); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return (D) getChronology().ensureChronoLocalDate(unit.addTo(this, amountToAdd)); } @@ -398,17 +429,18 @@ public interface ChronoLocalDate> * @throws ArithmeticException {@inheritDoc} */ @Override - public default D minus(TemporalAmount amount) { + default D minus(TemporalAmount amount) { return (D) getChronology().ensureChronoLocalDate(Temporal.super.minus(amount)); } /** * {@inheritDoc} * @throws DateTimeException {@inheritDoc} + * @throws UnsupportedTemporalTypeException {@inheritDoc} * @throws ArithmeticException {@inheritDoc} */ @Override - public default D minus(long amountToSubtract, TemporalUnit unit) { + default D minus(long amountToSubtract, TemporalUnit unit) { return (D) getChronology().ensureChronoLocalDate(Temporal.super.minus(amountToSubtract, unit)); } @@ -433,14 +465,14 @@ public interface ChronoLocalDate> */ @SuppressWarnings("unchecked") @Override - public default R query(TemporalQuery query) { - if (query == Queries.zoneId() || query == Queries.zone() || query == Queries.offset()) { + default R query(TemporalQuery query) { + if (query == TemporalQuery.zoneId() || query == TemporalQuery.zone() || query == TemporalQuery.offset()) { return null; - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return null; - } else if (query == Queries.chronology()) { + } else if (query == TemporalQuery.chronology()) { return (R) getChronology(); - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) DAYS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -473,7 +505,7 @@ public interface ChronoLocalDate> * @throws ArithmeticException if numeric overflow occurs */ @Override - public default Temporal adjustInto(Temporal temporal) { + default Temporal adjustInto(Temporal temporal) { return temporal.with(EPOCH_DAY, toEpochDay()); } @@ -522,7 +554,7 @@ public interface ChronoLocalDate> * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc - public abstract long periodUntil(Temporal endDate, TemporalUnit unit); + long periodUntil(Temporal endDate, TemporalUnit unit); /** * Calculates the period between this date and another date as a {@code Period}. @@ -530,13 +562,11 @@ public interface ChronoLocalDate> * This calculates the period between two dates in terms of years, months and days. * The start and end points are {@code this} and the specified date. * The result will be negative if the end is before the start. - *

    - * The calculation is performed using the the chronology of this date. - * If necessary, the input date will be converted to match. - *

    - * The result of this method can be a negative period if the end is before the start. * The negative sign will be the same in each of year, month and day. *

    + * The calculation is performed using the chronology of this date. + * If necessary, the input date will be converted to match. + *

    * This instance is immutable and unaffected by this method call. * * @param endDate the end date, exclusive, which may be in any chronology, not null @@ -544,7 +574,26 @@ public interface ChronoLocalDate> * @throws DateTimeException if the period cannot be calculated * @throws ArithmeticException if numeric overflow occurs */ - public abstract Period periodUntil(ChronoLocalDate endDate); + Period periodUntil(ChronoLocalDate endDate); + + /** + * Formats this date using the specified formatter. + *

    + * This date will be passed to the formatter to produce a string. + *

    + * The default implementation must behave as follows: + *

    +     *  return formatter.format(this);
    +     * 
    + * + * @param formatter the formatter to use, not null + * @return the formatted date string, not null + * @throws DateTimeException if an error occurs during printing + */ + default String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } //----------------------------------------------------------------------- /** @@ -556,7 +605,7 @@ public interface ChronoLocalDate> * @param localTime the local time to use, not null * @return the local date-time formed from this date and the specified time, not null */ - public default ChronoLocalDateTime atTime(LocalTime localTime) { + default ChronoLocalDateTime atTime(LocalTime localTime) { return (ChronoLocalDateTime)ChronoLocalDateTimeImpl.of(this, localTime); } @@ -572,7 +621,7 @@ public interface ChronoLocalDate> * * @return the Epoch Day equivalent to this date */ - public default long toEpochDay() { + default long toEpochDay() { return getLong(EPOCH_DAY); } @@ -606,7 +655,7 @@ public interface ChronoLocalDate> * @return the comparator value, negative if less, positive if greater */ @Override - public default int compareTo(ChronoLocalDate other) { + default int compareTo(ChronoLocalDate other) { int cmp = Long.compare(toEpochDay(), other.toEpochDay()); if (cmp == 0) { cmp = getChronology().compareTo(other.getChronology()); @@ -628,7 +677,7 @@ public interface ChronoLocalDate> * @param other the other date to compare to, not null * @return true if this is after the specified date */ - public default boolean isAfter(ChronoLocalDate other) { + default boolean isAfter(ChronoLocalDate other) { return this.toEpochDay() > other.toEpochDay(); } @@ -646,7 +695,7 @@ public interface ChronoLocalDate> * @param other the other date to compare to, not null * @return true if this is before the specified date */ - public default boolean isBefore(ChronoLocalDate other) { + default boolean isBefore(ChronoLocalDate other) { return this.toEpochDay() < other.toEpochDay(); } @@ -664,7 +713,7 @@ public interface ChronoLocalDate> * @param other the other date to compare to, not null * @return true if the underlying date is equal to the specified date */ - public default boolean isEqual(ChronoLocalDate other) { + default boolean isEqual(ChronoLocalDate other) { return this.toEpochDay() == other.toEpochDay(); } @@ -695,28 +744,11 @@ public interface ChronoLocalDate> /** * Outputs this date as a {@code String}. *

    - * The output will include the full local date and the chronology ID. + * The output will include the full local date. * * @return the formatted date, not null */ @Override String toString(); - /** - * Outputs this date as a {@code String} using the formatter. - *

    - * The default implementation must behave as follows: - *

    -     *  return formatter.format(this);
    -     * 
    - * - * @param formatter the formatter to use, not null - * @return the formatted date string, not null - * @throws DateTimeException if an error occurs during printing - */ - public default String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - } diff --git a/jdk/src/share/classes/java/time/chrono/ChronoLocalDateTime.java b/jdk/src/share/classes/java/time/chrono/ChronoLocalDateTime.java index f06bd650f1f..d706db128f3 100644 --- a/jdk/src/share/classes/java/time/chrono/ChronoLocalDateTime.java +++ b/jdk/src/share/classes/java/time/chrono/ChronoLocalDateTime.java @@ -73,7 +73,6 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -119,29 +118,57 @@ public interface ChronoLocalDateTime> extends Temporal, TemporalAdjuster, Comparable> { /** - * Comparator for two {@code ChronoLocalDateTime} instances ignoring the chronology. + * Gets a comparator that compares {@code ChronoLocalDateTime} in + * time-line order ignoring the chronology. *

    - * This method differs from the comparison in {@link #compareTo} in that it - * only compares the underlying date and not the chronology. + * This comparator differs from the comparison in {@link #compareTo} in that it + * only compares the underlying date-time and not the chronology. * This allows dates in different calendar systems to be compared based - * on the time-line position. + * on the position of the date-time on the local time-line. + * The underlying comparison is equivalent to comparing the epoch-day and nano-of-day. * * @see #isAfter * @see #isBefore * @see #isEqual */ - Comparator> DATE_TIME_COMPARATOR = - new Comparator>() { - @Override - public int compare(ChronoLocalDateTime datetime1, ChronoLocalDateTime datetime2) { - int cmp = Long.compare(datetime1.toLocalDate().toEpochDay(), datetime2.toLocalDate().toEpochDay()); - if (cmp == 0) { - cmp = Long.compare(datetime1.toLocalTime().toNanoOfDay(), datetime2.toLocalTime().toNanoOfDay()); - } - return cmp; - } - }; + static Comparator> timeLineOrder() { + return Chronology.DATE_TIME_ORDER; + } + //----------------------------------------------------------------------- + /** + * Obtains an instance of {@code ChronoLocalDateTime} from a temporal object. + *

    + * This obtains a local date-time based on the specified temporal. + * A {@code TemporalAccessor} represents an arbitrary set of date and time information, + * which this factory converts to an instance of {@code ChronoLocalDateTime}. + *

    + * The conversion extracts and combines the chronology and the date-time + * from the temporal object. The behavior is equivalent to using + * {@link Chronology#localDateTime(TemporalAccessor)} with the extracted chronology. + * Implementations are permitted to perform optimizations such as accessing + * those fields that are equivalent to the relevant objects. + *

    + * This method matches the signature of the functional interface {@link TemporalQuery} + * allowing it to be used as a query via method reference, {@code ChronoLocalDateTime::from}. + * + * @param temporal the temporal object to convert, not null + * @return the date-time, not null + * @throws DateTimeException if unable to convert to a {@code ChronoLocalDateTime} + * @see Chronology#localDateTime(TemporalAccessor) + */ + static ChronoLocalDateTime from(TemporalAccessor temporal) { + if (temporal instanceof ChronoLocalDateTime) { + return (ChronoLocalDateTime) temporal; + } + Chronology chrono = temporal.query(TemporalQuery.chronology()); + if (chrono == null) { + throw new DateTimeException("Unable to obtain ChronoLocalDateTime from TemporalAccessor: " + temporal.getClass()); + } + return chrono.localDateTime(temporal); + } + + //----------------------------------------------------------------------- /** * Gets the local date part of this date-time. *

    @@ -163,7 +190,7 @@ public interface ChronoLocalDateTime> LocalTime toLocalTime(); @Override // Override to provide javadoc - public boolean isSupported(TemporalField field); + boolean isSupported(TemporalField field); //----------------------------------------------------------------------- // override for covariant return type @@ -173,7 +200,7 @@ public interface ChronoLocalDateTime> * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoLocalDateTime with(TemporalAdjuster adjuster) { + default ChronoLocalDateTime with(TemporalAdjuster adjuster) { return (ChronoLocalDateTime)(toLocalDate().getChronology().ensureChronoLocalDateTime(Temporal.super.with(adjuster))); } @@ -191,7 +218,7 @@ public interface ChronoLocalDateTime> * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoLocalDateTime plus(TemporalAmount amount) { + default ChronoLocalDateTime plus(TemporalAmount amount) { return (ChronoLocalDateTime)(toLocalDate().getChronology().ensureChronoLocalDateTime(Temporal.super.plus(amount))); } @@ -209,7 +236,7 @@ public interface ChronoLocalDateTime> * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoLocalDateTime minus(TemporalAmount amount) { + default ChronoLocalDateTime minus(TemporalAmount amount) { return (ChronoLocalDateTime)(toLocalDate().getChronology().ensureChronoLocalDateTime(Temporal.super.minus(amount))); } @@ -219,7 +246,7 @@ public interface ChronoLocalDateTime> * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoLocalDateTime minus(long amountToSubtract, TemporalUnit unit) { + default ChronoLocalDateTime minus(long amountToSubtract, TemporalUnit unit) { return (ChronoLocalDateTime)(toLocalDate().getChronology().ensureChronoLocalDateTime(Temporal.super.minus(amountToSubtract, unit))); } @@ -244,14 +271,14 @@ public interface ChronoLocalDateTime> */ @SuppressWarnings("unchecked") @Override - public default R query(TemporalQuery query) { - if (query == Queries.zoneId() || query == Queries.zone() || query == Queries.offset()) { + default R query(TemporalQuery query) { + if (query == TemporalQuery.zoneId() || query == TemporalQuery.zone() || query == TemporalQuery.offset()) { return null; - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return (R) toLocalTime(); - } else if (query == Queries.chronology()) { + } else if (query == TemporalQuery.chronology()) { return (R) toLocalDate().getChronology(); - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -285,12 +312,31 @@ public interface ChronoLocalDateTime> * @throws ArithmeticException if numeric overflow occurs */ @Override - public default Temporal adjustInto(Temporal temporal) { + default Temporal adjustInto(Temporal temporal) { return temporal .with(EPOCH_DAY, toLocalDate().toEpochDay()) .with(NANO_OF_DAY, toLocalTime().toNanoOfDay()); } + /** + * Formats this date-time using the specified formatter. + *

    + * This date-time will be passed to the formatter to produce a string. + *

    + * The default implementation must behave as follows: + *

    +     *  return formatter.format(this);
    +     * 
    + * + * @param formatter the formatter to use, not null + * @return the formatted date-time string, not null + * @throws DateTimeException if an error occurs during printing + */ + default String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Combines this time with a time-zone to create a {@code ChronoZonedDateTime}. @@ -334,7 +380,7 @@ public interface ChronoLocalDateTime> * @param offset the offset to use for the conversion, not null * @return an {@code Instant} representing the same instant, not null */ - public default Instant toInstant(ZoneOffset offset) { + default Instant toInstant(ZoneOffset offset) { return Instant.ofEpochSecond(toEpochSecond(offset), toLocalTime().getNano()); } @@ -352,7 +398,7 @@ public interface ChronoLocalDateTime> * @param offset the offset to use for the conversion, not null * @return the number of seconds from the epoch of 1970-01-01T00:00:00Z */ - public default long toEpochSecond(ZoneOffset offset) { + default long toEpochSecond(ZoneOffset offset) { Objects.requireNonNull(offset, "offset"); long epochDay = toLocalDate().toEpochDay(); long secs = epochDay * 86400 + toLocalTime().toSecondOfDay(); @@ -388,7 +434,7 @@ public interface ChronoLocalDateTime> * @return the comparator value, negative if less, positive if greater */ @Override - public default int compareTo(ChronoLocalDateTime other) { + default int compareTo(ChronoLocalDateTime other) { int cmp = toLocalDate().compareTo(other.toLocalDate()); if (cmp == 0) { cmp = toLocalTime().compareTo(other.toLocalTime()); @@ -413,7 +459,7 @@ public interface ChronoLocalDateTime> * @param other the other date-time to compare to, not null * @return true if this is after the specified date-time */ - public default boolean isAfter(ChronoLocalDateTime other) { + default boolean isAfter(ChronoLocalDateTime other) { long thisEpDay = this.toLocalDate().toEpochDay(); long otherEpDay = other.toLocalDate().toEpochDay(); return thisEpDay > otherEpDay || @@ -434,7 +480,7 @@ public interface ChronoLocalDateTime> * @param other the other date-time to compare to, not null * @return true if this is before the specified date-time */ - public default boolean isBefore(ChronoLocalDateTime other) { + default boolean isBefore(ChronoLocalDateTime other) { long thisEpDay = this.toLocalDate().toEpochDay(); long otherEpDay = other.toLocalDate().toEpochDay(); return thisEpDay < otherEpDay || @@ -455,7 +501,7 @@ public interface ChronoLocalDateTime> * @param other the other date-time to compare to, not null * @return true if the underlying date-time is equal to the specified date-time on the timeline */ - public default boolean isEqual(ChronoLocalDateTime other) { + default boolean isEqual(ChronoLocalDateTime other) { // Do the time check first, it is cheaper than computing EPOCH day. return this.toLocalTime().toNanoOfDay() == other.toLocalTime().toNanoOfDay() && this.toLocalDate().toEpochDay() == other.toLocalDate().toEpochDay(); @@ -484,27 +530,11 @@ public interface ChronoLocalDateTime> /** * Outputs this date-time as a {@code String}. *

    - * The output will include the full local date-time and the chronology ID. + * The output will include the full local date-time. * * @return a string representation of this date-time, not null */ @Override String toString(); - /** - * Outputs this date-time as a {@code String} using the formatter. - *

    - * The default implementation must behave as follows: - *

    -     *  return formatter.format(this);
    -     * 
    - * - * @param formatter the formatter to use, not null - * @return the formatted date-time string, not null - * @throws DateTimeException if an error occurs during printing - */ - public default String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } } diff --git a/jdk/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java b/jdk/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java index 98751676a00..fd6e7c05c46 100644 --- a/jdk/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java +++ b/jdk/src/share/classes/java/time/chrono/ChronoLocalDateTimeImpl.java @@ -171,6 +171,7 @@ final class ChronoLocalDateTimeImpl> * @param time the local time, not null * @return the local date-time, not null */ + @SuppressWarnings("rawtypes") static ChronoLocalDateTimeImpl of(ChronoLocalDate date, LocalTime time) { return new ChronoLocalDateTimeImpl(date, time); } @@ -201,8 +202,8 @@ final class ChronoLocalDateTimeImpl> return this; } // Validate that the new Temporal is a ChronoLocalDate (and not something else) - D cd = (D)date.getChronology().ensureChronoLocalDate(newDate); - return new ChronoLocalDateTimeImpl<>((D)cd, newTime); + D cd = (D) date.getChronology().ensureChronoLocalDate(newDate); + return new ChronoLocalDateTimeImpl<>(cd, newTime); } //----------------------------------------------------------------------- @@ -221,7 +222,7 @@ final class ChronoLocalDateTimeImpl> public boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return f.isDateField() || f.isTimeField(); + return f.isDateBased() || f.isTimeBased(); } return field != null && field.isSupportedBy(this); } @@ -230,7 +231,7 @@ final class ChronoLocalDateTimeImpl> public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.range(field) : date.range(field)); + return (f.isTimeBased() ? time.range(field) : date.range(field)); } return field.rangeRefinedBy(this); } @@ -239,7 +240,7 @@ final class ChronoLocalDateTimeImpl> public int get(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.get(field) : date.get(field)); + return (f.isTimeBased() ? time.get(field) : date.get(field)); } return range(field).checkValidIntValue(getLong(field), field); } @@ -248,7 +249,7 @@ final class ChronoLocalDateTimeImpl> public long getLong(TemporalField field) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - return (f.isTimeField() ? time.getLong(field) : date.getLong(field)); + return (f.isTimeBased() ? time.getLong(field) : date.getLong(field)); } return field.getFrom(this); } @@ -272,7 +273,7 @@ final class ChronoLocalDateTimeImpl> public ChronoLocalDateTimeImpl with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - if (f.isTimeField()) { + if (f.isTimeBased()) { return with(date, time.with(field, newValue)); } else { return with(date.with(field, newValue), time); @@ -376,7 +377,7 @@ final class ChronoLocalDateTimeImpl> } D endDate = end.toLocalDate(); if (end.toLocalTime().isBefore(time)) { - endDate = (D)endDate.minus(1, ChronoUnit.DAYS); + endDate = endDate.minus(1, ChronoUnit.DAYS); } return date.periodUntil(endDate, unit); } @@ -403,7 +404,7 @@ final class ChronoLocalDateTimeImpl> } static ChronoLocalDateTime readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - ChronoLocalDate date = (ChronoLocalDate) in.readObject(); + ChronoLocalDate date = (ChronoLocalDate) in.readObject(); LocalTime time = (LocalTime) in.readObject(); return date.atTime(time); } diff --git a/jdk/src/share/classes/java/time/chrono/ChronoZonedDateTime.java b/jdk/src/share/classes/java/time/chrono/ChronoZonedDateTime.java index 92e018bf0ba..4307c104ab4 100644 --- a/jdk/src/share/classes/java/time/chrono/ChronoZonedDateTime.java +++ b/jdk/src/share/classes/java/time/chrono/ChronoZonedDateTime.java @@ -73,7 +73,6 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -81,6 +80,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Comparator; import java.util.Objects; @@ -119,30 +119,59 @@ public interface ChronoZonedDateTime> extends Temporal, Comparable> { /** - * Comparator for two {@code ChronoZonedDateTime} instances ignoring the chronology. + * Gets a comparator that compares {@code ChronoZonedDateTime} in + * time-line order ignoring the chronology. *

    - * This method differs from the comparison in {@link #compareTo} in that it - * only compares the underlying date and not the chronology. + * This comparator differs from the comparison in {@link #compareTo} in that it + * only compares the underlying instant and not the chronology. * This allows dates in different calendar systems to be compared based - * on the time-line position. + * on the position of the date-time on the instant time-line. + * The underlying comparison is equivalent to comparing the epoch-second and nano-of-second. * * @see #isAfter * @see #isBefore * @see #isEqual */ - Comparator> INSTANT_COMPARATOR = new Comparator>() { - @Override - public int compare(ChronoZonedDateTime datetime1, ChronoZonedDateTime datetime2) { - int cmp = Long.compare(datetime1.toEpochSecond(), datetime2.toEpochSecond()); - if (cmp == 0) { - cmp = Long.compare(datetime1.toLocalTime().toNanoOfDay(), datetime2.toLocalTime().toNanoOfDay()); - } - return cmp; - } - }; + static Comparator> timeLineOrder() { + return Chronology.INSTANT_ORDER; + } + //----------------------------------------------------------------------- + /** + * Obtains an instance of {@code ChronoZonedDateTime} from a temporal object. + *

    + * This creates a zoned date-time based on the specified temporal. + * A {@code TemporalAccessor} represents an arbitrary set of date and time information, + * which this factory converts to an instance of {@code ChronoZonedDateTime}. + *

    + * The conversion extracts and combines the chronology, date, time and zone + * from the temporal object. The behavior is equivalent to using + * {@link Chronology#zonedDateTime(TemporalAccessor)} with the extracted chronology. + * Implementations are permitted to perform optimizations such as accessing + * those fields that are equivalent to the relevant objects. + *

    + * This method matches the signature of the functional interface {@link TemporalQuery} + * allowing it to be used as a query via method reference, {@code ChronoZonedDateTime::from}. + * + * @param temporal the temporal objec t to convert, not null + * @return the date-time, not null + * @throws DateTimeException if unable to convert to a {@code ChronoZonedDateTime} + * @see Chronology#zonedDateTime(TemporalAccessor) + */ + static ChronoZonedDateTime from(TemporalAccessor temporal) { + if (temporal instanceof ChronoZonedDateTime) { + return (ChronoZonedDateTime) temporal; + } + Chronology chrono = temporal.query(TemporalQuery.chronology()); + if (chrono == null) { + throw new DateTimeException("Unable to obtain ChronoZonedDateTime from TemporalAccessor: " + temporal.getClass()); + } + return chrono.zonedDateTime(temporal); + } + + //----------------------------------------------------------------------- @Override - public default ValueRange range(TemporalField field) { + default ValueRange range(TemporalField field) { if (field instanceof ChronoField) { if (field == INSTANT_SECONDS || field == OFFSET_SECONDS) { return field.range(); @@ -153,11 +182,13 @@ public interface ChronoZonedDateTime> } @Override - public default int get(TemporalField field) { + default int get(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { - case INSTANT_SECONDS: throw new DateTimeException("Field too large for an int: " + field); - case OFFSET_SECONDS: return getOffset().getTotalSeconds(); + case INSTANT_SECONDS: + throw new UnsupportedTemporalTypeException("Invalid field 'InstantSeconds' for get() method, use getLong() instead"); + case OFFSET_SECONDS: + return getOffset().getTotalSeconds(); } return toLocalDateTime().get(field); } @@ -165,7 +196,7 @@ public interface ChronoZonedDateTime> } @Override - public default long getLong(TemporalField field) { + default long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { case INSTANT_SECONDS: return toEpochSecond(); @@ -184,7 +215,7 @@ public interface ChronoZonedDateTime> * * @return the date part of this date-time, not null */ - public default D toLocalDate() { + default D toLocalDate() { return toLocalDateTime().toLocalDate(); } @@ -196,7 +227,7 @@ public interface ChronoZonedDateTime> * * @return the time part of this date-time, not null */ - public default LocalTime toLocalTime() { + default LocalTime toLocalTime() { return toLocalDateTime().toLocalTime(); } @@ -306,7 +337,7 @@ public interface ChronoZonedDateTime> ChronoZonedDateTime withZoneSameInstant(ZoneId zone); @Override // Override to provide javadoc - public boolean isSupported(TemporalField field); + boolean isSupported(TemporalField field); //----------------------------------------------------------------------- // override for covariant return type @@ -316,7 +347,7 @@ public interface ChronoZonedDateTime> * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoZonedDateTime with(TemporalAdjuster adjuster) { + default ChronoZonedDateTime with(TemporalAdjuster adjuster) { return (ChronoZonedDateTime)(toLocalDate().getChronology().ensureChronoZonedDateTime(Temporal.super.with(adjuster))); } @@ -334,7 +365,7 @@ public interface ChronoZonedDateTime> * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoZonedDateTime plus(TemporalAmount amount) { + default ChronoZonedDateTime plus(TemporalAmount amount) { return (ChronoZonedDateTime)(toLocalDate().getChronology().ensureChronoZonedDateTime(Temporal.super.plus(amount))); } @@ -352,7 +383,7 @@ public interface ChronoZonedDateTime> * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoZonedDateTime minus(TemporalAmount amount) { + default ChronoZonedDateTime minus(TemporalAmount amount) { return (ChronoZonedDateTime)(toLocalDate().getChronology().ensureChronoZonedDateTime(Temporal.super.minus(amount))); } @@ -362,7 +393,7 @@ public interface ChronoZonedDateTime> * @throws ArithmeticException {@inheritDoc} */ @Override - public default ChronoZonedDateTime minus(long amountToSubtract, TemporalUnit unit) { + default ChronoZonedDateTime minus(long amountToSubtract, TemporalUnit unit) { return (ChronoZonedDateTime)(toLocalDate().getChronology().ensureChronoZonedDateTime(Temporal.super.minus(amountToSubtract, unit))); } @@ -387,16 +418,16 @@ public interface ChronoZonedDateTime> */ @SuppressWarnings("unchecked") @Override - public default R query(TemporalQuery query) { - if (query == Queries.zone() || query == Queries.zoneId()) { + default R query(TemporalQuery query) { + if (query == TemporalQuery.zone() || query == TemporalQuery.zoneId()) { return (R) getZone(); - } else if (query == Queries.offset()) { + } else if (query == TemporalQuery.offset()) { return (R) getOffset(); - } else if (query == Queries.localTime()) { + } else if (query == TemporalQuery.localTime()) { return (R) toLocalTime(); - } else if (query == Queries.chronology()) { + } else if (query == TemporalQuery.chronology()) { return (R) toLocalDate().getChronology(); - } else if (query == Queries.precision()) { + } else if (query == TemporalQuery.precision()) { return (R) NANOS; } // inline TemporalAccessor.super.query(query) as an optimization @@ -404,6 +435,25 @@ public interface ChronoZonedDateTime> return query.queryFrom(this); } + /** + * Formats this date-time using the specified formatter. + *

    + * This date-time will be passed to the formatter to produce a string. + *

    + * The default implementation must behave as follows: + *

    +     *  return formatter.format(this);
    +     * 
    + * + * @param formatter the formatter to use, not null + * @return the formatted date-time string, not null + * @throws DateTimeException if an error occurs during printing + */ + default String format(DateTimeFormatter formatter) { + Objects.requireNonNull(formatter, "formatter"); + return formatter.format(this); + } + //----------------------------------------------------------------------- /** * Converts this date-time to an {@code Instant}. @@ -415,7 +465,7 @@ public interface ChronoZonedDateTime> * * @return an {@code Instant} representing the same instant, not null */ - public default Instant toInstant() { + default Instant toInstant() { return Instant.ofEpochSecond(toEpochSecond(), toLocalTime().getNano()); } @@ -430,7 +480,7 @@ public interface ChronoZonedDateTime> * * @return the number of seconds from the epoch of 1970-01-01T00:00:00Z */ - public default long toEpochSecond() { + default long toEpochSecond() { long epochDay = toLocalDate().toEpochDay(); long secs = epochDay * 86400 + toLocalTime().toSecondOfDay(); secs -= getOffset().getTotalSeconds(); @@ -454,7 +504,7 @@ public interface ChronoZonedDateTime> * @return the comparator value, negative if less, positive if greater */ @Override - public default int compareTo(ChronoZonedDateTime other) { + default int compareTo(ChronoZonedDateTime other) { int cmp = Long.compare(toEpochSecond(), other.toEpochSecond()); if (cmp == 0) { cmp = toLocalTime().getNano() - other.toLocalTime().getNano(); @@ -484,7 +534,7 @@ public interface ChronoZonedDateTime> * @param other the other date-time to compare to, not null * @return true if this point is before the specified date-time */ - public default boolean isBefore(ChronoZonedDateTime other) { + default boolean isBefore(ChronoZonedDateTime other) { long thisEpochSec = toEpochSecond(); long otherEpochSec = other.toEpochSecond(); return thisEpochSec < otherEpochSec || @@ -504,7 +554,7 @@ public interface ChronoZonedDateTime> * @param other the other date-time to compare to, not null * @return true if this is after the specified date-time */ - public default boolean isAfter(ChronoZonedDateTime other) { + default boolean isAfter(ChronoZonedDateTime other) { long thisEpochSec = toEpochSecond(); long otherEpochSec = other.toEpochSecond(); return thisEpochSec > otherEpochSec || @@ -524,7 +574,7 @@ public interface ChronoZonedDateTime> * @param other the other date-time to compare to, not null * @return true if the instant equals the instant of the specified date-time */ - public default boolean isEqual(ChronoZonedDateTime other) { + default boolean isEqual(ChronoZonedDateTime other) { return toEpochSecond() == other.toEpochSecond() && toLocalTime().getNano() == other.toLocalTime().getNano(); } @@ -555,28 +605,11 @@ public interface ChronoZonedDateTime> /** * Outputs this date-time as a {@code String}. *

    - * The output will include the full zoned date-time and the chronology ID. + * The output will include the full zoned date-time. * * @return a string representation of this date-time, not null */ @Override String toString(); - /** - * Outputs this date-time as a {@code String} using the formatter. - *

    - * The default implementation must behave as follows: - *

    -     *  return formatter.format(this);
    -     * 
    - * - * @param formatter the formatter to use, not null - * @return the formatted date-time string, not null - * @throws DateTimeException if an error occurs during printing - */ - public default String toString(DateTimeFormatter formatter) { - Objects.requireNonNull(formatter, "formatter"); - return formatter.format(this); - } - } diff --git a/jdk/src/share/classes/java/time/chrono/ChronoZonedDateTimeImpl.java b/jdk/src/share/classes/java/time/chrono/ChronoZonedDateTimeImpl.java index 0edd114a51b..0061eebdffc 100644 --- a/jdk/src/share/classes/java/time/chrono/ChronoZonedDateTimeImpl.java +++ b/jdk/src/share/classes/java/time/chrono/ChronoZonedDateTimeImpl.java @@ -167,6 +167,7 @@ final class ChronoZonedDateTimeImpl> * @param zone the zone identifier, not null * @return the zoned date-time, not null */ + @SuppressWarnings("rawtypes") static ChronoZonedDateTimeImpl ofInstant(Chronology chrono, Instant instant, ZoneId zone) { ZoneRules rules = zone.getRules(); ZoneOffset offset = rules.getOffset(instant); diff --git a/jdk/src/share/classes/java/time/chrono/Chronology.java b/jdk/src/share/classes/java/time/chrono/Chronology.java index ed4aacd8f64..6c61c32e9c0 100644 --- a/jdk/src/share/classes/java/time/chrono/Chronology.java +++ b/jdk/src/share/classes/java/time/chrono/Chronology.java @@ -61,38 +61,57 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR; +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.DAY_OF_WEEK; +import static java.time.temporal.ChronoField.DAY_OF_YEAR; +import static java.time.temporal.ChronoField.EPOCH_DAY; +import static java.time.temporal.ChronoField.ERA; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; +import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.TemporalAdjuster.nextOrSame; + import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.io.InvalidObjectException; import java.io.ObjectStreamException; +import java.io.Serializable; import java.time.Clock; import java.time.DateTimeException; +import java.time.DayOfWeek; import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; import java.time.ZoneId; -import java.time.chrono.HijrahChronology; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.MinguoChronology; -import java.time.chrono.ThaiBuddhistChronology; import java.time.format.DateTimeFormatterBuilder; +import java.time.format.ResolverStyle; import java.time.format.TextStyle; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; +import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; +import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Objects; import java.util.ServiceLoader; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import sun.util.logging.PlatformLogger; + /** * A calendar system, used to organize and identify dates. *

    @@ -106,7 +125,7 @@ import java.util.concurrent.ConcurrentHashMap; * for use by any {@code Chronology} implementation: *

      *   LocalDate isoDate = ...
    - *   ChronoLocalDate<ThaiBuddhistChronology> thaiDate = ...
    + *   ThaiBuddhistDate thaiDate = ...
      *   int isoYear = isoDate.get(ChronoField.YEAR);
      *   int thaiYear = thaiDate.get(ChronoField.YEAR);
      * 
    @@ -154,8 +173,8 @@ import java.util.concurrent.ConcurrentHashMap; *

    * Each chronology must define a chronology ID that is unique within the system. * If the chronology represents a calendar system defined by the - * Unicode Locale Data Markup Language (LDML) specification then that - * calendar type should also be specified. + * CLDR specification then the calendar type is the concatenation of the + * CLDR type and, if applicable, the CLDR variant, * *

    Specification for implementors

    * This class must be implemented with care to ensure other classes operate correctly. @@ -166,6 +185,36 @@ import java.util.concurrent.ConcurrentHashMap; */ public abstract class Chronology implements Comparable { + /** + * ChronoLocalDate order constant. + */ + static final Comparator> DATE_ORDER = + (Comparator> & Serializable) (date1, date2) -> { + return Long.compare(date1.toEpochDay(), date2.toEpochDay()); + }; + /** + * ChronoLocalDateTime order constant. + */ + static final Comparator> DATE_TIME_ORDER = + (Comparator> & Serializable) (dateTime1, dateTime2) -> { + int cmp = Long.compare(dateTime1.toLocalDate().toEpochDay(), dateTime2.toLocalDate().toEpochDay()); + if (cmp == 0) { + cmp = Long.compare(dateTime1.toLocalTime().toNanoOfDay(), dateTime2.toLocalTime().toNanoOfDay()); + } + return cmp; + }; + /** + * ChronoZonedDateTime order constant. + */ + static final Comparator> INSTANT_ORDER = + (Comparator> & Serializable) (dateTime1, dateTime2) -> { + int cmp = Long.compare(dateTime1.toEpochSecond(), dateTime2.toEpochSecond()); + if (cmp == 0) { + cmp = Long.compare(dateTime1.toLocalTime().getNano(), dateTime2.toLocalTime().getNano()); + } + return cmp; + }; + /** * Map of available calendars by ID. */ @@ -175,20 +224,36 @@ public abstract class Chronology implements Comparable { */ private static final ConcurrentHashMap CHRONOS_BY_TYPE = new ConcurrentHashMap<>(); + /** + * Register a Chronology by its ID and type for lookup by {@link #of(java.lang.String)}. + * Chronologies must not be registered until they are completely constructed. + * Specifically, not in the constructor of Chronology. + * + * @param chrono the chronology to register; not null + * @return the already registered Chronology if any, may be null + */ + static Chronology registerChrono(Chronology chrono) { + return registerChrono(chrono, chrono.getId()); + } + /** * Register a Chronology by ID and type for lookup by {@link #of(java.lang.String)}. * Chronos must not be registered until they are completely constructed. * Specifically, not in the constructor of Chronology. + * * @param chrono the chronology to register; not null + * @param id the ID to register the chronology; not null + * @return the already registered Chronology if any, may be null */ - private static void registerChrono(Chronology chrono) { - Chronology prev = CHRONOS_BY_ID.putIfAbsent(chrono.getId(), chrono); + static Chronology registerChrono(Chronology chrono, String id) { + Chronology prev = CHRONOS_BY_ID.putIfAbsent(id, chrono); if (prev == null) { String type = chrono.getCalendarType(); if (type != null) { CHRONOS_BY_TYPE.putIfAbsent(type, chrono); } } + return prev; } /** @@ -209,18 +274,25 @@ public abstract class Chronology implements Comparable { private static boolean initCache() { if (CHRONOS_BY_ID.get("ISO") == null) { // Initialization is incomplete - @SuppressWarnings("rawtypes") - ServiceLoader loader = ServiceLoader.load(Chronology.class, null); - for (Chronology chrono : loader) { - registerChrono(chrono); - } - // Register these calendars; the ServiceLoader configuration is not used + // Register built-in Chronologies registerChrono(HijrahChronology.INSTANCE); registerChrono(JapaneseChronology.INSTANCE); registerChrono(MinguoChronology.INSTANCE); registerChrono(ThaiBuddhistChronology.INSTANCE); + // Register Chronologies from the ServiceLoader + @SuppressWarnings("rawtypes") + ServiceLoader loader = ServiceLoader.load(Chronology.class, null); + for (Chronology chrono : loader) { + String id = chrono.getId(); + if (id.equals("ISO") || registerChrono(chrono) != null) { + // Log the attempt to replace an existing Chronology + PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono"); + logger.warning("Ignoring duplicate Chronology, from ServiceLoader configuration " + id); + } + } + // finally, register IsoChronology to mark initialization is complete registerChrono(IsoChronology.INSTANCE); return true; @@ -236,7 +308,7 @@ public abstract class Chronology implements Comparable { * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code Chronology}. *

    - * The conversion will obtain the chronology using {@link Queries#chronology()}. + * The conversion will obtain the chronology using {@link TemporalQuery#chronology()}. * If the specified temporal object does not have a chronology, {@link IsoChronology} is returned. *

    * This method matches the signature of the functional interface {@link TemporalQuery} @@ -248,7 +320,7 @@ public abstract class Chronology implements Comparable { */ public static Chronology from(TemporalAccessor temporal) { Objects.requireNonNull(temporal, "temporal"); - Chronology obj = temporal.query(Queries.chronology()); + Chronology obj = temporal.query(TemporalQuery.chronology()); return (obj != null ? obj : IsoChronology.INSTANCE); } @@ -266,13 +338,16 @@ public abstract class Chronology implements Comparable { *

    * The {@code Locale} class also supports an extension mechanism that * can be used to identify a calendar system. The mechanism is a form - * of key-value pairs, where the calendar system has the key "ca". + * of key-value pairs, where the calendar system has the key "ca" + * and an optional variant key "cv". * For example, the locale "en-JP-u-ca-japanese" represents the English * language as used in Japan with the Japanese calendar system. *

    * This method finds the desired calendar system by in a manner equivalent * to passing "ca" to {@link Locale#getUnicodeLocaleType(String)}. * If the "ca" key is not present, then {@code IsoChronology} is returned. + * The variant, if present, is appended to the "ca" value separated by "-" + * and the concatenated value is used to find the calendar system by type. *

    * Note that the behavior of this method differs from the older * {@link java.util.Calendar#getInstance(Locale)} method. @@ -299,6 +374,10 @@ public abstract class Chronology implements Comparable { if (type == null || "iso".equals(type) || "iso8601".equals(type)) { return IsoChronology.INSTANCE; } + String variant = locale.getUnicodeLocaleType("cv"); + if (variant != null && !variant.isEmpty()) { + type = type + '-' + variant; + } // Not pre-defined; lookup by the type do { Chronology chrono = CHRONOS_BY_TYPE.get(type); @@ -307,6 +386,16 @@ public abstract class Chronology implements Comparable { } // If not found, do the initialization (once) and repeat the lookup } while (initCache()); + + // Look for a Chronology using ServiceLoader of the Thread's ContextClassLoader + // Application provided Chronologies must not be cached + @SuppressWarnings("rawtypes") + ServiceLoader loader = ServiceLoader.load(Chronology.class); + for (Chronology chrono : loader) { + if (type.equals(chrono.getCalendarType())) { + return chrono; + } + } throw new DateTimeException("Unknown calendar system: " + type); } @@ -317,7 +406,8 @@ public abstract class Chronology implements Comparable { *

    * This returns a chronology based on either the ID or the type. * The {@link #getId() chronology ID} uniquely identifies the chronology. - * The {@link #getCalendarType() calendar system type} is defined by the LDML specification. + * The {@link #getCalendarType() calendar system type} is defined by the + * CLDR specification. *

    * The chronology may be a system chronology or a chronology * provided by the application via ServiceLoader configuration. @@ -379,7 +469,7 @@ public abstract class Chronology implements Comparable { */ public static Set getAvailableChronologies() { initCache(); // force initialization - HashSet chronos = new HashSet(CHRONOS_BY_ID.values()); + HashSet chronos = new HashSet<>(CHRONOS_BY_ID.values()); /// Add in Chronologies from the ServiceLoader configuration @SuppressWarnings("rawtypes") @@ -406,9 +496,9 @@ public abstract class Chronology implements Comparable { * @throws ClassCastException if the date-time cannot be cast to ChronoLocalDate * or the chronology is not equal this Chronology */ - ChronoLocalDate ensureChronoLocalDate(Temporal temporal) { + ChronoLocalDate ensureChronoLocalDate(Temporal temporal) { @SuppressWarnings("unchecked") - ChronoLocalDate other = (ChronoLocalDate) temporal; + ChronoLocalDate other = (ChronoLocalDate) temporal; if (this.equals(other.getChronology()) == false) { throw new ClassCastException("Chronology mismatch, expected: " + getId() + ", actual: " + other.getChronology().getId()); } @@ -464,15 +554,16 @@ public abstract class Chronology implements Comparable { public abstract String getId(); /** - * Gets the calendar type of the underlying calendar system. + * Gets the calendar type of the calendar system. *

    - * The calendar type is an identifier defined by the - * Unicode Locale Data Markup Language (LDML) specification. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. - * It can also be used as part of a locale, accessible via - * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. + * The calendar type is an identifier defined by the CLDR and + * Unicode Locale Data Markup Language (LDML) specifications + * to uniquely identification a calendar. + * The {@code getCalendarType} is the concatenation of the CLDR calendar type + * and the variant, if applicable, is appended separated by "-". + * The calendar type is used to lookup the {@code Chronology} using {@link #of(String)}. * - * @return the calendar system type, null if the calendar is not defined by LDML + * @return the calendar system type, null if the calendar is not defined * @see #getId() */ public abstract String getCalendarType(); @@ -488,8 +579,9 @@ public abstract class Chronology implements Comparable { * @param dayOfMonth the chronology day-of-month * @return the local date in this chronology, not null * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not of the correct type for the chronology */ - public ChronoLocalDate date(Era era, int yearOfEra, int month, int dayOfMonth) { + public ChronoLocalDate date(Era era, int yearOfEra, int month, int dayOfMonth) { return date(prolepticYear(era, yearOfEra), month, dayOfMonth); } @@ -503,7 +595,7 @@ public abstract class Chronology implements Comparable { * @return the local date in this chronology, not null * @throws DateTimeException if unable to create the date */ - public abstract ChronoLocalDate date(int prolepticYear, int month, int dayOfMonth); + public abstract ChronoLocalDate date(int prolepticYear, int month, int dayOfMonth); /** * Obtains a local date in this chronology from the era, year-of-era and @@ -514,8 +606,9 @@ public abstract class Chronology implements Comparable { * @param dayOfYear the chronology day-of-year * @return the local date in this chronology, not null * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not of the correct type for the chronology */ - public ChronoLocalDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { + public ChronoLocalDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); } @@ -528,7 +621,19 @@ public abstract class Chronology implements Comparable { * @return the local date in this chronology, not null * @throws DateTimeException if unable to create the date */ - public abstract ChronoLocalDate dateYearDay(int prolepticYear, int dayOfYear); + public abstract ChronoLocalDate dateYearDay(int prolepticYear, int dayOfYear); + + /** + * Obtains a local date in this chronology from the epoch-day. + *

    + * The definition of {@link ChronoField#EPOCH_DAY EPOCH_DAY} is the same + * for all calendar systems, thus it can be used for conversion. + * + * @param epochDay the epoch day + * @return the local date in this chronology, not null + * @throws DateTimeException if unable to create the date + */ + public abstract ChronoLocalDate dateEpochDay(long epochDay); //----------------------------------------------------------------------- /** @@ -545,7 +650,7 @@ public abstract class Chronology implements Comparable { * @return the current local date using the system clock and default time-zone, not null * @throws DateTimeException if unable to create the date */ - public ChronoLocalDate dateNow() { + public ChronoLocalDate dateNow() { return dateNow(Clock.systemDefaultZone()); } @@ -562,7 +667,7 @@ public abstract class Chronology implements Comparable { * @return the current local date using the system clock, not null * @throws DateTimeException if unable to create the date */ - public ChronoLocalDate dateNow(ZoneId zone) { + public ChronoLocalDate dateNow(ZoneId zone) { return dateNow(Clock.system(zone)); } @@ -577,7 +682,7 @@ public abstract class Chronology implements Comparable { * @return the current local date, not null * @throws DateTimeException if unable to create the date */ - public ChronoLocalDate dateNow(Clock clock) { + public ChronoLocalDate dateNow(Clock clock) { Objects.requireNonNull(clock, "clock"); return date(LocalDate.now(clock)); } @@ -586,7 +691,7 @@ public abstract class Chronology implements Comparable { /** * Obtains a local date in this chronology from another temporal object. *

    - * This creates a date in this chronology based on the specified temporal. + * This obtains a date in this chronology based on the specified temporal. * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code ChronoLocalDate}. *

    @@ -599,13 +704,14 @@ public abstract class Chronology implements Comparable { * @param temporal the temporal object to convert, not null * @return the local date in this chronology, not null * @throws DateTimeException if unable to create the date + * @see ChronoLocalDate#from(TemporalAccessor) */ - public abstract ChronoLocalDate date(TemporalAccessor temporal); + public abstract ChronoLocalDate date(TemporalAccessor temporal); /** * Obtains a local date-time in this chronology from another temporal object. *

    - * This creates a date-time in this chronology based on the specified temporal. + * This obtains a date-time in this chronology based on the specified temporal. * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code ChronoLocalDateTime}. *

    @@ -621,6 +727,7 @@ public abstract class Chronology implements Comparable { * @param temporal the temporal object to convert, not null * @return the local date-time in this chronology, not null * @throws DateTimeException if unable to create the date-time + * @see ChronoLocalDateTime#from(TemporalAccessor) */ public ChronoLocalDateTime localDateTime(TemporalAccessor temporal) { try { @@ -633,7 +740,7 @@ public abstract class Chronology implements Comparable { /** * Obtains a {@code ChronoZonedDateTime} in this chronology from another temporal object. *

    - * This creates a zoned date-time in this chronology based on the specified temporal. + * This obtains a zoned date-time in this chronology based on the specified temporal. * A {@code TemporalAccessor} represents an arbitrary set of date and time information, * which this factory converts to an instance of {@code ChronoZonedDateTime}. *

    @@ -652,6 +759,7 @@ public abstract class Chronology implements Comparable { * @param temporal the temporal object to convert, not null * @return the zoned date-time in this chronology, not null * @throws DateTimeException if unable to create the date-time + * @see ChronoZonedDateTime#from(TemporalAccessor) */ public ChronoZonedDateTime zonedDateTime(TemporalAccessor temporal) { try { @@ -661,6 +769,7 @@ public abstract class Chronology implements Comparable { return zonedDateTime(instant, zone); } catch (DateTimeException ex1) { + @SuppressWarnings("rawtypes") ChronoLocalDateTimeImpl cldt = ensureChronoLocalDateTime(localDateTime(temporal)); return ChronoZonedDateTimeImpl.ofBest(cldt, zone, null); } @@ -672,7 +781,7 @@ public abstract class Chronology implements Comparable { /** * Obtains a {@code ChronoZonedDateTime} in this chronology from an {@code Instant}. *

    - * This creates a zoned date-time with the same instant as that specified. + * This obtains a zoned date-time with the same instant as that specified. * * @param instant the instant to create the date-time from, not null * @param zone the time-zone, not null @@ -703,11 +812,17 @@ public abstract class Chronology implements Comparable { * Calculates the proleptic-year given the era and year-of-era. *

    * This combines the era and year-of-era into the single proleptic-year field. + *

    + * If the chronology makes active use of eras, such as {@code JapaneseChronology} + * then the year-of-era will be validated against the era. + * For other chronologies, validation is optional. * * @param era the era of the correct type for the chronology, not null * @param yearOfEra the chronology year-of-era * @return the proleptic-year - * @throws DateTimeException if unable to convert + * @throws DateTimeException if unable to convert to a proleptic-year, + * such as if the year is invalid for the era + * @throws ClassCastException if the {@code era} is not of the correct type for the chronology */ public abstract int prolepticYear(Era era, int yearOfEra); @@ -775,24 +890,175 @@ public abstract class Chronology implements Comparable { * @return the text value of the chronology, not null */ public String getDisplayName(TextStyle style, Locale locale) { - return new DateTimeFormatterBuilder().appendChronologyText(style).toFormatter(locale).format(new TemporalAccessor() { + return new DateTimeFormatterBuilder().appendChronologyText(style).toFormatter(locale).format(toTemporal()); + } + + /** + * Converts this chronology to a {@code TemporalAccessor}. + *

    + * A {@code Chronology} can be fully represented as a {@code TemporalAccessor}. + * However, the interface is not implemented by this class as most of the + * methods on the interface have no meaning to {@code Chronology}. + *

    + * The returned temporal has no supported fields, with the query method + * supporting the return of the chronology using {@link TemporalQuery#chronology()}. + * + * @return a temporal equivalent to this chronology, not null + */ + private TemporalAccessor toTemporal() { + return new TemporalAccessor() { @Override public boolean isSupported(TemporalField field) { return false; } @Override public long getLong(TemporalField field) { - throw new DateTimeException("Unsupported field: " + field); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.chronology()) { + if (query == TemporalQuery.chronology()) { return (R) Chronology.this; } return TemporalAccessor.super.query(query); } - }); + }; + } + + //----------------------------------------------------------------------- + /** + * Resolves parsed {@code ChronoField} values into a date during parsing. + *

    + * Most {@code TemporalField} implementations are resolved using the + * resolve method on the field. By contrast, the {@code ChronoField} class + * defines fields that only have meaning relative to the chronology. + * As such, {@code ChronoField} date fields are resolved here in the + * context of a specific chronology. + *

    + * The default implementation is suitable for most calendar systems. + * If {@link ChronoField#YEAR_OF_ERA} is found without an {@link ChronoField#ERA} + * then the last era in {@link #eras()} is used. + * The implementation assumes a 7 day week, that the first day-of-month + * has the value 1, and that first day-of-year has the value 1. + * + * @param fieldValues the map of fields to values, which can be updated, not null + * @param resolverStyle the requested type of resolve, not null + * @return the resolved date, null if insufficient information to create a date + * @throws DateTimeException if the date cannot be resolved, typically + * because of a conflict in the input data + */ + public ChronoLocalDate resolveDate(Map fieldValues, ResolverStyle resolverStyle) { + // check epoch-day before inventing era + if (fieldValues.containsKey(EPOCH_DAY)) { + return dateEpochDay(fieldValues.remove(EPOCH_DAY)); + } + + // fix proleptic month before inventing era + Long pMonth = fieldValues.remove(PROLEPTIC_MONTH); + if (pMonth != null) { + // first day-of-month is likely to be safest for setting proleptic-month + // cannot add to year zero, as not all chronologies have a year zero + ChronoLocalDate chronoDate = dateNow() + .with(DAY_OF_MONTH, 1).with(PROLEPTIC_MONTH, pMonth); + addFieldValue(fieldValues, MONTH_OF_YEAR, chronoDate.get(MONTH_OF_YEAR)); + addFieldValue(fieldValues, YEAR, chronoDate.get(YEAR)); + } + + // invent era if necessary to resolve year-of-era + Long yoeLong = fieldValues.remove(YEAR_OF_ERA); + if (yoeLong != null) { + Long eraLong = fieldValues.remove(ERA); + int yoe = range(YEAR_OF_ERA).checkValidIntValue(yoeLong, YEAR_OF_ERA); + if (eraLong != null) { + Era eraObj = eraOf(Math.toIntExact(eraLong)); + addFieldValue(fieldValues, YEAR, prolepticYear(eraObj, yoe)); + } else if (fieldValues.containsKey(YEAR)) { + int year = range(YEAR).checkValidIntValue(fieldValues.get(YEAR), YEAR); + ChronoLocalDate chronoDate = dateYearDay(year, 1); + addFieldValue(fieldValues, YEAR, prolepticYear(chronoDate.getEra(), yoe)); + } else { + List eras = eras(); + if (eras.isEmpty()) { + addFieldValue(fieldValues, YEAR, yoe); + } else { + Era eraObj = eras.get(eras.size() - 1); + addFieldValue(fieldValues, YEAR, prolepticYear(eraObj, yoe)); + } + } + } + + // build date + if (fieldValues.containsKey(YEAR)) { + if (fieldValues.containsKey(MONTH_OF_YEAR)) { + if (fieldValues.containsKey(DAY_OF_MONTH)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int moy = range(MONTH_OF_YEAR).checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR), MONTH_OF_YEAR); + int dom = range(DAY_OF_MONTH).checkValidIntValue(fieldValues.remove(DAY_OF_MONTH), DAY_OF_MONTH); + return date(y, moy, dom); + } + if (fieldValues.containsKey(ALIGNED_WEEK_OF_MONTH)) { + if (fieldValues.containsKey(ALIGNED_DAY_OF_WEEK_IN_MONTH)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int moy = range(MONTH_OF_YEAR).checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR), MONTH_OF_YEAR); + int aw = range(ALIGNED_WEEK_OF_MONTH).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), ALIGNED_WEEK_OF_MONTH); + int ad = range(ALIGNED_DAY_OF_WEEK_IN_MONTH).checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH), ALIGNED_DAY_OF_WEEK_IN_MONTH); + ChronoLocalDate chronoDate = date(y, moy, 1); + return chronoDate.plus((aw - 1) * 7 + (ad - 1), ChronoUnit.DAYS); + } + if (fieldValues.containsKey(DAY_OF_WEEK)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int moy = range(MONTH_OF_YEAR).checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR), MONTH_OF_YEAR); + int aw = range(ALIGNED_WEEK_OF_MONTH).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), ALIGNED_WEEK_OF_MONTH); + int dow = range(DAY_OF_WEEK).checkValidIntValue(fieldValues.remove(DAY_OF_WEEK), DAY_OF_WEEK); + ChronoLocalDate chronoDate = date(y, moy, 1); + return chronoDate.plus((aw - 1) * 7, ChronoUnit.DAYS).with(nextOrSame(DayOfWeek.of(dow))); + } + } + } + if (fieldValues.containsKey(DAY_OF_YEAR)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int doy = range(DAY_OF_YEAR).checkValidIntValue(fieldValues.remove(DAY_OF_YEAR), DAY_OF_YEAR); + return dateYearDay(y, doy); + } + if (fieldValues.containsKey(ALIGNED_WEEK_OF_YEAR)) { + if (fieldValues.containsKey(ALIGNED_DAY_OF_WEEK_IN_YEAR)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int aw = range(ALIGNED_WEEK_OF_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), ALIGNED_WEEK_OF_YEAR); + int ad = range(ALIGNED_DAY_OF_WEEK_IN_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), ALIGNED_DAY_OF_WEEK_IN_YEAR); + ChronoLocalDate chronoDate = dateYearDay(y, 1); + return chronoDate.plus((aw - 1) * 7 + (ad - 1), ChronoUnit.DAYS); + } + if (fieldValues.containsKey(DAY_OF_WEEK)) { + int y = range(YEAR).checkValidIntValue(fieldValues.remove(YEAR), YEAR); + int aw = range(ALIGNED_WEEK_OF_YEAR).checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), ALIGNED_WEEK_OF_YEAR); + int dow = range(DAY_OF_WEEK).checkValidIntValue(fieldValues.remove(DAY_OF_WEEK), DAY_OF_WEEK); + ChronoLocalDate chronoDate = dateYearDay(y, 1); + return chronoDate.plus((aw - 1) * 7, ChronoUnit.DAYS).with(nextOrSame(DayOfWeek.of(dow))); + } + } + } + return null; + } + + /** + * Adds a field-value pair to the map, checking for conflicts. + *

    + * If the field is not already present, then the field-value pair is added to the map. + * If the field is already present and it has the same value as that specified, no action occurs. + * If the field is already present and it has a different value to that specified, then + * an exception is thrown. + * + * @param field the field to add, not null + * @param value the value to add, not null + * @throws DateTimeException if the field is already present with a different value + */ + void addFieldValue(Map fieldValues, ChronoField field, long value) { + Long old = fieldValues.get(field); // check first for better error message + if (old != null && old.longValue() != value) { + throw new DateTimeException("Conflict found: " + field + " " + old + " differs from " + field + " " + value); + } + fieldValues.put(field, value); } //----------------------------------------------------------------------- @@ -861,16 +1127,16 @@ public abstract class Chronology implements Comparable { //----------------------------------------------------------------------- /** - * Writes the object using a - * dedicated serialized form. + * Writes the Chronology using a + * dedicated serialized form. *

    -     *  out.writeByte(7);  // identifies this as a Chronology
    -     * out.writeUTF(chronoId);
    +     *  out.writeByte(1);  // identifies this as a Chronology
    +     *  out.writeUTF(getId());
          * 
    * * @return the instance of {@code Ser}, not null */ - private Object writeReplace() { + protected Object writeReplace() { return new Ser(Ser.CHRONO_TYPE, this); } diff --git a/jdk/src/share/classes/java/time/chrono/Era.java b/jdk/src/share/classes/java/time/chrono/Era.java index 95254c960c4..a26953ee11a 100644 --- a/jdk/src/share/classes/java/time/chrono/Era.java +++ b/jdk/src/share/classes/java/time/chrono/Era.java @@ -65,10 +65,10 @@ import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoUnit.ERAS; import java.time.DateTimeException; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -120,55 +120,6 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { */ int getValue(); - /** - * Gets the chronology of this era. - *

    - * The {@code Chronology} represents the calendar system in use. - * This always returns the standard form of the chronology. - * - * @return the chronology, not null - */ - Chronology getChronology(); - - //----------------------------------------------------------------------- - /** - * Obtains a date in this era given the year-of-era, month, and day. - *

    - * This era is combined with the given date fields to form a date. - * The year specified must be the year-of-era. - * Methods to create a date from the proleptic-year are on {@code Chronology}. - * This always uses the standard form of the chronology. - *

    - * This default implementation invokes the factory method on {@link Chronology}. - * - * @param yearOfEra the calendar system year-of-era - * @param month the calendar system month-of-year - * @param day the calendar system day-of-month - * @return a local date based on this era and the specified year-of-era, month and day - */ - public default ChronoLocalDate date(int yearOfEra, int month, int day) { - return getChronology().date(this, yearOfEra, month, day); - } - - - /** - * Obtains a date in this era given year-of-era and day-of-year fields. - *

    - * This era is combined with the given date fields to form a date. - * The year specified must be the year-of-era. - * Methods to create a date from the proleptic-year are on {@code Chronology}. - * This always uses the standard form of the chronology. - *

    - * This default implementation invokes the factory method on {@link Chronology}. - * - * @param yearOfEra the calendar system year-of-era - * @param dayOfYear the calendar system day-of-year - * @return a local date based on this era and the specified year-of-era and day-of-year - */ - public default ChronoLocalDate dateYearDay(int yearOfEra, int dayOfYear) { - return getChronology().dateYearDay(this, yearOfEra, dayOfYear); - } - //----------------------------------------------------------------------- /** * Checks if the specified field is supported. @@ -190,7 +141,7 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { * @return true if the field is supported on this era, false if not */ @Override - public default boolean isSupported(TemporalField field) { + default boolean isSupported(TemporalField field) { if (field instanceof ChronoField) { return field == ERA; } @@ -207,19 +158,23 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@code ERA} field returns the range. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} * passing {@code this} as the argument. * Whether the range can be obtained is determined by the field. + *

    + * The default implementation must return a range for {@code ERA} from + * zero to one, suitable for two era calendar systems such as ISO. * * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the unit is not supported */ @Override // override for Javadoc - public default ValueRange range(TemporalField field) { + default ValueRange range(TemporalField field) { return TemporalAccessor.super.range(field); } @@ -233,7 +188,7 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@code ERA} field returns the value of the era. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -242,15 +197,18 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { * * @param field the field to get, not null * @return the value for the field - * @throws DateTimeException if a value for the field cannot be obtained + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ @Override // override for Javadoc and performance - public default int get(TemporalField field) { + default int get(TemporalField field) { if (field == ERA) { return getValue(); } - return range(field).checkValidIntValue(getLong(field), field); + return TemporalAccessor.super.get(field); } /** @@ -262,7 +220,7 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { *

    * If the field is a {@link ChronoField} then the query is implemented here. * The {@code ERA} field returns the value of the era. - * All other {@code ChronoField} instances will throw a {@code DateTimeException}. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -272,14 +230,15 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ @Override - public default long getLong(TemporalField field) { + default long getLong(TemporalField field) { if (field == ERA) { return getValue(); } else if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -305,10 +264,8 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { */ @SuppressWarnings("unchecked") @Override - public default R query(TemporalQuery query) { - if (query == Queries.chronology()) { - return (R) getChronology(); - } else if (query == Queries.precision()) { + default R query(TemporalQuery query) { + if (query == TemporalQuery.precision()) { return (R) ERAS; } return TemporalAccessor.super.query(query); @@ -339,7 +296,7 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { * @throws ArithmeticException if numeric overflow occurs */ @Override - public default Temporal adjustInto(Temporal temporal) { + default Temporal adjustInto(Temporal temporal) { return temporal.with(ERA, getValue()); } @@ -359,7 +316,7 @@ public interface Era extends TemporalAccessor, TemporalAdjuster { * @param locale the locale to use, not null * @return the text value of the era, not null */ - public default String getDisplayName(TextStyle style, Locale locale) { + default String getDisplayName(TextStyle style, Locale locale) { return new DateTimeFormatterBuilder().appendText(ERA, style).toFormatter(locale).format(this); } diff --git a/jdk/src/share/classes/java/time/chrono/HijrahChronology.java b/jdk/src/share/classes/java/time/chrono/HijrahChronology.java index 0cd16cf47c2..5d53855d723 100644 --- a/jdk/src/share/classes/java/time/chrono/HijrahChronology.java +++ b/jdk/src/share/classes/java/time/chrono/HijrahChronology.java @@ -59,9 +59,13 @@ package java.time.chrono; import static java.time.temporal.ChronoField.EPOCH_DAY; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.io.Serializable; -import java.text.ParseException; +import java.security.AccessController; +import java.security.PrivilegedActionException; import java.time.Clock; import java.time.DateTimeException; import java.time.Instant; @@ -73,106 +77,135 @@ import java.time.temporal.ValueRange; import java.util.Arrays; import java.util.HashMap; import java.util.List; -import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; + +import sun.util.logging.PlatformLogger; /** - * The Hijrah calendar system. + * The Hijrah calendar is a lunar calendar supporting Islamic calendars. *

    - * This chronology defines the rules of the Hijrah calendar system. + * The HijrahChronology follows the rules of the Hijrah calendar system. The Hijrah + * calendar has several variants based on differences in when the new moon is + * determined to have occurred and where the observation is made. + * In some variants the length of each month is + * computed algorithmically from the astronomical data for the moon and earth and + * in others the length of the month is determined by an authorized sighting + * of the new moon. For the algorithmically based calendars the calendar + * can project into the future. + * For sighting based calendars only historical data from past + * sightings is available. *

    - * The implementation follows the Freeman-Grenville algorithm (*1) and has following features. - *

      - *
    • A year has 12 months.
    • - *
    • Over a cycle of 30 years there are 11 leap years.
    • - *
    • There are 30 days in month number 1, 3, 5, 7, 9, and 11, - * and 29 days in month number 2, 4, 6, 8, 10, and 12.
    • - *
    • In a leap year month 12 has 30 days.
    • - *
    • In a 30 year cycle, year 2, 5, 7, 10, 13, 16, 18, 21, 24, - * 26, and 29 are leap years.
    • - *
    • Total of 10631 days in a 30 years cycle.
    • - *

    - *

    - * The table shows the features described above. - *

    - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * The length of each month is 29 or 30 days. + * Ordinary years have 354 days; leap years have 355 days. + * + *

    + * CLDR and LDML identify variants: + *

    Hijrah Calendar Months
    # of monthName of monthNumber of days
    1Muharram30
    2Safar29
    3Rabi'al-Awwal30
    4Rabi'ath-Thani29
    5Jumada l-Ula30
    6Jumada t-Tania29
    7Rajab30
    8Sha`ban29
    9Ramadan30
    10Shawwal29
    11Dhu 'l-Qa`da30
    12Dhu 'l-Hijja29, but 30 days in years 2, 5, 7, 10,
    - * 13, 16, 18, 21, 24, 26, and 29
    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * *
    Chronology IDCalendar TypeLocale extension, see {@link java.util.Locale}Description
    Hijrah-umalquraislamic-umalquraca-islamic-cv-umalquraIslamic - Umm Al-Qura calendar of Saudi Arabia
    - *
    - *

    - * (*1) The algorithm is taken from the book, - * The Muslim and Christian Calendars by G.S.P. Freeman-Grenville. + *

    Additional variants may be available through {@link Chronology#getAvailableChronologies()}. + * + *

    Example

    *

    + * Selecting the chronology from the locale uses {@link Chronology#ofLocale} + * to find the Chronology based on Locale supported BCP 47 extension mechanism + * to request a specific calendar ("ca") and variant ("cv"). For example, + *

    + *
    + *      Locale locale = Locale.forLanguageTag("en-US-u-ca-islamic-cv-umalqura");
    + *      Chronology chrono = Chronology.ofLocale(locale);
    + * 
    * *

    Specification for implementors

    * This class is immutable and thread-safe. + *

    Implementation Note for Hijrah Calendar Variant Configuration

    + * Each Hijrah variant is configured individually. Each variant is defined by a + * property resource that defines the {@code ID}, the {@code calendar type}, + * the start of the calendar, the alignment with the + * ISO calendar, and the length of each month for a range of years. + * The variants are identified in the {@code calendars.properties} file. + * The new properties are prefixed with {@code "calendars.hijrah."}: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Property NameProperty valueDescription
    calendars.hijrah.{ID}The property resource defining the {@code {ID}} variantThe property resource is located with the {@code calendars.properties} file
    calendars.hijrah.{ID}.typeThe calendar typeLDML defines the calendar type names
    + *

    + * The Hijrah property resource is a set of properties that describe the calendar. + * The syntax is defined by {@code java.util.Properties#load(Reader)}. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Property Name Property value Description
    idChronology Id, for example, "Hijrah-umalqura"The Id of the calendar in common usage
    typeCalendar type, for example, "islamic-umalqura"LDML defines the calendar types
    versionVersion, for example: "1.8.0_1"The version of the Hijrah variant data
    iso-startISO start date, formatted as {@code yyyy-MM-dd}, for example: "1900-04-30"The ISO date of the first day of the minimum Hijrah year.
    yyyy - a numeric 4 digit year, for example "1434"The value is a sequence of 12 month lengths, + * for example: "29 30 29 30 29 30 30 30 29 30 29 29"The lengths of the 12 months of the year separated by whitespace. + * A numeric year property must be present for every year without any gaps. + * The month lengths must be between 29-32 inclusive. + *
    * * @since 1.8 */ @@ -182,336 +215,161 @@ public final class HijrahChronology extends Chronology implements Serializable { * The Hijrah Calendar id. */ private final String typeId; - /** * The Hijrah calendarType. */ - private final String calendarType; - - /** - * The singleton instance for the era before the current one - Before Hijrah - - * which has the value 0. - */ - public static final Era ERA_BEFORE_AH = HijrahEra.BEFORE_AH; - /** - * The singleton instance for the current era - Hijrah - which has the value 1. - */ - public static final Era ERA_AH = HijrahEra.AH; + private transient final String calendarType; /** * Serialization version. */ private static final long serialVersionUID = 3127340209035924785L; /** - * The minimum valid year-of-era. - */ - public static final int MIN_YEAR_OF_ERA = 1; - /** - * The maximum valid year-of-era. - * This is currently set to 9999 but may be changed to increase the valid range - * in a future version of the specification. - */ - public static final int MAX_YEAR_OF_ERA = 9999; - - /** - * Number of Gregorian day of July 19, year 622 (Gregorian), which is epoch day - * of Hijrah calendar. - */ - private static final int HIJRAH_JAN_1_1_GREGORIAN_DAY = -492148; - /** - * 0-based, for number of day-of-year in the beginning of month in normal - * year. - */ - private static final int NUM_DAYS[] = - {0, 30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325}; - /** - * 0-based, for number of day-of-year in the beginning of month in leap year. - */ - private static final int LEAP_NUM_DAYS[] = - {0, 30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325}; - /** - * 0-based, for day-of-month in normal year. - */ - private static final int MONTH_LENGTH[] = - {30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29}; - /** - * 0-based, for day-of-month in leap year. - */ - private static final int LEAP_MONTH_LENGTH[] = - {30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 30}; - - /** - *

    -     *                            Greatest       Least
    -     * Field name        Minimum   Minimum     Maximum     Maximum
    -     * ----------        -------   -------     -------     -------
    -     * ERA                     0         0           1           1
    -     * YEAR_OF_ERA             1         1        9999        9999
    -     * MONTH_OF_YEAR           1         1          12          12
    -     * DAY_OF_MONTH            1         1          29          30
    -     * DAY_OF_YEAR             1         1         354         355
    -     * 
    - * - * Minimum values. - */ - private static final int MIN_VALUES[] = - { - 0, - MIN_YEAR_OF_ERA, - 0, - 1, - 0, - 1, - 1 - }; - - /** - * Least maximum values. - */ - private static final int LEAST_MAX_VALUES[] = - { - 1, - MAX_YEAR_OF_ERA, - 11, - 51, - 5, - 29, - 354 - }; - - /** - * Maximum values. - */ - private static final int MAX_VALUES[] = - { - 1, - MAX_YEAR_OF_ERA, - 11, - 52, - 6, - 30, - 355 - }; - - /** - * Position of day-of-month. This value is used to get the min/max value - * from an array. - */ - private static final int POSITION_DAY_OF_MONTH = 5; - /** - * Position of day-of-year. This value is used to get the min/max value from - * an array. - */ - private static final int POSITION_DAY_OF_YEAR = 6; - /** - * Zero-based start date of cycle year. - */ - private static final int CYCLEYEAR_START_DATE[] = - { - 0, - 354, - 709, - 1063, - 1417, - 1772, - 2126, - 2481, - 2835, - 3189, - 3544, - 3898, - 4252, - 4607, - 4961, - 5315, - 5670, - 6024, - 6379, - 6733, - 7087, - 7442, - 7796, - 8150, - 8505, - 8859, - 9214, - 9568, - 9922, - 10277 - }; - - /** - * Holding the adjusted month days in year. The key is a year (Integer) and - * the value is the all the month days in year (int[]). - */ - private final HashMap ADJUSTED_MONTH_DAYS = new HashMap<>(); - /** - * Holding the adjusted month length in year. The key is a year (Integer) - * and the value is the all the month length in year (int[]). - */ - private final HashMap ADJUSTED_MONTH_LENGTHS = new HashMap<>(); - /** - * Holding the adjusted days in the 30 year cycle. The key is a cycle number - * (Integer) and the value is the all the starting days of the year in the - * cycle (int[]). - */ - private final HashMap ADJUSTED_CYCLE_YEARS = new HashMap<>(); - /** - * Holding the adjusted cycle in the 1 - 30000 year. The key is the cycle - * number (Integer) and the value is the starting days in the cycle in the - * term. - */ - private final long[] ADJUSTED_CYCLES; - /** - * Holding the adjusted min values. - */ - private final int[] ADJUSTED_MIN_VALUES; - /** - * Holding the adjusted max least max values. - */ - private final int[] ADJUSTED_LEAST_MAX_VALUES; - /** - * Holding adjusted max values. - */ - private final int[] ADJUSTED_MAX_VALUES; - /** - * Holding the non-adjusted month days in year for non leap year. - */ - private static final int[] DEFAULT_MONTH_DAYS; - /** - * Holding the non-adjusted month days in year for leap year. - */ - private static final int[] DEFAULT_LEAP_MONTH_DAYS; - /** - * Holding the non-adjusted month length for non leap year. - */ - private static final int[] DEFAULT_MONTH_LENGTHS; - /** - * Holding the non-adjusted month length for leap year. - */ - private static final int[] DEFAULT_LEAP_MONTH_LENGTHS; - /** - * Holding the non-adjusted 30 year cycle starting day. - */ - private static final int[] DEFAULT_CYCLE_YEARS; - /** - * number of 30-year cycles to hold the deviation data. - */ - private static final int MAX_ADJUSTED_CYCLE = 334; // to support year 9999 - - - /** - * Narrow names for eras. - */ - private static final HashMap ERA_NARROW_NAMES = new HashMap<>(); - /** - * Short names for eras. - */ - private static final HashMap ERA_SHORT_NAMES = new HashMap<>(); - /** - * Full names for eras. - */ - private static final HashMap ERA_FULL_NAMES = new HashMap<>(); - /** - * Fallback language for the era names. - */ - private static final String FALLBACK_LANGUAGE = "en"; - - /** - * Singleton instance of the Hijrah chronology. - * Must be initialized after the rest of the static initialization. + * Singleton instance of the Islamic Umm Al-Qura calendar of Saudi Arabia. + * Other Hijrah chronology variants may be available from + * {@link Chronology#getAvailableChronologies}. */ public static final HijrahChronology INSTANCE; + /** + * Array of epoch days indexed by Hijrah Epoch month. + * Computed by {@link #loadCalendarData}. + */ + private transient int[] hijrahEpochMonthStartDays; + /** + * The minimum epoch day of this Hijrah calendar. + * Computed by {@link #loadCalendarData}. + */ + private transient int minEpochDay; + /** + * The maximum epoch day for which calendar data is available. + * Computed by {@link #loadCalendarData}. + */ + private transient int maxEpochDay; + /** + * The minimum epoch month. + * Computed by {@link #loadCalendarData}. + */ + private transient int hijrahStartEpochMonth; + /** + * The minimum length of a month. + * Computed by {@link #createEpochMonths}. + */ + private transient int minMonthLength; + /** + * The maximum length of a month. + * Computed by {@link #createEpochMonths}. + */ + private transient int maxMonthLength; + /** + * The minimum length of a year in days. + * Computed by {@link #createEpochMonths}. + */ + private transient int minYearLength; + /** + * The maximum length of a year in days. + * Computed by {@link #createEpochMonths}. + */ + private transient int maxYearLength; + /** + * A reference to the properties stored in + * ${java.home}/lib/calendars.properties + */ + private transient final static Properties calendarProperties; + + /** + * Prefix of property names for Hijrah calendar variants. + */ + private static final String PROP_PREFIX = "calendar.hijrah."; + /** + * Suffix of property names containing the calendar type of a variant. + */ + private static final String PROP_TYPE_SUFFIX = ".type"; /** * Name data. */ static { - ERA_NARROW_NAMES.put(FALLBACK_LANGUAGE, new String[]{"BH", "HE"}); - ERA_SHORT_NAMES.put(FALLBACK_LANGUAGE, new String[]{"B.H.", "H.E."}); - ERA_FULL_NAMES.put(FALLBACK_LANGUAGE, new String[]{"Before Hijrah", "Hijrah Era"}); + try { + calendarProperties = sun.util.calendar.BaseCalendar.getCalendarProperties(); + } catch (IOException ioe) { + throw new InternalError("Can't initialize lib/calendars.properties", ioe); + } - DEFAULT_MONTH_DAYS = Arrays.copyOf(NUM_DAYS, NUM_DAYS.length); + try { + INSTANCE = new HijrahChronology("Hijrah-umalqura"); + // Register it by its aliases + Chronology.registerChrono(INSTANCE, "Hijrah"); + Chronology.registerChrono(INSTANCE, "islamic"); - DEFAULT_LEAP_MONTH_DAYS = Arrays.copyOf(LEAP_NUM_DAYS, LEAP_NUM_DAYS.length); + } catch (Exception ex) { + // Absence of Hijrah calendar is fatal to initializing this class. + PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono"); + logger.severe("Unable to initialize Hijrah calendar: Hijrah-umalqura", ex); + throw new RuntimeException("Unable to initialize Hijrah-umalqura calendar", ex.getCause()); + } + registerVariants(); + } - DEFAULT_MONTH_LENGTHS = Arrays.copyOf(MONTH_LENGTH, MONTH_LENGTH.length); - - DEFAULT_LEAP_MONTH_LENGTHS = Arrays.copyOf(LEAP_MONTH_LENGTH, LEAP_MONTH_LENGTH.length); - - DEFAULT_CYCLE_YEARS = Arrays.copyOf(CYCLEYEAR_START_DATE, CYCLEYEAR_START_DATE.length); - - INSTANCE = new HijrahChronology(); - - String extraCalendars = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("java.time.chrono.HijrahCalendars")); - if (extraCalendars != null) { - try { - // Split on whitespace - String[] splits = extraCalendars.split("\\s"); - for (String cal : splits) { - if (!cal.isEmpty()) { - // Split on the delimiter between typeId "-" calendarType - String[] type = cal.split("-"); - Chronology cal2 = new HijrahChronology(type[0], type.length > 1 ? type[1] : type[0]); - } + /** + * For each Hijrah variant listed, create the HijrahChronology and register it. + * Exceptions during initialization are logged but otherwise ignored. + */ + private static void registerVariants() { + for (String name : calendarProperties.stringPropertyNames()) { + if (name.startsWith(PROP_PREFIX)) { + String id = name.substring(PROP_PREFIX.length()); + if (id.indexOf('.') >= 0) { + continue; // no name or not a simple name of a calendar + } + if (id.equals(INSTANCE.getId())) { + continue; // do not duplicate the default + } + try { + // Create and register the variant + HijrahChronology chrono = new HijrahChronology(id); + Chronology.registerChrono(chrono); + } catch (Exception ex) { + // Log error and continue + PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono"); + logger.severe("Unable to initialize Hijrah calendar: " + id, ex); } - } catch (Exception ex) { - // Log the error - // ex.printStackTrace(); } } } /** - * Restricted constructor. - */ - private HijrahChronology() { - this("Hijrah", "islamicc"); - } - /** - * Constructor for name and type HijrahChronology. + * Create a HijrahChronology for the named variant. + * The resource and calendar type are retrieved from properties + * in the {@code calendars.properties}. + * The property names are {@code "calendar.hijrah." + id} + * and {@code "calendar.hijrah." + id + ".type"} * @param id the id of the calendar - * @param calendarType the calendar type + * @throws Exception if the resource can not be accessed or + * the format is invalid */ - private HijrahChronology(String id, String calendarType) { - this.typeId = id; - this.calendarType = calendarType; - - ADJUSTED_CYCLES = new long[MAX_ADJUSTED_CYCLE]; - for (int i = 0; i < ADJUSTED_CYCLES.length; i++) { - ADJUSTED_CYCLES[i] = (10631L * i); + private HijrahChronology(String id) throws Exception { + if (id.isEmpty()) { + throw new IllegalArgumentException("calendar id is empty"); } - // Initialize min values, least max values and max values. - ADJUSTED_MIN_VALUES = Arrays.copyOf(MIN_VALUES, MIN_VALUES.length); - ADJUSTED_LEAST_MAX_VALUES = Arrays.copyOf(LEAST_MAX_VALUES, LEAST_MAX_VALUES.length); - ADJUSTED_MAX_VALUES = Arrays.copyOf(MAX_VALUES,MAX_VALUES.length); + this.typeId = id; + this.calendarType = calendarProperties.getProperty(PROP_PREFIX + id + PROP_TYPE_SUFFIX); try { - // Implicitly reads deviation data for this HijrahChronology. - boolean any = HijrahDeviationReader.readDeviation(typeId, calendarType, this::addDeviationAsHijrah); - } catch (IOException | ParseException e) { - // do nothing. Log deviation config errors. - //e.printStackTrace(); + String resource = calendarProperties.getProperty(PROP_PREFIX + id); + Objects.requireNonNull(resource, "Resource missing for calendar"); + loadCalendarData(resource); + } catch (Exception ex) { + throw new Exception("Unable to initialize HijrahCalendar: " + id, ex); } } - /** - * Resolve singleton. - * - * @return the singleton instance, not null - */ - private Object readResolve() { - return INSTANCE; - } - //----------------------------------------------------------------------- /** - * Gets the ID of the chronology - 'Hijrah'. + * Gets the ID of the chronology. *

    - * The ID uniquely identifies the {@code Chronology}. - * It can be used to lookup the {@code Chronology} using {@link #of(String)}. + * The ID uniquely identifies the {@code Chronology}. It can be used to + * lookup the {@code Chronology} using {@link #of(String)}. * - * @return the chronology ID - 'Hijrah' + * @return the chronology ID, non-null * @see #getCalendarType() */ @Override @@ -520,15 +378,14 @@ public final class HijrahChronology extends Chronology implements Serializable { } /** - * Gets the calendar type of the underlying calendar system - 'islamicc'. + * Gets the calendar type of the Islamic calendar. *

    * The calendar type is an identifier defined by the * Unicode Locale Data Markup Language (LDML) specification. * It can be used to lookup the {@code Chronology} using {@link #of(String)}. - * It can also be used as part of a locale, accessible via - * {@link Locale#getUnicodeLocaleType(String)} with the key 'ca'. * - * @return the calendar system type - 'islamicc' + * @return the calendar system type; non-null if the calendar has + * a standard type, otherwise null * @see #getId() */ @Override @@ -537,33 +394,78 @@ public final class HijrahChronology extends Chronology implements Serializable { } //----------------------------------------------------------------------- + /** + * Obtains a local date in Hijrah calendar system from the + * era, year-of-era, month-of-year and day-of-month fields. + * + * @param era the Hijrah era, not null + * @param yearOfEra the year-of-era + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Hijrah local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code HijrahEra} + */ + @Override + public HijrahDate date(Era era, int yearOfEra, int month, int dayOfMonth) { + return date(prolepticYear(era, yearOfEra), month, dayOfMonth); + } + + /** + * Obtains a local date in Hijrah calendar system from the + * proleptic-year, month-of-year and day-of-month fields. + * + * @param prolepticYear the proleptic-year + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Hijrah local date, not null + * @throws DateTimeException if unable to create the date + */ @Override public HijrahDate date(int prolepticYear, int month, int dayOfMonth) { return HijrahDate.of(this, prolepticYear, month, dayOfMonth); } + /** + * Obtains a local date in Hijrah calendar system from the + * era, year-of-era and day-of-year fields. + * + * @param era the Hijrah era, not null + * @param yearOfEra the year-of-era + * @param dayOfYear the day-of-year + * @return the Hijrah local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code HijrahEra} + */ + @Override + public HijrahDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { + return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + } + + /** + * Obtains a local date in Hijrah calendar system from the + * proleptic-year and day-of-year fields. + * + * @param prolepticYear the proleptic-year + * @param dayOfYear the day-of-year + * @return the Hijrah local date, not null + * @throws DateTimeException if unable to create the date + */ @Override public HijrahDate dateYearDay(int prolepticYear, int dayOfYear) { return HijrahDate.of(this, prolepticYear, 1, 1).plusDays(dayOfYear - 1); // TODO better } - @Override - public HijrahDate date(TemporalAccessor temporal) { - if (temporal instanceof HijrahDate) { - return (HijrahDate) temporal; - } - return HijrahDate.ofEpochDay(this, temporal.getLong(EPOCH_DAY)); - } - - @Override - public HijrahDate date(Era era, int yearOfEra, int month, int dayOfMonth) { - return date(prolepticYear(era, yearOfEra), month, dayOfMonth); - - } - - @Override - public HijrahDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { - return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + /** + * Obtains a local date in the Hijrah calendar system from the epoch-day. + * + * @param epochDay the epoch day + * @return the Hijrah local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override // override with covariant return type + public HijrahDate dateEpochDay(long epochDay) { + return HijrahDate.ofEpochDay(this, epochDay); } @Override @@ -581,48 +483,51 @@ public final class HijrahChronology extends Chronology implements Serializable { return date(LocalDate.now(clock)); } + @Override + public HijrahDate date(TemporalAccessor temporal) { + if (temporal instanceof HijrahDate) { + return (HijrahDate) temporal; + } + return HijrahDate.ofEpochDay(this, temporal.getLong(EPOCH_DAY)); + } + @Override public ChronoLocalDateTime localDateTime(TemporalAccessor temporal) { - return (ChronoLocalDateTime)super.localDateTime(temporal); + return (ChronoLocalDateTime) super.localDateTime(temporal); } @Override public ChronoZonedDateTime zonedDateTime(TemporalAccessor temporal) { - return (ChronoZonedDateTime)super.zonedDateTime(temporal); + return (ChronoZonedDateTime) super.zonedDateTime(temporal); } @Override public ChronoZonedDateTime zonedDateTime(Instant instant, ZoneId zone) { - return (ChronoZonedDateTime)super.zonedDateTime(instant, zone); + return (ChronoZonedDateTime) super.zonedDateTime(instant, zone); } //----------------------------------------------------------------------- @Override public boolean isLeapYear(long prolepticYear) { - return isLeapYear0(prolepticYear); - } - /** - * Returns if the year is a leap year. - * @param prolepticYear he year to compute from - * @return {@code true} if the year is a leap year, otherwise {@code false} - */ - private static boolean isLeapYear0(long prolepticYear) { - return (14 + 11 * (prolepticYear > 0 ? prolepticYear : -prolepticYear)) % 30 < 11; + int epochMonth = yearToEpochMonth((int) prolepticYear); + if (epochMonth < 0 || epochMonth > maxEpochDay) { + throw new DateTimeException("Hijrah date out of range"); + } + int len = getYearLength((int) prolepticYear); + return (len > 354); } @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof HijrahEra == false) { - throw new DateTimeException("Era must be HijrahEra"); + throw new ClassCastException("Era must be HijrahEra"); } - return (era == HijrahEra.AH ? yearOfEra : 1 - yearOfEra); + return yearOfEra; } @Override public Era eraOf(int eraValue) { switch (eraValue) { - case 0: - return HijrahEra.BEFORE_AH; case 1: return HijrahEra.AH; default: @@ -638,430 +543,159 @@ public final class HijrahChronology extends Chronology implements Serializable { //----------------------------------------------------------------------- @Override public ValueRange range(ChronoField field) { + if (field instanceof ChronoField) { + ChronoField f = field; + switch (f) { + case DAY_OF_MONTH: + return ValueRange.of(1, 1, getMinimumMonthLength(), getMaximumMonthLength()); + case DAY_OF_YEAR: + return ValueRange.of(1, getMaximumDayOfYear()); + case ALIGNED_WEEK_OF_MONTH: + return ValueRange.of(1, 5); + case YEAR: + case YEAR_OF_ERA: + return ValueRange.of(getMinimumYear(), getMaximumYear()); + default: + return field.range(); + } + } return field.range(); } /** - * Check the validity of a yearOfEra. - * @param yearOfEra the year to check + * Check the validity of a year. + * + * @param prolepticYear the year to check */ - void checkValidYearOfEra(int yearOfEra) { - if (yearOfEra < MIN_YEAR_OF_ERA || - yearOfEra > MAX_YEAR_OF_ERA) { - throw new DateTimeException("Invalid year of Hijrah Era"); - } + int checkValidYear(long prolepticYear) { + if (prolepticYear < getMinimumYear() || prolepticYear > getMaximumYear()) { + throw new DateTimeException("Invalid Hijrah year: " + prolepticYear); + } + return (int) prolepticYear; } void checkValidDayOfYear(int dayOfYear) { - if (dayOfYear < 1 || - dayOfYear > getMaximumDayOfYear()) { - throw new DateTimeException("Invalid day of year of Hijrah date"); - } + if (dayOfYear < 1 || dayOfYear > getMaximumDayOfYear()) { + throw new DateTimeException("Invalid Hijrah day of year: " + dayOfYear); + } } void checkValidMonth(int month) { - if (month < 1 || month > 12) { - throw new DateTimeException("Invalid month of Hijrah date"); - } - } - - void checkValidDayOfMonth(int dayOfMonth) { - if (dayOfMonth < 1 || - dayOfMonth > getMaximumDayOfMonth()) { - throw new DateTimeException("Invalid day of month of Hijrah date, day " - + dayOfMonth + " greater than " + getMaximumDayOfMonth() + " or less than 1"); - } + if (month < 1 || month > 12) { + throw new DateTimeException("Invalid Hijrah month: " + month); + } } //----------------------------------------------------------------------- /** - * Returns the int array containing the following field from the julian day. + * Returns an array containing the Hijrah year, month and day + * computed from the epoch day. * - * int[0] = ERA - * int[1] = YEAR - * int[2] = MONTH - * int[3] = DATE - * int[4] = DAY_OF_YEAR - * int[5] = DAY_OF_WEEK - * - * @param gregorianDays a julian day. + * @param epochDay the EpochDay + * @return int[0] = YEAR, int[1] = MONTH, int[2] = DATE */ - int[] getHijrahDateInfo(long gregorianDays) { - int era, year, month, date, dayOfWeek, dayOfYear; - - int cycleNumber, yearInCycle, dayOfCycle; - - long epochDay = gregorianDays - HIJRAH_JAN_1_1_GREGORIAN_DAY; - - if (epochDay >= 0) { - cycleNumber = getCycleNumber(epochDay); // 0 - 99. - dayOfCycle = getDayOfCycle(epochDay, cycleNumber); // 0 - 10631. - yearInCycle = getYearInCycle(cycleNumber, dayOfCycle); // 0 - 29. - dayOfYear = getDayOfYear(cycleNumber, dayOfCycle, yearInCycle); - // 0 - 354/355 - year = cycleNumber * 30 + yearInCycle + 1; // 1-based year. - month = getMonthOfYear(dayOfYear, year); // 0-based month-of-year - date = getDayOfMonth(dayOfYear, month, year); // 0-based date - ++date; // Convert from 0-based to 1-based - era = HijrahEra.AH.getValue(); - } else { - cycleNumber = (int) epochDay / 10631; // 0 or negative number. - dayOfCycle = (int) epochDay % 10631; // -10630 - 0. - if (dayOfCycle == 0) { - dayOfCycle = -10631; - cycleNumber++; - } - yearInCycle = getYearInCycle(cycleNumber, dayOfCycle); // 0 - 29. - dayOfYear = getDayOfYear(cycleNumber, dayOfCycle, yearInCycle); - year = cycleNumber * 30 - yearInCycle; // negative number. - year = 1 - year; - dayOfYear = (isLeapYear(year) ? (dayOfYear + 355) - : (dayOfYear + 354)); - month = getMonthOfYear(dayOfYear, year); - date = getDayOfMonth(dayOfYear, month, year); - ++date; // Convert from 0-based to 1-based - era = HijrahEra.BEFORE_AH.getValue(); + int[] getHijrahDateInfo(int epochDay) { + if (epochDay < minEpochDay || epochDay >= maxEpochDay) { + throw new DateTimeException("Hijrah date out of range"); } - // Hijrah day zero is a Friday - dayOfWeek = (int) ((epochDay + 5) % 7); - dayOfWeek += (dayOfWeek <= 0) ? 7 : 0; - int dateInfo[] = new int[6]; - dateInfo[0] = era; - dateInfo[1] = year; - dateInfo[2] = month + 1; // change to 1-based. - dateInfo[3] = date; - dateInfo[4] = dayOfYear + 1; // change to 1-based. - dateInfo[5] = dayOfWeek; + int epochMonth = epochDayToEpochMonth(epochDay); + int year = epochMonthToYear(epochMonth); + int month = epochMonthToMonth(epochMonth); + int day1 = epochMonthToEpochDay(epochMonth); + int date = epochDay - day1; // epochDay - dayOfEpoch(year, month); + + int dateInfo[] = new int[3]; + dateInfo[0] = year; + dateInfo[1] = month + 1; // change to 1-based. + dateInfo[2] = date + 1; // change to 1-based. return dateInfo; } /** - * Return Gregorian epoch day from Hijrah year, month, and day. + * Return the epoch day computed from Hijrah year, month, and day. * - * @param prolepticYear the year to represent, caller calculated - * @param monthOfYear the month-of-year to represent, caller calculated - * @param dayOfMonth the day-of-month to represent, caller calculated - * @return a julian day + * @param prolepticYear the year to represent, 0-origin + * @param monthOfYear the month-of-year to represent, 1-origin + * @param dayOfMonth the day-of-month to represent, 1-origin + * @return the epoch day */ - long getGregorianEpochDay(int prolepticYear, int monthOfYear, int dayOfMonth) { - long day = yearToGregorianEpochDay(prolepticYear); - day += getMonthDays(monthOfYear - 1, prolepticYear); - day += dayOfMonth; - return day; + long getEpochDay(int prolepticYear, int monthOfYear, int dayOfMonth) { + checkValidMonth(monthOfYear); + int epochMonth = yearToEpochMonth(prolepticYear) + (monthOfYear - 1); + if (epochMonth < 0 || epochMonth >= hijrahEpochMonthStartDays.length) { + throw new DateTimeException("Invalid Hijrah date, year: " + + prolepticYear + ", month: " + monthOfYear); + } + if (dayOfMonth < 1 || dayOfMonth > getMonthLength(prolepticYear, monthOfYear)) { + throw new DateTimeException("Invalid Hijrah day of month: " + dayOfMonth); + } + return epochMonthToEpochDay(epochMonth) + (dayOfMonth - 1); } /** - * Returns the Gregorian epoch day from the proleptic year - * @param prolepticYear the proleptic year - * @return the Epoch day + * Returns day of year for the year and month. + * + * @param prolepticYear a proleptic year + * @param month a month, 1-origin + * @return the day of year, 1-origin */ - private long yearToGregorianEpochDay(int prolepticYear) { - - int cycleNumber = (prolepticYear - 1) / 30; // 0-based. - int yearInCycle = (prolepticYear - 1) % 30; // 0-based. - - int dayInCycle = getAdjustedCycle(cycleNumber)[Math.abs(yearInCycle)] - ; - - if (yearInCycle < 0) { - dayInCycle = -dayInCycle; - } - - Long cycleDays; - - try { - cycleDays = ADJUSTED_CYCLES[cycleNumber]; - } catch (ArrayIndexOutOfBoundsException e) { - cycleDays = null; - } - - if (cycleDays == null) { - cycleDays = new Long(cycleNumber * 10631); - } - - return (cycleDays.longValue() + dayInCycle + HIJRAH_JAN_1_1_GREGORIAN_DAY - 1); + int getDayOfYear(int prolepticYear, int month) { + return yearMonthToDayOfYear(prolepticYear, (month - 1)); } /** - * Returns the 30 year cycle number from the epoch day. + * Returns month length for the year and month. * - * @param epochDay an epoch day - * @return a cycle number + * @param prolepticYear a proleptic year + * @param monthOfYear a month, 1-origin. + * @return the length of the month */ - private int getCycleNumber(long epochDay) { - long[] days = ADJUSTED_CYCLES; - int cycleNumber; - try { - for (int i = 0; i < days.length; i++) { - if (epochDay < days[i]) { - return i - 1; - } - } - cycleNumber = (int) epochDay / 10631; - } catch (ArrayIndexOutOfBoundsException e) { - cycleNumber = (int) epochDay / 10631; + int getMonthLength(int prolepticYear, int monthOfYear) { + int epochMonth = yearToEpochMonth(prolepticYear) + (monthOfYear - 1); + if (epochMonth < 0 || epochMonth >= hijrahEpochMonthStartDays.length) { + throw new DateTimeException("Invalid Hijrah date, year: " + + prolepticYear + ", month: " + monthOfYear); } - return cycleNumber; - } - - /** - * Returns day of cycle from the epoch day and cycle number. - * - * @param epochDay an epoch day - * @param cycleNumber a cycle number - * @return a day of cycle - */ - private int getDayOfCycle(long epochDay, int cycleNumber) { - Long day; - - try { - day = ADJUSTED_CYCLES[cycleNumber]; - } catch (ArrayIndexOutOfBoundsException e) { - day = null; - } - if (day == null) { - day = new Long(cycleNumber * 10631); - } - return (int) (epochDay - day.longValue()); - } - - /** - * Returns the year in cycle from the cycle number and day of cycle. - * - * @param cycleNumber a cycle number - * @param dayOfCycle day of cycle - * @return a year in cycle - */ - private int getYearInCycle(int cycleNumber, long dayOfCycle) { - int[] cycles = getAdjustedCycle(cycleNumber); - if (dayOfCycle == 0) { - return 0; - } - - if (dayOfCycle > 0) { - for (int i = 0; i < cycles.length; i++) { - if (dayOfCycle < cycles[i]) { - return i - 1; - } - } - return 29; - } else { - dayOfCycle = -dayOfCycle; - for (int i = 0; i < cycles.length; i++) { - if (dayOfCycle <= cycles[i]) { - return i - 1; - } - } - return 29; - } - } - - /** - * Returns adjusted 30 year cycle starting day as Integer array from the - * cycle number specified. - * - * @param cycleNumber a cycle number - * @return an Integer array - */ - int[] getAdjustedCycle(int cycleNumber) { - int[] cycles; - try { - cycles = ADJUSTED_CYCLE_YEARS.get(cycleNumber); - } catch (ArrayIndexOutOfBoundsException e) { - cycles = null; - } - if (cycles == null) { - cycles = DEFAULT_CYCLE_YEARS; - } - return cycles; - } - - /** - * Returns adjusted month days as Integer array form the year specified. - * - * @param year a year - * @return an Integer array - */ - int[] getAdjustedMonthDays(int year) { - int[] newMonths; - try { - newMonths = ADJUSTED_MONTH_DAYS.get(year); - } catch (ArrayIndexOutOfBoundsException e) { - newMonths = null; - } - if (newMonths == null) { - if (isLeapYear0(year)) { - newMonths = DEFAULT_LEAP_MONTH_DAYS; - } else { - newMonths = DEFAULT_MONTH_DAYS; - } - } - return newMonths; - } - - /** - * Returns adjusted month length as Integer array form the year specified. - * - * @param year a year - * @return an Integer array - */ - int[] getAdjustedMonthLength(int year) { - int[] newMonths; - try { - newMonths = ADJUSTED_MONTH_LENGTHS.get(year); - } catch (ArrayIndexOutOfBoundsException e) { - newMonths = null; - } - if (newMonths == null) { - if (isLeapYear0(year)) { - newMonths = DEFAULT_LEAP_MONTH_LENGTHS; - } else { - newMonths = DEFAULT_MONTH_LENGTHS; - } - } - return newMonths; - } - - /** - * Returns day-of-year. - * - * @param cycleNumber a cycle number - * @param dayOfCycle day of cycle - * @param yearInCycle year in cycle - * @return day-of-year - */ - private int getDayOfYear(int cycleNumber, int dayOfCycle, int yearInCycle) { - int[] cycles = getAdjustedCycle(cycleNumber); - - if (dayOfCycle > 0) { - return dayOfCycle - cycles[yearInCycle]; - } else { - return cycles[yearInCycle] + dayOfCycle; - } - } - - /** - * Returns month-of-year. 0-based. - * - * @param dayOfYear day-of-year - * @param year a year - * @return month-of-year - */ - private int getMonthOfYear(int dayOfYear, int year) { - - int[] newMonths = getAdjustedMonthDays(year); - - if (dayOfYear >= 0) { - for (int i = 0; i < newMonths.length; i++) { - if (dayOfYear < newMonths[i]) { - return i - 1; - } - } - return 11; - } else { - dayOfYear = (isLeapYear0(year) ? (dayOfYear + 355) - : (dayOfYear + 354)); - for (int i = 0; i < newMonths.length; i++) { - if (dayOfYear < newMonths[i]) { - return i - 1; - } - } - return 11; - } - } - - /** - * Returns day-of-month. - * - * @param dayOfYear day of year - * @param month month - * @param year year - * @return day-of-month - */ - private int getDayOfMonth(int dayOfYear, int month, int year) { - - int[] newMonths = getAdjustedMonthDays(year); - - if (dayOfYear >= 0) { - if (month > 0) { - return dayOfYear - newMonths[month]; - } else { - return dayOfYear; - } - } else { - dayOfYear = (isLeapYear0(year) ? (dayOfYear + 355) - : (dayOfYear + 354)); - if (month > 0) { - return dayOfYear - newMonths[month]; - } else { - return dayOfYear; - } - } - } - - - /** - * Returns month days from the beginning of year. - * - * @param month month (0-based) - * @parma year year - * @return month days from the beginning of year - */ - private int getMonthDays(int month, int year) { - int[] newMonths = getAdjustedMonthDays(year); - return newMonths[month]; - } - - /** - * Returns month length. - * - * @param month month (0-based) - * @param year year - * @return month length - */ - private int getMonthLength(int month, int year) { - int[] newMonths = getAdjustedMonthLength(year); - return newMonths[month]; + return epochMonthLength(epochMonth); } /** * Returns year length. + * Note: The 12th month must exist in the data. * - * @param year year - * @return year length + * @param prolepticYear a proleptic year + * @return year length in days */ - int getYearLength(int year) { - - int cycleNumber = (year - 1) / 30; - int[] cycleYears; - try { - cycleYears = ADJUSTED_CYCLE_YEARS.get(cycleNumber); - } catch (ArrayIndexOutOfBoundsException e) { - cycleYears = null; - } - if (cycleYears != null) { - int yearInCycle = (year - 1) % 30; - if (yearInCycle == 29) { - return (int)(ADJUSTED_CYCLES[cycleNumber + 1] - - ADJUSTED_CYCLES[cycleNumber] - - cycleYears[yearInCycle]); - } - return cycleYears[yearInCycle + 1] - - cycleYears[yearInCycle]; - } else { - return isLeapYear0(year) ? 355 : 354; - } + int getYearLength(int prolepticYear) { + return yearMonthToDayOfYear(prolepticYear, 12); } + /** + * Return the minimum supported Hijrah year. + * + * @return the minimum + */ + int getMinimumYear() { + return epochMonthToYear(0); + } + + /** + * Return the maximum supported Hijrah ear. + * + * @return the minimum + */ + int getMaximumYear() { + return epochMonthToYear(hijrahEpochMonthStartDays.length - 1) - 1; + } /** * Returns maximum day-of-month. * * @return maximum day-of-month */ - int getMaximumDayOfMonth() { - return ADJUSTED_MAX_VALUES[POSITION_DAY_OF_MONTH]; + int getMaximumMonthLength() { + return maxMonthLength; } /** @@ -1069,8 +703,8 @@ public final class HijrahChronology extends Chronology implements Serializable { * * @return smallest maximum day-of-month */ - int getSmallestMaximumDayOfMonth() { - return ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_MONTH]; + int getMinimumMonthLength() { + return minMonthLength; } /** @@ -1079,7 +713,7 @@ public final class HijrahChronology extends Chronology implements Serializable { * @return maximum day-of-year */ int getMaximumDayOfYear() { - return ADJUSTED_MAX_VALUES[POSITION_DAY_OF_YEAR]; + return maxYearLength; } /** @@ -1088,296 +722,303 @@ public final class HijrahChronology extends Chronology implements Serializable { * @return smallest maximum day-of-year */ int getSmallestMaximumDayOfYear() { - return ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_YEAR]; + return minYearLength; } - // ----- Deviation handling -----// - /** - * Adds deviation definition. The year and month specified should be the - * calculated Hijrah year and month. The month is 1 based. e.g. 9 for - * Ramadan (9th month) Addition of anything minus deviation days is - * calculated negatively in the case the user wants to subtract days from - * the calendar. For example, adding -1 days will subtract one day from the - * current date. + * Returns the epochMonth found by locating the epochDay in the table. The + * epochMonth is the index in the table * - * @param startYear start year, 1 origin - * @param startMonth start month, 1 origin - * @param endYear end year, 1 origin - * @param endMonth end month, 1 origin - * @param offset offset -2, -1, +1, +2 + * @param epochDay + * @return The index of the element of the start of the month containing the + * epochDay. */ - private void addDeviationAsHijrah(Deviation entry) { - int startYear = entry.startYear; - int startMonth = entry.startMonth - 1 ; - int endYear = entry.endYear; - int endMonth = entry.endMonth - 1; - int offset = entry.offset; - - if (startYear < 1) { - throw new IllegalArgumentException("startYear < 1"); + private int epochDayToEpochMonth(int epochDay) { + // binary search + int ndx = Arrays.binarySearch(hijrahEpochMonthStartDays, epochDay); + if (ndx < 0) { + ndx = -ndx - 2; } - if (endYear < 1) { - throw new IllegalArgumentException("endYear < 1"); - } - if (startMonth < 0 || startMonth > 11) { - throw new IllegalArgumentException( - "startMonth < 0 || startMonth > 11"); - } - if (endMonth < 0 || endMonth > 11) { - throw new IllegalArgumentException("endMonth < 0 || endMonth > 11"); - } - if (endYear > 9999) { - throw new IllegalArgumentException("endYear > 9999"); - } - if (endYear < startYear) { - throw new IllegalArgumentException("startYear > endYear"); - } - if (endYear == startYear && endMonth < startMonth) { - throw new IllegalArgumentException( - "startYear == endYear && endMonth < startMonth"); - } - - // Adjusting start year. - boolean isStartYLeap = isLeapYear0(startYear); - - // Adjusting the number of month. - int[] orgStartMonthNums = ADJUSTED_MONTH_DAYS.get(startYear); - if (orgStartMonthNums == null) { - if (isStartYLeap) { - orgStartMonthNums = Arrays.copyOf(LEAP_NUM_DAYS, LEAP_NUM_DAYS.length); - } else { - orgStartMonthNums = Arrays.copyOf(NUM_DAYS, NUM_DAYS.length); - } - } - - int[] newStartMonthNums = new int[orgStartMonthNums.length]; - - for (int month = 0; month < 12; month++) { - if (month > startMonth) { - newStartMonthNums[month] = (orgStartMonthNums[month] - offset); - } else { - newStartMonthNums[month] = (orgStartMonthNums[month]); - } - } - - ADJUSTED_MONTH_DAYS.put(startYear, newStartMonthNums); - - // Adjusting the days of month. - - int[] orgStartMonthLengths = ADJUSTED_MONTH_LENGTHS.get(startYear); - if (orgStartMonthLengths == null) { - if (isStartYLeap) { - orgStartMonthLengths = Arrays.copyOf(LEAP_MONTH_LENGTH, LEAP_MONTH_LENGTH.length); - } else { - orgStartMonthLengths = Arrays.copyOf(MONTH_LENGTH, MONTH_LENGTH.length); - } - } - - int[] newStartMonthLengths = new int[orgStartMonthLengths.length]; - - for (int month = 0; month < 12; month++) { - if (month == startMonth) { - newStartMonthLengths[month] = orgStartMonthLengths[month] - offset; - } else { - newStartMonthLengths[month] = orgStartMonthLengths[month]; - } - } - - ADJUSTED_MONTH_LENGTHS.put(startYear, newStartMonthLengths); - - if (startYear != endYear) { - // System.out.println("over year"); - // Adjusting starting 30 year cycle. - int sCycleNumber = (startYear - 1) / 30; - int sYearInCycle = (startYear - 1) % 30; // 0-based. - int[] startCycles = ADJUSTED_CYCLE_YEARS.get(sCycleNumber); - if (startCycles == null) { - startCycles = Arrays.copyOf(CYCLEYEAR_START_DATE, CYCLEYEAR_START_DATE.length); - } - - for (int j = sYearInCycle + 1; j < CYCLEYEAR_START_DATE.length; j++) { - startCycles[j] = startCycles[j] - offset; - } - - // System.out.println(sCycleNumber + ":" + sYearInCycle); - ADJUSTED_CYCLE_YEARS.put(sCycleNumber, startCycles); - - int sYearInMaxY = (startYear - 1) / 30; - int sEndInMaxY = (endYear - 1) / 30; - - if (sYearInMaxY != sEndInMaxY) { - // System.out.println("over 30"); - // Adjusting starting 30 * MAX_ADJUSTED_CYCLE year cycle. - // System.out.println(sYearInMaxY); - - for (int j = sYearInMaxY + 1; j < ADJUSTED_CYCLES.length; j++) { - ADJUSTED_CYCLES[j] = ADJUSTED_CYCLES[j] - offset; - } - - // Adjusting ending 30 * MAX_ADJUSTED_CYCLE year cycles. - for (int j = sEndInMaxY + 1; j < ADJUSTED_CYCLES.length; j++) { - ADJUSTED_CYCLES[j] = ADJUSTED_CYCLES[j] + offset; - } - } - - // Adjusting ending 30 year cycle. - int eCycleNumber = (endYear - 1) / 30; - int sEndInCycle = (endYear - 1) % 30; // 0-based. - int[] endCycles = ADJUSTED_CYCLE_YEARS.get(eCycleNumber); - if (endCycles == null) { - endCycles = Arrays.copyOf(CYCLEYEAR_START_DATE, CYCLEYEAR_START_DATE.length); - } - for (int j = sEndInCycle + 1; j < CYCLEYEAR_START_DATE.length; j++) { - endCycles[j] = endCycles[j] + offset; - } - ADJUSTED_CYCLE_YEARS.put(eCycleNumber, endCycles); - } - - // Adjusting ending year. - boolean isEndYLeap = isLeapYear0(endYear); - - int[] orgEndMonthDays = ADJUSTED_MONTH_DAYS.get(endYear); - - if (orgEndMonthDays == null) { - if (isEndYLeap) { - orgEndMonthDays = Arrays.copyOf(LEAP_NUM_DAYS, LEAP_NUM_DAYS.length); - } else { - orgEndMonthDays = Arrays.copyOf(NUM_DAYS, NUM_DAYS.length); - } - } - - int[] newEndMonthDays = new int[orgEndMonthDays.length]; - - for (int month = 0; month < 12; month++) { - if (month > endMonth) { - newEndMonthDays[month] = orgEndMonthDays[month] + offset; - } else { - newEndMonthDays[month] = orgEndMonthDays[month]; - } - } - - ADJUSTED_MONTH_DAYS.put(endYear, newEndMonthDays); - - // Adjusting the days of month. - int[] orgEndMonthLengths = ADJUSTED_MONTH_LENGTHS.get(endYear); - - if (orgEndMonthLengths == null) { - if (isEndYLeap) { - orgEndMonthLengths = Arrays.copyOf(LEAP_MONTH_LENGTH, LEAP_MONTH_LENGTH.length); - } else { - orgEndMonthLengths = Arrays.copyOf(MONTH_LENGTH, MONTH_LENGTH.length); - } - } - - int[] newEndMonthLengths = new int[orgEndMonthLengths.length]; - - for (int month = 0; month < 12; month++) { - if (month == endMonth) { - newEndMonthLengths[month] = orgEndMonthLengths[month] + offset; - } else { - newEndMonthLengths[month] = orgEndMonthLengths[month]; - } - } - - ADJUSTED_MONTH_LENGTHS.put(endYear, newEndMonthLengths); - - int[] startMonthLengths = ADJUSTED_MONTH_LENGTHS.get(startYear); - int[] endMonthLengths = ADJUSTED_MONTH_LENGTHS.get(endYear); - int[] startMonthDays = ADJUSTED_MONTH_DAYS.get(startYear); - int[] endMonthDays = ADJUSTED_MONTH_DAYS.get(endYear); - - int startMonthLength = startMonthLengths[startMonth]; - int endMonthLength = endMonthLengths[endMonth]; - int startMonthDay = startMonthDays[11] + startMonthLengths[11]; - int endMonthDay = endMonthDays[11] + endMonthLengths[11]; - - int maxMonthLength = ADJUSTED_MAX_VALUES[POSITION_DAY_OF_MONTH]; - int leastMaxMonthLength = ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_MONTH]; - - if (maxMonthLength < startMonthLength) { - maxMonthLength = startMonthLength; - } - if (maxMonthLength < endMonthLength) { - maxMonthLength = endMonthLength; - } - ADJUSTED_MAX_VALUES[POSITION_DAY_OF_MONTH] = maxMonthLength; - - if (leastMaxMonthLength > startMonthLength) { - leastMaxMonthLength = startMonthLength; - } - if (leastMaxMonthLength > endMonthLength) { - leastMaxMonthLength = endMonthLength; - } - ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_MONTH] = leastMaxMonthLength; - - int maxMonthDay = ADJUSTED_MAX_VALUES[POSITION_DAY_OF_YEAR]; - int leastMaxMonthDay = ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_YEAR]; - - if (maxMonthDay < startMonthDay) { - maxMonthDay = startMonthDay; - } - if (maxMonthDay < endMonthDay) { - maxMonthDay = endMonthDay; - } - - ADJUSTED_MAX_VALUES[POSITION_DAY_OF_YEAR] = maxMonthDay; - - if (leastMaxMonthDay > startMonthDay) { - leastMaxMonthDay = startMonthDay; - } - if (leastMaxMonthDay > endMonthDay) { - leastMaxMonthDay = endMonthDay; - } - ADJUSTED_LEAST_MAX_VALUES[POSITION_DAY_OF_YEAR] = leastMaxMonthDay; + return ndx; } /** - * Package private Entry for suppling deviations from the Reader. - * Each entry consists of a range using the Hijrah calendar, - * start year, month, end year, end month, and an offset. - * The offset is used to modify the length of the month +2, +1, -1, -2. + * Returns the year computed from the epochMonth + * + * @param epochMonth the epochMonth + * @return the Hijrah Year */ - static final class Deviation { + private int epochMonthToYear(int epochMonth) { + return (epochMonth + hijrahStartEpochMonth) / 12; + } - Deviation(int startYear, int startMonth, int endYear, int endMonth, int offset) { - this.startYear = startYear; - this.startMonth = startMonth; - this.endYear = endYear; - this.endMonth = endMonth; - this.offset = offset; - } + /** + * Returns the epochMonth for the Hijrah Year. + * + * @param year the HijrahYear + * @return the epochMonth for the beginning of the year. + */ + private int yearToEpochMonth(int year) { + return (year * 12) - hijrahStartEpochMonth; + } - final int startYear; - final int startMonth; - final int endYear; - final int endMonth; - final int offset; + /** + * Returns the Hijrah month from the epochMonth. + * + * @param epochMonth the epochMonth + * @return the month of the Hijrah Year + */ + private int epochMonthToMonth(int epochMonth) { + return (epochMonth + hijrahStartEpochMonth) % 12; + } - int getStartYear() { - return startYear; - } + /** + * Returns the epochDay for the start of the epochMonth. + * + * @param epochMonth the epochMonth + * @return the epochDay for the start of the epochMonth. + */ + private int epochMonthToEpochDay(int epochMonth) { + return hijrahEpochMonthStartDays[epochMonth]; - int getStartMonth() { - return startMonth; - } + } - int getEndYear() { - return endYear; - } + /** + * Returns the day of year for the requested HijrahYear and month. + * + * @param prolepticYear the Hijrah year + * @param month the Hijrah month + * @return the day of year for the start of the month of the year + */ + private int yearMonthToDayOfYear(int prolepticYear, int month) { + int epochMonthFirst = yearToEpochMonth(prolepticYear); + return epochMonthToEpochDay(epochMonthFirst + month) + - epochMonthToEpochDay(epochMonthFirst); + } - int getEndMonth() { - return endMonth; - } + /** + * Returns the length of the epochMonth. It is computed from the start of + * the following month minus the start of the requested month. + * + * @param epochMonth the epochMonth; assumed to be within range + * @return the length in days of the epochMonth + */ + private int epochMonthLength(int epochMonth) { + // The very last entry in the epochMonth table is not the start of a month + return hijrahEpochMonthStartDays[epochMonth + 1] + - hijrahEpochMonthStartDays[epochMonth]; + } - int getOffset() { - return offset; - } + //----------------------------------------------------------------------- + private static final String KEY_ID = "id"; + private static final String KEY_TYPE = "type"; + private static final String KEY_VERSION = "version"; + private static final String KEY_ISO_START = "iso-start"; - @Override - public String toString() { - return String.format("[year: %4d, month: %2d, offset: %+d]", startYear, startMonth, offset); + /** + * Return the configuration properties from the resource. + *

    + * The default location of the variant configuration resource is: + *

    +     *   "$java.home/lib/" + resource-name
    +     * 
    + * + * @param resource the name of the calendar property resource + * @return a Properties containing the properties read from the resource. + * @throws Exception if access to the property resource fails + */ + private static Properties readConfigProperties(final String resource) throws Exception { + try { + return AccessController + .doPrivileged((java.security.PrivilegedExceptionAction) + () -> { + String libDir = System.getProperty("java.home") + File.separator + "lib"; + File file = new File(libDir, resource); + Properties props = new Properties(); + try (InputStream is = new FileInputStream(file)) { + props.load(is); + } + return props; + }); + } catch (PrivilegedActionException pax) { + throw pax.getException(); } } + /** + * Loads and processes the Hijrah calendar properties file. + * The starting Hijrah date and the corresponding ISO date are + * extracted and used to calculate the epochDate offset. + * The version number is identified and ignored. + * Everything else is the data for a year with containing the length of each + * of 12 months. + * + * @param resourceName containing the properties defining the calendar, not null + * @throws IllegalArgumentException if any of the values are malformed + * @throws NumberFormatException if numbers, including properties that should + * be years are invalid + * @throws IOException if access to the property resource fails. + */ + private void loadCalendarData(String resourceName) throws Exception { + Properties props = readConfigProperties(resourceName); + + Map years = new HashMap<>(); + int minYear = Integer.MAX_VALUE; + int maxYear = Integer.MIN_VALUE; + String id = null; + String type = null; + String version = null; + int isoStart = 0; + for (Map.Entry entry : props.entrySet()) { + String key = (String) entry.getKey(); + switch (key) { + case KEY_ID: + id = (String)entry.getValue(); + break; + case KEY_TYPE: + type = (String)entry.getValue(); + break; + case KEY_VERSION: + version = (String)entry.getValue(); + break; + case KEY_ISO_START: { + int[] ymd = parseYMD((String) entry.getValue()); + isoStart = (int) LocalDate.of(ymd[0], ymd[1], ymd[2]).toEpochDay(); + break; + } + default: + try { + // Everything else is either a year or invalid + int year = Integer.valueOf(key); + int[] months = parseMonths((String) entry.getValue()); + years.put(year, months); + maxYear = Math.max(maxYear, year); + minYear = Math.min(minYear, year); + } catch (NumberFormatException nfe) { + throw new IllegalArgumentException("bad key: " + key); + } + } + } + + if (!getId().equals(id)) { + throw new IllegalArgumentException("Configuration is for a different calendar: " + id); + } + if (!getCalendarType().equals(type)) { + throw new IllegalArgumentException("Configuration is for a different calendar type: " + type); + } + if (version == null || version.isEmpty()) { + throw new IllegalArgumentException("Configuration does not contain a version"); + } + if (isoStart == 0) { + throw new IllegalArgumentException("Configuration does not contain a ISO start date"); + } + + // Now create and validate the array of epochDays indexed by epochMonth + hijrahStartEpochMonth = minYear * 12; + minEpochDay = isoStart; + hijrahEpochMonthStartDays = createEpochMonths(minEpochDay, minYear, maxYear, years); + maxEpochDay = hijrahEpochMonthStartDays[hijrahEpochMonthStartDays.length - 1]; + + // Compute the min and max year length in days. + for (int year = minYear; year < maxYear; year++) { + int length = getYearLength(year); + minYearLength = Math.min(minYearLength, length); + maxYearLength = Math.max(maxYearLength, length); + } + } + + /** + * Converts the map of year to month lengths ranging from minYear to maxYear + * into a linear contiguous array of epochDays. The index is the hijrahMonth + * computed from year and month and offset by minYear. The value of each + * entry is the epochDay corresponding to the first day of the month. + * + * @param minYear The minimum year for which data is provided + * @param maxYear The maximum year for which data is provided + * @param years a Map of year to the array of 12 month lengths + * @return array of epochDays for each month from min to max + */ + private int[] createEpochMonths(int epochDay, int minYear, int maxYear, Map years) { + // Compute the size for the array of dates + int numMonths = (maxYear - minYear + 1) * 12 + 1; + + // Initialize the running epochDay as the corresponding ISO Epoch day + int epochMonth = 0; // index into array of epochMonths + int[] epochMonths = new int[numMonths]; + minMonthLength = Integer.MAX_VALUE; + maxMonthLength = Integer.MIN_VALUE; + + // Only whole years are valid, any zero's in the array are illegal + for (int year = minYear; year <= maxYear; year++) { + int[] months = years.get(year);// must not be gaps + for (int month = 0; month < 12; month++) { + int length = months[month]; + epochMonths[epochMonth++] = epochDay; + + if (length < 29 || length > 32) { + throw new IllegalArgumentException("Invalid month length in year: " + minYear); + } + epochDay += length; + minMonthLength = Math.min(minMonthLength, length); + maxMonthLength = Math.max(maxMonthLength, length); + } + } + + // Insert the final epochDay + epochMonths[epochMonth++] = epochDay; + + if (epochMonth != epochMonths.length) { + throw new IllegalStateException("Did not fill epochMonths exactly: ndx = " + epochMonth + + " should be " + epochMonths.length); + } + + return epochMonths; + } + + /** + * Parses the 12 months lengths from a property value for a specific year. + * + * @param line the value of a year property + * @return an array of int[12] containing the 12 month lengths + * @throws IllegalArgumentException if the number of months is not 12 + * @throws NumberFormatException if the 12 tokens are not numbers + */ + private int[] parseMonths(String line) { + int[] months = new int[12]; + String[] numbers = line.split("\\s"); + if (numbers.length != 12) { + throw new IllegalArgumentException("wrong number of months on line: " + Arrays.toString(numbers) + "; count: " + numbers.length); + } + for (int i = 0; i < 12; i++) { + try { + months[i] = Integer.valueOf(numbers[i]); + } catch (NumberFormatException nfe) { + throw new IllegalArgumentException("bad key: " + numbers[i]); + } + } + return months; + } + + /** + * Parse yyyy-MM-dd into a 3 element array [yyyy, mm, dd]. + * + * @param string the input string + * @return the 3 element array with year, month, day + */ + private int[] parseYMD(String string) { + // yyyy-MM-dd + string = string.trim(); + try { + if (string.charAt(4) != '-' || string.charAt(7) != '-') { + throw new IllegalArgumentException("date must be yyyy-MM-dd"); + } + int[] ymd = new int[3]; + ymd[0] = Integer.valueOf(string.substring(0, 4)); + ymd[1] = Integer.valueOf(string.substring(5, 7)); + ymd[2] = Integer.valueOf(string.substring(8, 10)); + return ymd; + } catch (NumberFormatException ex) { + throw new IllegalArgumentException("date must be yyyy-MM-dd", ex); + } + } } diff --git a/jdk/src/share/classes/java/time/chrono/HijrahDate.java b/jdk/src/share/classes/java/time/chrono/HijrahDate.java index 2d98cd40eff..fc9bd5b0e8e 100644 --- a/jdk/src/share/classes/java/time/chrono/HijrahDate.java +++ b/jdk/src/share/classes/java/time/chrono/HijrahDate.java @@ -70,55 +70,38 @@ import java.io.ObjectOutput; import java.io.Serializable; import java.time.Clock; import java.time.DateTimeException; -import java.time.DayOfWeek; import java.time.LocalDate; import java.time.LocalTime; import java.time.Period; import java.time.ZoneId; import java.time.temporal.ChronoField; -import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; -import java.util.Objects; /** * A date in the Hijrah calendar system. *

    - * This date operates using the {@linkplain HijrahChronology Hijrah calendar}. + * This date operates using one of several variants of the + * {@linkplain HijrahChronology Hijrah calendar}. *

    * The Hijrah calendar has a different total of days in a year than - * Gregorian calendar, and a month is based on the period of a complete - * revolution of the moon around the earth (as between successive new moons). - * The calendar cycles becomes longer and unstable, and sometimes a manual - * adjustment (for entering deviation) is necessary for correctness - * because of the complex algorithm. + * Gregorian calendar, and the length of each month is based on the period + * of a complete revolution of the moon around the earth + * (as between successive new moons). + * Refer to the {@link HijrahChronology} for details of supported variants. *

    - * HijrahDate supports the manual adjustment feature by providing a configuration - * file. The configuration file contains the adjustment (deviation) data with following format. - *

    - *   StartYear/StartMonth(0-based)-EndYear/EndMonth(0-based):Deviation day (1, 2, -1, or -2)
    - *   Line separator or ";" is used for the separator of each deviation data.
    - * Here is the example. - *
    - *     1429/0-1429/1:1
    - *     1429/2-1429/7:1;1429/6-1429/11:1
    - *     1429/11-9999/11:1
    - * The default location of the configuration file is: - *
    - *   $CLASSPATH/java/time/i18n
    - * And the default file name is: - *
    - *   hijrah_deviation.cfg
    - * The default location and file name can be overriden by setting - * following two Java's system property. - *
    - *   Location: java.time.i18n.HijrahDate.deviationConfigDir
    - *   File name: java.time.i18n.HijrahDate.deviationConfigFile
    - * + * Each HijrahDate is created bound to a particular HijrahChronology, + * The same chronology is propagated to each HijrahDate computed from the date. + * To use a different Hijrah variant, its HijrahChronology can be used + * to create new HijrahDate instances. + * Alternatively, the {@link #withVariant} method can be used to convert + * to a new HijrahChronology. *

    Specification for implementors

    * This class is immutable and thread-safe. * @@ -132,19 +115,14 @@ public final class HijrahDate * Serialization version. */ private static final long serialVersionUID = -5207853542612002020L; - /** * The Chronology of this HijrahDate. */ private final HijrahChronology chrono; /** - * The era. + * The proleptic year. */ - private final transient HijrahEra era; - /** - * The year. - */ - private final transient int yearOfEra; + private final transient int prolepticYear; /** * The month-of-year. */ @@ -153,69 +131,36 @@ public final class HijrahDate * The day-of-month. */ private final transient int dayOfMonth; - /** - * The day-of-year. - */ - private final transient int dayOfYear; - /** - * The day-of-week. - */ - private final transient DayOfWeek dayOfWeek; - /** - * Gregorian days for this object. Holding number of days since 1970/01/01. - * The number of days are calculated with pure Gregorian calendar - * based. - */ - private final long gregorianEpochDay; - /** - * True if year is leap year. - */ - private final transient boolean isLeapYear; //------------------------------------------------------------------------- /** - * Obtains an instance of {@code HijrahDate} from the Hijrah era year, - * month-of-year and day-of-month. This uses the Hijrah era. + * Obtains an instance of {@code HijrahDate} from the Hijrah proleptic year, + * month-of-year and day-of-month. * - * @param prolepticYear the proleptic year to represent in the Hijrah + * @param prolepticYear the proleptic year to represent in the Hijrah calendar * @param monthOfYear the month-of-year to represent, from 1 to 12 * @param dayOfMonth the day-of-month to represent, from 1 to 30 * @return the Hijrah date, never null * @throws DateTimeException if the value of any field is out of range */ static HijrahDate of(HijrahChronology chrono, int prolepticYear, int monthOfYear, int dayOfMonth) { - return (prolepticYear >= 1) ? - HijrahDate.of(chrono, HijrahEra.AH, prolepticYear, monthOfYear, dayOfMonth) : - HijrahDate.of(chrono, HijrahEra.BEFORE_AH, 1 - prolepticYear, monthOfYear, dayOfMonth); + return new HijrahDate(chrono, prolepticYear, monthOfYear, dayOfMonth); } /** - * Obtains an instance of {@code HijrahDate} from the era, year-of-era - * month-of-year and day-of-month. - * - * @param era the era to represent, not null - * @param yearOfEra the year-of-era to represent, from 1 to 9999 - * @param monthOfYear the month-of-year to represent, from 1 to 12 - * @param dayOfMonth the day-of-month to represent, from 1 to 31 - * @return the Hijrah date, never null - * @throws DateTimeException if the value of any field is out of range + * Returns a HijrahDate for the chronology and epochDay. + * @param chrono The Hijrah chronology + * @param epochDay the epoch day + * @return a HijrahDate for the epoch day; non-null */ - private static HijrahDate of(HijrahChronology chrono, HijrahEra era, int yearOfEra, int monthOfYear, int dayOfMonth) { - Objects.requireNonNull(era, "era"); - chrono.checkValidYearOfEra(yearOfEra); - chrono.checkValidMonth(monthOfYear); - chrono.checkValidDayOfMonth(dayOfMonth); - long gregorianDays = chrono.getGregorianEpochDay(era.prolepticYear(yearOfEra), monthOfYear, dayOfMonth); - return new HijrahDate(chrono, gregorianDays); - } - static HijrahDate ofEpochDay(HijrahChronology chrono, long epochDay) { return new HijrahDate(chrono, epochDay); } //----------------------------------------------------------------------- /** - * Obtains the current {@code HijrahDate} from the system clock in the default time-zone. + * Obtains the current {@code HijrahDate} of the Islamic Umm Al-Qura calendar + * in the default time-zone. *

    * This will query the {@link Clock#systemDefaultZone() system clock} in the default * time-zone to obtain the current date. @@ -230,7 +175,8 @@ public final class HijrahDate } /** - * Obtains the current {@code HijrahDate} from the system clock in the specified time-zone. + * Obtains the current {@code HijrahDate} of the Islamic Umm Al-Qura calendar + * in the specified time-zone. *

    * This will query the {@link Clock#system(ZoneId) system clock} to obtain the current date. * Specifying the time-zone avoids dependence on the default time-zone. @@ -246,7 +192,8 @@ public final class HijrahDate } /** - * Obtains the current {@code HijrahDate} from the specified clock. + * Obtains the current {@code HijrahDate} of the Islamic Umm Al-Qura calendar + * from the specified clock. *

    * This will query the specified clock to obtain the current date - today. * Using this method allows the use of an alternate clock for testing. @@ -261,8 +208,8 @@ public final class HijrahDate } /** - * Obtains a {@code HijrahDate} representing a date in the Hijrah calendar - * system from the proleptic-year, month-of-year and day-of-month fields. + * Obtains a {@code HijrahDate} of the Islamic Umm Al-Qura calendar + * from the proleptic-year, month-of-year and day-of-month fields. *

    * This returns a {@code HijrahDate} with the specified fields. * The day must be valid for the year and month, otherwise an exception will be thrown. @@ -279,7 +226,7 @@ public final class HijrahDate } /** - * Obtains a {@code HijrahDate} from a temporal object. + * Obtains a {@code HijrahDate} of the Islamic Umm Al-Qura calendar from a temporal object. *

    * This obtains a date in the Hijrah calendar system based on the specified temporal. * A {@code TemporalAccessor} represents an arbitrary set of date and time information, @@ -301,35 +248,93 @@ public final class HijrahDate //----------------------------------------------------------------------- /** - * Constructs an instance with the specified date. + * Constructs an {@code HijrahDate} with the proleptic-year, month-of-year and + * day-of-month fields. * - * @param gregorianDay the number of days from 0001/01/01 (Gregorian), caller calculated + * @param chrono The chronology to create the date with + * @param prolepticYear the proleptic year + * @param monthOfYear the month of year + * @param dayOfMonth the day of month */ - private HijrahDate(HijrahChronology chrono, long gregorianDay) { + private HijrahDate(HijrahChronology chrono, int prolepticYear, int monthOfYear, int dayOfMonth) { + // Computing the Gregorian day checks the valid ranges + chrono.getEpochDay(prolepticYear, monthOfYear, dayOfMonth); + this.chrono = chrono; - int[] dateInfo = chrono.getHijrahDateInfo(gregorianDay); + this.prolepticYear = prolepticYear; + this.monthOfYear = monthOfYear; + this.dayOfMonth = dayOfMonth; + } - chrono.checkValidYearOfEra(dateInfo[1]); - chrono.checkValidMonth(dateInfo[2]); - chrono.checkValidDayOfMonth(dateInfo[3]); - chrono.checkValidDayOfYear(dateInfo[4]); + /** + * Constructs an instance with the Epoch Day. + * + * @param epochDay the epochDay + */ + private HijrahDate(HijrahChronology chrono, long epochDay) { + int[] dateInfo = chrono.getHijrahDateInfo((int)epochDay); - this.era = HijrahEra.of(dateInfo[0]); - this.yearOfEra = dateInfo[1]; - this.monthOfYear = dateInfo[2]; - this.dayOfMonth = dateInfo[3]; - this.dayOfYear = dateInfo[4]; - this.dayOfWeek = DayOfWeek.of(dateInfo[5]); - this.gregorianEpochDay = gregorianDay; - this.isLeapYear = chrono.isLeapYear(this.yearOfEra); + this.chrono = chrono; + this.prolepticYear = dateInfo[0]; + this.monthOfYear = dateInfo[1]; + this.dayOfMonth = dateInfo[2]; } //----------------------------------------------------------------------- + /** + * Gets the chronology of this date, which is the Hijrah calendar system. + *

    + * The {@code Chronology} represents the calendar system in use. + * The era and other fields in {@link ChronoField} are defined by the chronology. + * + * @return the Hijrah chronology, not null + */ @Override public HijrahChronology getChronology() { return chrono; } + /** + * Gets the era applicable at this date. + *

    + * The Hijrah calendar system has one era, 'AH', + * defined by {@link HijrahEra}. + * + * @return the era applicable at this date, not null + */ + @Override + public HijrahEra getEra() { + return HijrahEra.AH; + } + + /** + * Returns the length of the month represented by this date. + *

    + * This returns the length of the month in days. + * Month lengths in the Hijrah calendar system vary between 29 and 30 days. + * + * @return the length of the month in days + */ + @Override + public int lengthOfMonth() { + return chrono.getMonthLength(prolepticYear, monthOfYear); + } + + /** + * Returns the length of the year represented by this date. + *

    + * This returns the length of the year in days. + * A Hijrah calendar system year is typically shorter than + * that of the ISO calendar system. + * + * @return the length of the year in days + */ + @Override + public int lengthOfYear() { + return chrono.getYearLength(prolepticYear); + } + + //----------------------------------------------------------------------- @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { @@ -339,83 +344,106 @@ public final class HijrahDate case DAY_OF_MONTH: return ValueRange.of(1, lengthOfMonth()); case DAY_OF_YEAR: return ValueRange.of(1, lengthOfYear()); case ALIGNED_WEEK_OF_MONTH: return ValueRange.of(1, 5); // TODO - case YEAR_OF_ERA: return ValueRange.of(1, 1000); // TODO + // TODO does the limited range of valid years cause years to + // start/end part way through? that would affect range } return getChronology().range(f); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } - @Override // Override for javadoc - public int get(TemporalField field) { - return super.get(field); - } - @Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { - case DAY_OF_WEEK: return dayOfWeek.getValue(); - case ALIGNED_DAY_OF_WEEK_IN_MONTH: return ((dayOfWeek.getValue() - 1) % 7) + 1; - case ALIGNED_DAY_OF_WEEK_IN_YEAR: return ((dayOfYear - 1) % 7) + 1; + case DAY_OF_WEEK: return getDayOfWeek(); + case ALIGNED_DAY_OF_WEEK_IN_MONTH: return ((getDayOfWeek() - 1) % 7) + 1; + case ALIGNED_DAY_OF_WEEK_IN_YEAR: return ((getDayOfYear() - 1) % 7) + 1; case DAY_OF_MONTH: return this.dayOfMonth; - case DAY_OF_YEAR: return this.dayOfYear; + case DAY_OF_YEAR: return this.getDayOfYear(); case EPOCH_DAY: return toEpochDay(); case ALIGNED_WEEK_OF_MONTH: return ((dayOfMonth - 1) / 7) + 1; - case ALIGNED_WEEK_OF_YEAR: return ((dayOfYear - 1) / 7) + 1; + case ALIGNED_WEEK_OF_YEAR: return ((getDayOfYear() - 1) / 7) + 1; case MONTH_OF_YEAR: return monthOfYear; - case YEAR_OF_ERA: return yearOfEra; - case YEAR: return yearOfEra; - case ERA: return era.getValue(); + case PROLEPTIC_MONTH: return getProlepticMonth(); + case YEAR_OF_ERA: return prolepticYear; + case YEAR: return prolepticYear; + case ERA: return getEraValue(); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } + private long getProlepticMonth() { + return prolepticYear * 12L + monthOfYear - 1; + } + @Override public HijrahDate with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; - f.checkValidValue(newValue); // TODO: validate value + // not using checkValidIntValue so EPOCH_DAY and PROLEPTIC_MONTH work + chrono.range(f).checkValidValue(newValue, f); // TODO: validate value int nvalue = (int) newValue; switch (f) { - case DAY_OF_WEEK: return plusDays(newValue - dayOfWeek.getValue()); + case DAY_OF_WEEK: return plusDays(newValue - getDayOfWeek()); case ALIGNED_DAY_OF_WEEK_IN_MONTH: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_MONTH)); case ALIGNED_DAY_OF_WEEK_IN_YEAR: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_YEAR)); - case DAY_OF_MONTH: return resolvePreviousValid(yearOfEra, monthOfYear, nvalue); - case DAY_OF_YEAR: return resolvePreviousValid(yearOfEra, ((nvalue - 1) / 30) + 1, ((nvalue - 1) % 30) + 1); - case EPOCH_DAY: return new HijrahDate(chrono, nvalue); + case DAY_OF_MONTH: return resolvePreviousValid(prolepticYear, monthOfYear, nvalue); + case DAY_OF_YEAR: return resolvePreviousValid(prolepticYear, ((nvalue - 1) / 30) + 1, ((nvalue - 1) % 30) + 1); + case EPOCH_DAY: return new HijrahDate(chrono, newValue); case ALIGNED_WEEK_OF_MONTH: return plusDays((newValue - getLong(ALIGNED_WEEK_OF_MONTH)) * 7); case ALIGNED_WEEK_OF_YEAR: return plusDays((newValue - getLong(ALIGNED_WEEK_OF_YEAR)) * 7); - case MONTH_OF_YEAR: return resolvePreviousValid(yearOfEra, nvalue, dayOfMonth); - case YEAR_OF_ERA: return resolvePreviousValid(yearOfEra >= 1 ? nvalue : 1 - nvalue, monthOfYear, dayOfMonth); + case MONTH_OF_YEAR: return resolvePreviousValid(prolepticYear, nvalue, dayOfMonth); + case PROLEPTIC_MONTH: return plusMonths(newValue - getProlepticMonth()); + case YEAR_OF_ERA: return resolvePreviousValid(prolepticYear >= 1 ? nvalue : 1 - nvalue, monthOfYear, dayOfMonth); case YEAR: return resolvePreviousValid(nvalue, monthOfYear, dayOfMonth); - case ERA: return resolvePreviousValid(1 - yearOfEra, monthOfYear, dayOfMonth); + case ERA: return resolvePreviousValid(1 - prolepticYear, monthOfYear, dayOfMonth); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } - return (HijrahDate) ChronoLocalDate.super.with(field, newValue); + return ChronoLocalDate.super.with(field, newValue); } - private HijrahDate resolvePreviousValid(int yearOfEra, int month, int day) { - int monthDays = getMonthDays(month - 1, yearOfEra); + private HijrahDate resolvePreviousValid(int prolepticYear, int month, int day) { + int monthDays = chrono.getMonthLength(prolepticYear, month); if (day > monthDays) { day = monthDays; } - return HijrahDate.of(chrono, yearOfEra, month, day); + return HijrahDate.of(chrono, prolepticYear, month, day); } /** * {@inheritDoc} - * @throws DateTimeException {@inheritDoc} + * @throws DateTimeException if unable to make the adjustment. + * For example, if the adjuster requires an ISO chronology * @throws ArithmeticException {@inheritDoc} */ @Override public HijrahDate with(TemporalAdjuster adjuster) { - return (HijrahDate)super.with(adjuster); + return super.with(adjuster); + } + + /** + * Returns a {@code HijrahDate} with the Chronology requested. + *

    + * The year, month, and day are checked against the new requested + * HijrahChronology. If the chronology has a shorter month length + * for the month, the day is reduced to be the last day of the month. + * + * @param chronology the new HijrahChonology, non-null + * @return a HijrahDate with the requested HijrahChronology, non-null + */ + public HijrahDate withVariant(HijrahChronology chronology) { + if (chrono == chronology) { + return this; + } + // Like resolvePreviousValid the day is constrained to stay in the same month + int monthDays = chronology.getDayOfYear(prolepticYear, monthOfYear); + return HijrahDate.of(chronology, prolepticYear, monthOfYear,(dayOfMonth > monthDays) ? monthDays : dayOfMonth ); } /** @@ -425,7 +453,7 @@ public final class HijrahDate */ @Override public HijrahDate plus(TemporalAmount amount) { - return (HijrahDate)super.plus(amount); + return super.plus(amount); } /** @@ -435,12 +463,42 @@ public final class HijrahDate */ @Override public HijrahDate minus(TemporalAmount amount) { - return (HijrahDate)super.minus(amount); + return super.minus(amount); } @Override public long toEpochDay() { - return chrono.getGregorianEpochDay(yearOfEra, monthOfYear, dayOfMonth); + return chrono.getEpochDay(prolepticYear, monthOfYear, dayOfMonth); + } + + /** + * Gets the day-of-year field. + *

    + * This method returns the primitive {@code int} value for the day-of-year. + * + * @return the day-of-year + */ + private int getDayOfYear() { + return chrono.getDayOfYear(prolepticYear, monthOfYear); + } + + /** + * Gets the day-of-week value. + * + * @return the day-of-week; computed from the epochday + */ + private int getDayOfWeek() { + int dow0 = (int)Math.floorMod(toEpochDay() + 3, 7); + return dow0 + 1; + } + + /** + * Gets the Era of this date. + * + * @return the Era of this date; computed from epochDay + */ + private int getEraValue() { + return (prolepticYear > 1 ? 1 : 0); } //----------------------------------------------------------------------- @@ -451,7 +509,7 @@ public final class HijrahDate */ @Override public boolean isLeapYear() { - return this.isLeapYear; + return chrono.isLeapYear(prolepticYear); } //----------------------------------------------------------------------- @@ -460,111 +518,72 @@ public final class HijrahDate if (years == 0) { return this; } - int newYear = Math.addExact(this.yearOfEra, (int)years); - return HijrahDate.of(chrono, this.era, newYear, this.monthOfYear, this.dayOfMonth); + int newYear = Math.addExact(this.prolepticYear, (int)years); + return resolvePreviousValid(newYear, monthOfYear, dayOfMonth); } @Override - HijrahDate plusMonths(long months) { - if (months == 0) { + HijrahDate plusMonths(long monthsToAdd) { + if (monthsToAdd == 0) { return this; } - int newMonth = this.monthOfYear - 1; - newMonth = newMonth + (int)months; - int years = newMonth / 12; - newMonth = newMonth % 12; - while (newMonth < 0) { - newMonth += 12; - years = Math.subtractExact(years, 1); - } - int newYear = Math.addExact(this.yearOfEra, years); - return HijrahDate.of(chrono, this.era, newYear, newMonth + 1, this.dayOfMonth); + long monthCount = prolepticYear * 12L + (monthOfYear - 1); + long calcMonths = monthCount + monthsToAdd; // safe overflow + int newYear = chrono.checkValidYear(Math.floorDiv(calcMonths, 12L)); + int newMonth = (int)Math.floorMod(calcMonths, 12L) + 1; + return resolvePreviousValid(newYear, newMonth, dayOfMonth); } @Override HijrahDate plusWeeks(long weeksToAdd) { - return (HijrahDate)super.plusWeeks(weeksToAdd); + return super.plusWeeks(weeksToAdd); } @Override HijrahDate plusDays(long days) { - return new HijrahDate(chrono, this.gregorianEpochDay + days); + return new HijrahDate(chrono, toEpochDay() + days); } @Override public HijrahDate plus(long amountToAdd, TemporalUnit unit) { - return (HijrahDate)super.plus(amountToAdd, unit); + return super.plus(amountToAdd, unit); } @Override public HijrahDate minus(long amountToSubtract, TemporalUnit unit) { - return (HijrahDate)super.minus(amountToSubtract, unit); + return super.minus(amountToSubtract, unit); } @Override HijrahDate minusYears(long yearsToSubtract) { - return (HijrahDate)super.minusYears(yearsToSubtract); + return super.minusYears(yearsToSubtract); } @Override HijrahDate minusMonths(long monthsToSubtract) { - return (HijrahDate)super.minusMonths(monthsToSubtract); + return super.minusMonths(monthsToSubtract); } @Override HijrahDate minusWeeks(long weeksToSubtract) { - return (HijrahDate)super.minusWeeks(weeksToSubtract); + return super.minusWeeks(weeksToSubtract); } @Override HijrahDate minusDays(long daysToSubtract) { - return (HijrahDate)super.minusDays(daysToSubtract); - } - - /** - * Returns month days from the beginning of year. - * - * @param month month (0-based) - * @parma year year - * @return month days from the beginning of year - */ - private int getMonthDays(int month, int year) { - int[] newMonths = chrono.getAdjustedMonthDays(year); - return newMonths[month]; - } - - /** - * Returns month length. - * - * @param month month (0-based) - * @param year year - * @return month length - */ - private int getMonthLength(int month, int year) { - int[] newMonths = chrono.getAdjustedMonthLength(year); - return newMonths[month]; - } - - @Override - public int lengthOfMonth() { - return getMonthLength(monthOfYear - 1, yearOfEra); - } - - @Override - public int lengthOfYear() { - return chrono.getYearLength(yearOfEra); // TODO: proleptic year + return super.minusDays(daysToSubtract); } @Override // for javadoc and covariant return type public final ChronoLocalDateTime atTime(LocalTime localTime) { - return (ChronoLocalDateTime)super.atTime(localTime); + return super.atTime(localTime); } @Override public Period periodUntil(ChronoLocalDate endDate) { // TODO: untested - HijrahDate end = (HijrahDate) getChronology().date(endDate); - long totalMonths = (end.yearOfEra - this.yearOfEra) * 12 + (end.monthOfYear - this.monthOfYear); // safe + HijrahDate end = getChronology().date(endDate); + long totalMonths = (end.prolepticYear - this.prolepticYear) * 12 + (end.monthOfYear - this.monthOfYear); // safe int days = end.dayOfMonth - this.dayOfMonth; if (totalMonths > 0 && days < 0) { totalMonths--; @@ -604,7 +623,7 @@ public final class HijrahDate } static ChronoLocalDate readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - HijrahChronology chrono = (HijrahChronology)in.readObject(); + HijrahChronology chrono = (HijrahChronology) in.readObject(); int year = in.readInt(); int month = in.readByte(); int dayOfMonth = in.readByte(); diff --git a/jdk/src/share/classes/java/time/chrono/HijrahDeviationReader.java b/jdk/src/share/classes/java/time/chrono/HijrahDeviationReader.java deleted file mode 100644 index 0c207af62bc..00000000000 --- a/jdk/src/share/classes/java/time/chrono/HijrahDeviationReader.java +++ /dev/null @@ -1,244 +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. 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. - */ - -/* - * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package java.time.chrono; - - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.file.FileSystems; -import java.security.AccessController; -import java.text.ParseException; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.time.temporal.ChronoField; -import java.util.Arrays; -import java.util.function.Consumer; - -/** - * A reader for Hijrah Deviation files. - *

    - * For each Hijrah calendar a deviation file is used - * to modify the initial Hijrah calendar by changing the length of - * individual months. - *

    - * The default location of the deviation files is - * {@code + FILE_SEP + "lib"}. - * The deviation files are named {@code "hijrah_" + ID}. - *

    - * The deviation file for a calendar can be overridden by defining the - * property {@code java.time.chrono.HijrahChronology.File.hijrah_} - * with the full pathname of the deviation file. - *

    - * The deviation file is read line by line: - *

      - *
    • The "#" character begins a comment - - * all characters including and after the "#" on the line are ignored
    • - *
    • Valid lines contain two fields, separated by whitespace, whitespace - * is otherwise ignored.
    • - *
    • The first field is a LocalDate using the format "MMM-dd-yyyy"; - * The LocalDate must be converted to a HijrahDate using - * the {@code islamic} calendar.
    • - *
    • The second field is the offset, +2, +1, -1, -2 as parsed - * by Integer.valueOf to modify the length of the Hijrah month.
    • - *
    • Empty lines are ignore.
    • - *
    • Exceptions are throw for invalid formatted dates and offset, - * and other I/O errors on the file. - *
    - *

    Example:

    - *
    # Deviation data for islamicc calendar
    - * Mar-23-2012 -1
    - * Apr-22-2012 +1
    - * May-21-2012 -1
    - * Dec-14-2012 +1
    - * 
    - * - * @since 1.8 - */ -final class HijrahDeviationReader { - - /** - * Default prefix for name of deviation file; suffix is typeId. - */ - private static final String DEFAULT_CONFIG_FILE_PREFIX = "hijrah_"; - - /** - * Read Hijrah_deviation.cfg file. The config file contains the deviation - * data with format defined in the class javadoc. - * - * @param typeId the name of the calendar - * @param calendarType the calendar type - * @return {@code true} if the file was read and each entry accepted by the - * Consumer; else {@code false} no configuration was done - * - * @throws IOException for zip/jar file handling exception. - * @throws ParseException if the format of the configuration file is wrong. - */ - static boolean readDeviation(String typeId, String calendarType, - Consumer consumer) throws IOException, ParseException { - InputStream is = getConfigFileInputStream(typeId); - if (is != null) { - try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) { - String line = ""; - int num = 0; - while ((line = br.readLine()) != null) { - num++; - HijrahChronology.Deviation entry = parseLine(line, num); - if (entry != null) { - consumer.accept(entry); - } - } - } - return true; - } - return false; - } - - /** - * Parse each deviation element. - * - * @param line a line to parse - * @param num line number - * @return an Entry or null if the line is empty. - * @throws ParseException if line has incorrect format. - */ - private static HijrahChronology.Deviation parseLine(final String line, final int num) throws ParseException { - int hash = line.indexOf("#"); - String nocomment = (hash < 0) ? line : line.substring(0, hash); - String[] split = nocomment.split("\\s"); - if (split.length == 0 || split[0].isEmpty()) { - return null; // Nothing to parse - } - if (split.length != 2) { - throw new ParseException("Less than 2 tokens on line : " + line + Arrays.toString(split) + ", split.length: " + split.length, num); - } - - //element [0] is a date - //element [1] is the offset - - LocalDate isoDate = DateTimeFormatter.ofPattern("MMM-dd-yyyy").parse(split[0], LocalDate::from); - int offset = Integer.valueOf(split[1]); - - // Convert date to HijrahDate using the default Islamic Calendar - - HijrahDate hijrahDate = HijrahChronology.INSTANCE.date(isoDate); - - int year = hijrahDate.get(ChronoField.YEAR); - int month = hijrahDate.get(ChronoField.MONTH_OF_YEAR); - return new HijrahChronology.Deviation(year, month, year, month, offset); - } - - - /** - * Return InputStream for deviation configuration file. The default location - * of the deviation file is: - *
    -     *   $CLASSPATH/java/time/calendar
    -     * 
    And the default file name is: - *
    -     *   hijrah_ + typeId + .cfg
    -     * 
    The default location and file name can be overridden by setting - * following two Java system properties. - *
    -     *   Location: java.time.chrono.HijrahDate.deviationConfigDir
    -     *   File name: java.time.chrono.HijrahDate.File. + typeid
    -     * 
    Regarding the file format, see readDeviationConfig() method for - * details. - * - * @param typeId the name of the calendar deviation data - * @return InputStream for file reading. - * @throws IOException for zip/jar file handling exception. - */ - private static InputStream getConfigFileInputStream(final String typeId) throws IOException { - try { - InputStream stream = AccessController - .doPrivileged((java.security.PrivilegedExceptionAction) () -> { - String propFilename = "java.time.chrono.HijrahChronology.File." + typeId; - String filename = System.getProperty(propFilename); - File file = null; - if (filename != null) { - file = new File(filename); - } else { - String libDir = System.getProperty("java.home") + File.separator + "lib"; - try { - libDir = FileSystems.getDefault().getPath(libDir).toRealPath().toString(); - } catch(Exception e) {} - filename = DEFAULT_CONFIG_FILE_PREFIX + typeId + ".cfg"; - file = new File(libDir, filename); - } - - if (file.exists()) { - try { - return new FileInputStream(file); - } catch (IOException ioe) { - throw ioe; - } - } else { - return null; - } - }); - return stream; - } catch (Exception ex) { - ex.printStackTrace(); - // Not working - return null; - } - } -} diff --git a/jdk/src/share/classes/java/time/chrono/HijrahEra.java b/jdk/src/share/classes/java/time/chrono/HijrahEra.java index 1ac2569281e..66622b567a4 100644 --- a/jdk/src/share/classes/java/time/chrono/HijrahEra.java +++ b/jdk/src/share/classes/java/time/chrono/HijrahEra.java @@ -24,6 +24,11 @@ */ /* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. @@ -56,16 +61,22 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.ERA; + import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.time.DateTimeException; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalField; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.time.temporal.ValueRange; /** * An era in the Hijrah calendar system. *

    - * The Hijrah calendar system has two eras. - * The date {@code 0001-01-01 (Hijrah)} is {@code 622-06-19 (ISO)}. + * The Hijrah calendar system has only one era covering the + * proleptic years greater than zero. *

    * Do not use {@code ordinal()} to obtain the numeric representation of {@code HijrahEra}. * Use {@code getValue()} instead. @@ -75,80 +86,76 @@ import java.time.DateTimeException; * * @since 1.8 */ -enum HijrahEra implements Era { +public enum HijrahEra implements Era { /** - * The singleton instance for the era before the current one, 'Before Anno Hegirae', - * which has the value 0. - */ - BEFORE_AH, - /** - * The singleton instance for the current era, 'Anno Hegirae', which has the value 1. + * The singleton instance for the current era, 'Anno Hegirae', + * which has the numeric value 1. */ AH; //----------------------------------------------------------------------- /** - * Obtains an instance of {@code HijrahEra} from a value. + * Obtains an instance of {@code HijrahEra} from an {@code int} value. *

    - * The current era (from ISO date 622-06-19 onwards) has the value 1 - * The previous era has the value 0. + * The current era, which is the only accepted value, has the value 1 * - * @param hijrahEra the era to represent, from 0 to 1 - * @return the HijrahEra singleton, never null - * @throws DateTimeException if the era is invalid + * @param hijrahEra the era to represent, only 1 supported + * @return the HijrahEra.AH singleton, not null + * @throws DateTimeException if the value is invalid */ public static HijrahEra of(int hijrahEra) { - switch (hijrahEra) { - case 0: - return BEFORE_AH; - case 1: - return AH; - default: - throw new DateTimeException("HijrahEra not valid"); + if (hijrahEra == 1 ) { + return AH; + } else { + throw new DateTimeException("Invalid era: " + hijrahEra); } } //----------------------------------------------------------------------- /** - * Gets the era numeric value. + * Gets the numeric era {@code int} value. *

    - * The current era (from ISO date 622-06-19 onwards) has the value 1. - * The previous era has the value 0. + * The era AH has the value 1. * - * @return the era value, from 0 (BEFORE_AH) to 1 (AH) + * @return the era value, 1 (AH) */ @Override public int getValue() { - return ordinal(); + return 1; } - @Override - public HijrahChronology getChronology() { - return HijrahChronology.INSTANCE; - } - - // JDK8 default methods: //----------------------------------------------------------------------- - @Override - public HijrahDate date(int year, int month, int day) { - return (HijrahDate)(getChronology().date(this, year, month, day)); - } - - @Override - public HijrahDate dateYearDay(int year, int dayOfYear) { - return (HijrahDate)(getChronology().dateYearDay(this, year, dayOfYear)); - } - - //------------------------------------------------------------------------- /** - * Returns the proleptic year from this era and year of era. + * Gets the range of valid values for the specified field. + *

    + * The range object expresses the minimum and maximum valid values for a field. + * This era is used to enhance the accuracy of the returned range. + * If it is not possible to return the range, because the field is not supported + * or for some other reason, an exception is thrown. + *

    + * If the field is a {@link ChronoField} then the query is implemented here. + * The {@code ERA} field returns the range. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. + *

    + * If the field is not a {@code ChronoField}, then the result of this method + * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} + * passing {@code this} as the argument. + * Whether the range can be obtained is determined by the field. + *

    + * The {@code ERA} field returns a range for the one valid Hijrah era. * - * @param yearOfEra the year of Era - * @return the computed prolepticYear + * @param field the field to query the range for, not null + * @return the range of valid values for the field, not null + * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the unit is not supported */ - int prolepticYear(int yearOfEra) { - return (this == HijrahEra.AH ? yearOfEra : 1 - yearOfEra); + @Override // override as super would return range from 0 to 1 + public ValueRange range(TemporalField field) { + if (field == ERA) { + return ValueRange.of(1, 1); + } + return Era.super.range(field); } //----------------------------------------------------------------------- diff --git a/jdk/src/share/classes/java/time/chrono/IsoChronology.java b/jdk/src/share/classes/java/time/chrono/IsoChronology.java index 883db3ee31c..3624e8d418e 100644 --- a/jdk/src/share/classes/java/time/chrono/IsoChronology.java +++ b/jdk/src/share/classes/java/time/chrono/IsoChronology.java @@ -61,20 +61,41 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR; +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.DAY_OF_WEEK; +import static java.time.temporal.ChronoField.DAY_OF_YEAR; +import static java.time.temporal.ChronoField.EPOCH_DAY; +import static java.time.temporal.ChronoField.ERA; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; +import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.TemporalAdjuster.nextOrSame; + import java.io.Serializable; import java.time.Clock; import java.time.DateTimeException; +import java.time.DayOfWeek; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.Month; +import java.time.Year; import java.time.ZoneId; import java.time.ZonedDateTime; +import java.time.format.ResolverStyle; import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; import java.time.temporal.ValueRange; import java.util.Arrays; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Objects; /** @@ -111,20 +132,6 @@ public final class IsoChronology extends Chronology implements Serializable { * Singleton instance of the ISO chronology. */ public static final IsoChronology INSTANCE = new IsoChronology(); - /** - * The singleton instance for the era BCE - 'Before Current Era'. - * The 'ISO' part of the name emphasizes that this differs from the BCE - * era in the Gregorian calendar system. - * This has the numeric value of {@code 0}. - */ - public static final Era ERA_BCE = IsoEra.BCE; - /** - * The singleton instance for the era CE - 'Current Era'. - * The 'ISO' part of the name emphasizes that this differs from the CE - * era in the Gregorian calendar system. - * This has the numeric value of {@code 1}. - */ - public static final Era ERA_CE = IsoEra.CE; /** * Serialization version. @@ -137,15 +144,6 @@ public final class IsoChronology extends Chronology implements Serializable { private IsoChronology() { } - /** - * Resolve singleton. - * - * @return the singleton instance, not null - */ - private Object readResolve() { - return INSTANCE; - } - //----------------------------------------------------------------------- /** * Gets the ID of the chronology - 'ISO'. @@ -189,6 +187,7 @@ public final class IsoChronology extends Chronology implements Serializable { * @param dayOfMonth the ISO day-of-month * @return the ISO local date, not null * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the type of {@code era} is not {@code IsoEra} */ @Override // override with covariant return type public LocalDate date(Era era, int yearOfEra, int month, int dayOfMonth) { @@ -241,6 +240,20 @@ public final class IsoChronology extends Chronology implements Serializable { return LocalDate.ofYearDay(prolepticYear, dayOfYear); } + /** + * Obtains an ISO local date from the epoch-day. + *

    + * This is equivalent to {@link LocalDate#ofEpochDay(long)}. + * + * @param epochDay the epoch day + * @return the ISO local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override // override with covariant return type + public LocalDate dateEpochDay(long epochDay) { + return LocalDate.ofEpochDay(epochDay); + } + //----------------------------------------------------------------------- /** * Obtains an ISO local date from another date-time object. @@ -379,7 +392,7 @@ public final class IsoChronology extends Chronology implements Serializable { @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof IsoEra == false) { - throw new DateTimeException("Era must be IsoEra"); + throw new ClassCastException("Era must be IsoEra"); } return (era == IsoEra.CE ? yearOfEra : 1 - yearOfEra); } @@ -394,6 +407,282 @@ public final class IsoChronology extends Chronology implements Serializable { return Arrays.asList(IsoEra.values()); } + //----------------------------------------------------------------------- + /** + * Resolves parsed {@code ChronoField} values into a date during parsing. + *

    + * Most {@code TemporalField} implementations are resolved using the + * resolve method on the field. By contrast, the {@code ChronoField} class + * defines fields that only have meaning relative to the chronology. + * As such, {@code ChronoField} date fields are resolved here in the + * context of a specific chronology. + *

    + * {@code ChronoField} instances on the ISO calendar system are resolved + * as follows. + *

      + *
    • {@code EPOCH_DAY} - If present, this is converted to a {@code LocalDate} + * all other date fields are then cross-checked against the date + *
    • {@code PROLEPTIC_MONTH} - If present, then it is split into the + * {@code YEAR} and {@code MONTH_OF_YEAR}. If the mode is strict or smart + * then the field is validated. + *
    • {@code YEAR_OF_ERA} and {@code ERA} - If both are present, then they + * are combined to form a {@code YEAR}. In lenient mode, the {@code YEAR_OF_ERA} + * range is not validated, in smart and strict mode it is. The {@code ERA} is + * validated for range in all three modes. If only the {@code YEAR_OF_ERA} is + * present, and the mode is smart or lenient, then the current era (CE/AD) + * is assumed. In strict mode, no ers is assumed and the {@code YEAR_OF_ERA} is + * left untouched. If only the {@code ERA} is present, then it is left untouched. + *
    • {@code YEAR}, {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} - + * If all three are present, then they are combined to form a {@code LocalDate}. + * In all three modes, the {@code YEAR} is validated. If the mode is smart or strict, + * then the month and day are validated, with the day validated from 1 to 31. + * If the mode is lenient, then the date is combined in a manner equivalent to + * creating a date on the first of January in the requested year, then adding + * the difference in months, then the difference in days. + * If the mode is smart, and the day-of-month is greater than the maximum for + * the year-month, then the day-of-month is adjusted to the last day-of-month. + * If the mode is strict, then the three fields must form a valid date. + *
    • {@code YEAR} and {@code DAY_OF_YEAR} - + * If both are present, then they are combined to form a {@code LocalDate}. + * In all three modes, the {@code YEAR} is validated. + * If the mode is lenient, then the date is combined in a manner equivalent to + * creating a date on the first of January in the requested year, then adding + * the difference in days. + * If the mode is smart or strict, then the two fields must form a valid date. + *
    • {@code YEAR}, {@code MONTH_OF_YEAR}, {@code ALIGNED_WEEK_OF_MONTH} and + * {@code ALIGNED_DAY_OF_WEEK_IN_MONTH} - + * If all four are present, then they are combined to form a {@code LocalDate}. + * In all three modes, the {@code YEAR} is validated. + * If the mode is lenient, then the date is combined in a manner equivalent to + * creating a date on the first of January in the requested year, then adding + * the difference in months, then the difference in weeks, then in days. + * If the mode is smart or strict, then the all four fields are validated to + * their outer ranges. The date is then combined in a manner equivalent to + * creating a date on the first day of the requested year and month, then adding + * the amount in weeks and days to reach their values. If the mode is strict, + * the date is additionally validated to check that the day and week adjustment + * did not change the month. + *
    • {@code YEAR}, {@code MONTH_OF_YEAR}, {@code ALIGNED_WEEK_OF_MONTH} and + * {@code DAY_OF_WEEK} - If all four are present, then they are combined to + * form a {@code LocalDate}. The approach is the same as described above for + * years, months and weeks in {@code ALIGNED_DAY_OF_WEEK_IN_MONTH}. + * The day-of-week is adjusted as the next or same matching day-of-week once + * the years, months and weeks have been handled. + *
    • {@code YEAR}, {@code ALIGNED_WEEK_OF_YEAR} and {@code ALIGNED_DAY_OF_WEEK_IN_YEAR} - + * If all three are present, then they are combined to form a {@code LocalDate}. + * In all three modes, the {@code YEAR} is validated. + * If the mode is lenient, then the date is combined in a manner equivalent to + * creating a date on the first of January in the requested year, then adding + * the difference in weeks, then in days. + * If the mode is smart or strict, then the all three fields are validated to + * their outer ranges. The date is then combined in a manner equivalent to + * creating a date on the first day of the requested year, then adding + * the amount in weeks and days to reach their values. If the mode is strict, + * the date is additionally validated to check that the day and week adjustment + * did not change the year. + *
    • {@code YEAR}, {@code ALIGNED_WEEK_OF_YEAR} and {@code DAY_OF_WEEK} - + * If all three are present, then they are combined to form a {@code LocalDate}. + * The approach is the same as described above for years and weeks in + * {@code ALIGNED_DAY_OF_WEEK_IN_YEAR}. The day-of-week is adjusted as the + * next or same matching day-of-week once the years and weeks have been handled. + *
    + * + * @param fieldValues the map of fields to values, which can be updated, not null + * @param resolverStyle the requested type of resolve, not null + * @return the resolved date, null if insufficient information to create a date + * @throws DateTimeException if the date cannot be resolved, typically + * because of a conflict in the input data + */ + @Override // override for performance + public LocalDate resolveDate(Map fieldValues, ResolverStyle resolverStyle) { + // check epoch-day before inventing era + if (fieldValues.containsKey(EPOCH_DAY)) { + return LocalDate.ofEpochDay(fieldValues.remove(EPOCH_DAY)); + } + + // fix proleptic month before inventing era + resolveProlepticMonth(fieldValues, resolverStyle); + + // invent era if necessary to resolve year-of-era + resolveYearOfEra(fieldValues, resolverStyle); + + // build date + if (fieldValues.containsKey(YEAR)) { + if (fieldValues.containsKey(MONTH_OF_YEAR)) { + if (fieldValues.containsKey(DAY_OF_MONTH)) { + return resolveYMD(fieldValues, resolverStyle); + } + if (fieldValues.containsKey(ALIGNED_WEEK_OF_MONTH)) { + if (fieldValues.containsKey(ALIGNED_DAY_OF_WEEK_IN_MONTH)) { + return resolveYMAA(fieldValues, resolverStyle); + } + if (fieldValues.containsKey(DAY_OF_WEEK)) { + return resolveYMAD(fieldValues, resolverStyle); + } + } + } + if (fieldValues.containsKey(DAY_OF_YEAR)) { + return resolveYD(fieldValues, resolverStyle); + } + if (fieldValues.containsKey(ALIGNED_WEEK_OF_YEAR)) { + if (fieldValues.containsKey(ALIGNED_DAY_OF_WEEK_IN_YEAR)) { + return resolveYAA(fieldValues, resolverStyle); + } + if (fieldValues.containsKey(DAY_OF_WEEK)) { + return resolveYAD(fieldValues, resolverStyle); + } + } + } + return null; + } + + private void resolveProlepticMonth(Map fieldValues, ResolverStyle resolverStyle) { + Long pMonth = fieldValues.remove(PROLEPTIC_MONTH); + if (pMonth != null) { + if (resolverStyle != ResolverStyle.LENIENT) { + PROLEPTIC_MONTH.checkValidValue(pMonth); + } + addFieldValue(fieldValues, MONTH_OF_YEAR, Math.floorMod(pMonth, 12) + 1); + addFieldValue(fieldValues, YEAR, Math.floorDiv(pMonth, 12)); + } + } + + private void resolveYearOfEra(Map fieldValues, ResolverStyle resolverStyle) { + Long yoeLong = fieldValues.remove(YEAR_OF_ERA); + if (yoeLong != null) { + if (resolverStyle != ResolverStyle.LENIENT) { + YEAR_OF_ERA.checkValidValue(yoeLong); + } + Long era = fieldValues.remove(ERA); + if (era == null) { + Long year = fieldValues.get(YEAR); + if (resolverStyle == ResolverStyle.STRICT) { + // do not invent era if strict, but do cross-check with year + if (year != null) { + addFieldValue(fieldValues, YEAR, (year > 0 ? yoeLong: Math.subtractExact(1, yoeLong))); + } else { + // reinstate the field removed earlier, no cross-check issues + fieldValues.put(YEAR_OF_ERA, yoeLong); + } + } else { + // invent era + addFieldValue(fieldValues, YEAR, (year == null || year > 0 ? yoeLong: Math.subtractExact(1, yoeLong))); + } + } else if (era.longValue() == 1L) { + addFieldValue(fieldValues, YEAR, yoeLong); + } else if (era.longValue() == 0L) { + addFieldValue(fieldValues, YEAR, Math.subtractExact(1, yoeLong)); + } else { + throw new DateTimeException("Invalid value for era: " + era); + } + } + } + + private LocalDate resolveYMD(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long months = Math.subtractExact(fieldValues.remove(MONTH_OF_YEAR), 1); + long days = Math.subtractExact(fieldValues.remove(DAY_OF_MONTH), 1); + return LocalDate.of(y, 1, 1).plusMonths(months).plusDays(days); + } + int moy = MONTH_OF_YEAR.checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR)); + int dom = DAY_OF_MONTH.checkValidIntValue(fieldValues.remove(DAY_OF_MONTH)); + if (resolverStyle == ResolverStyle.SMART) { // previous valid + dom = Math.min(dom, Month.of(moy).length(Year.isLeap(y))); + } + return LocalDate.of(y, moy, dom); + } + + private LocalDate resolveYD(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long days = Math.subtractExact(fieldValues.remove(DAY_OF_YEAR), 1); + return LocalDate.of(y, 1, 1).plusDays(days); + } + int doy = DAY_OF_YEAR.checkValidIntValue(fieldValues.remove(DAY_OF_YEAR)); + return LocalDate.ofYearDay(y, doy); // smart is same as strict + } + + private LocalDate resolveYMAA(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long months = Math.subtractExact(fieldValues.remove(MONTH_OF_YEAR), 1); + long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1); + long days = Math.subtractExact(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH), 1); + return LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks).plusDays(days); + } + int moy = MONTH_OF_YEAR.checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR)); + int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); + int ad = ALIGNED_DAY_OF_WEEK_IN_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH)); + LocalDate date = LocalDate.of(y, moy, 1).plusDays((aw - 1) * 7 + (ad - 1)); + if (resolverStyle == ResolverStyle.STRICT && date.getMonthValue() != moy) { + throw new DateTimeException("Strict mode rejected resolved date as it is in a different month"); + } + return date; + } + + private LocalDate resolveYMAD(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long months = Math.subtractExact(fieldValues.remove(MONTH_OF_YEAR), 1); + long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1); + long dow = Math.subtractExact(fieldValues.remove(DAY_OF_WEEK), 1); + return resolveAligned(y, months, weeks, dow); + } + int moy = MONTH_OF_YEAR.checkValidIntValue(fieldValues.remove(MONTH_OF_YEAR)); + int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); + int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); + LocalDate date = LocalDate.of(y, moy, 1).plusDays((aw - 1) * 7).with(nextOrSame(DayOfWeek.of(dow))); + if (resolverStyle == ResolverStyle.STRICT && date.getMonthValue() != moy) { + throw new DateTimeException("Strict mode rejected resolved date as it is in a different month"); + } + return date; + } + + private LocalDate resolveYAA(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1); + long days = Math.subtractExact(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR), 1); + return LocalDate.of(y, 1, 1).plusWeeks(weeks).plusDays(days); + } + int aw = ALIGNED_WEEK_OF_YEAR.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR)); + int ad = ALIGNED_DAY_OF_WEEK_IN_YEAR.checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR)); + LocalDate date = LocalDate.of(y, 1, 1).plusDays((aw - 1) * 7 + (ad - 1)); + if (resolverStyle == ResolverStyle.STRICT && date.getYear() != y) { + throw new DateTimeException("Strict mode rejected resolved date as it is in a different year"); + } + return date; + } + + private LocalDate resolveYAD(Map fieldValues, ResolverStyle resolverStyle) { + int y = YEAR.checkValidIntValue(fieldValues.remove(YEAR)); + if (resolverStyle == ResolverStyle.LENIENT) { + long weeks = Math.subtractExact(fieldValues.remove(ALIGNED_WEEK_OF_YEAR), 1); + long dow = Math.subtractExact(fieldValues.remove(DAY_OF_WEEK), 1); + return resolveAligned(y, 0, weeks, dow); + } + int aw = ALIGNED_WEEK_OF_YEAR.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_YEAR)); + int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); + LocalDate date = LocalDate.of(y, 1, 1).plusDays((aw - 1) * 7).with(nextOrSame(DayOfWeek.of(dow))); + if (resolverStyle == ResolverStyle.STRICT && date.getYear() != y) { + throw new DateTimeException("Strict mode rejected resolved date as it is in a different year"); + } + return date; + } + + private LocalDate resolveAligned(int y, long months, long weeks, long dow) { + LocalDate date = LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks); + if (dow > 7) { + date = date.plusWeeks((dow - 1) / 7); + dow = ((dow - 1) % 7) + 1; + } else if (dow < 1) { + date = date.plusWeeks(Math.subtractExact(dow, 7) / 7); + dow = ((dow + 6) % 7) + 1; + } + return date.with(nextOrSame(DayOfWeek.of((int) dow))); + } + //----------------------------------------------------------------------- @Override public ValueRange range(ChronoField field) { diff --git a/jdk/src/share/classes/java/time/chrono/IsoEra.java b/jdk/src/share/classes/java/time/chrono/IsoEra.java index 8a81067bdc8..445aa45478e 100644 --- a/jdk/src/share/classes/java/time/chrono/IsoEra.java +++ b/jdk/src/share/classes/java/time/chrono/IsoEra.java @@ -61,16 +61,38 @@ */ package java.time.chrono; - import java.time.DateTimeException; -import java.time.LocalDate; /** * An era in the ISO calendar system. *

    * The ISO-8601 standard does not define eras. * A definition has therefore been created with two eras - 'Current era' (CE) for - * years from 0001-01-01 (ISO) and 'Before current era' (BCE) for years before that. + * years on or after 0001-01-01 (ISO), and 'Before current era' (BCE) for years before that. + *

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    year-of-eraeraproleptic-year
    2CE2
    1CE1
    1BCE0
    2BCE-1
    *

    * Do not use {@code ordinal()} to obtain the numeric representation of {@code IsoEra}. * Use {@code getValue()} instead. @@ -80,20 +102,16 @@ import java.time.LocalDate; * * @since 1.8 */ -enum IsoEra implements Era { +public enum IsoEra implements Era { /** - * The singleton instance for the era BCE, 'Before Current Era'. - * The 'ISO' part of the name emphasizes that this differs from the BCE - * era in the Gregorian calendar system. - * This has the numeric value of {@code 0}. + * The singleton instance for the era before the current one, 'Before Current Era', + * which has the numeric value 0. */ BCE, /** - * The singleton instance for the era CE, 'Current Era'. - * The 'ISO' part of the name emphasizes that this differs from the CE - * era in the Gregorian calendar system. - * This has the numeric value of {@code 1}. + * The singleton instance for the current era, 'Current Era', + * which has the numeric value 1. */ CE; @@ -104,18 +122,18 @@ enum IsoEra implements Era { * {@code IsoEra} is an enum representing the ISO eras of BCE/CE. * This factory allows the enum to be obtained from the {@code int} value. * - * @param era the BCE/CE value to represent, from 0 (BCE) to 1 (CE) + * @param isoEra the BCE/CE value to represent, from 0 (BCE) to 1 (CE) * @return the era singleton, not null * @throws DateTimeException if the value is invalid */ - public static IsoEra of(int era) { - switch (era) { + public static IsoEra of(int isoEra) { + switch (isoEra) { case 0: return BCE; case 1: return CE; default: - throw new DateTimeException("Invalid era: " + era); + throw new DateTimeException("Invalid era: " + isoEra); } } @@ -132,21 +150,4 @@ enum IsoEra implements Era { return ordinal(); } - @Override - public IsoChronology getChronology() { - return IsoChronology.INSTANCE; - } - - // JDK8 default methods: - //----------------------------------------------------------------------- - @Override - public LocalDate date(int year, int month, int day) { - return getChronology().date(this, year, month, day); - } - - @Override - public LocalDate dateYearDay(int year, int dayOfYear) { - return getChronology().dateYearDay(this, year, dayOfYear); - } - } diff --git a/jdk/src/share/classes/java/time/chrono/JapaneseChronology.java b/jdk/src/share/classes/java/time/chrono/JapaneseChronology.java index bb16d891476..1d07a36929d 100644 --- a/jdk/src/share/classes/java/time/chrono/JapaneseChronology.java +++ b/jdk/src/share/classes/java/time/chrono/JapaneseChronology.java @@ -61,11 +61,11 @@ import java.time.Clock; import java.time.DateTimeException; import java.time.Instant; import java.time.LocalDate; +import java.time.Year; +import java.time.ZoneId; import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; import java.time.temporal.ValueRange; -import java.time.Year; -import java.time.ZoneId; import java.util.Arrays; import java.util.Calendar; import java.util.List; @@ -104,31 +104,6 @@ public final class JapaneseChronology extends Chronology implements Serializable */ public static final JapaneseChronology INSTANCE = new JapaneseChronology(); - /** - * The singleton instance for the before Meiji era ( - 1868-09-07) - * which has the value -999. - */ - public static final Era ERA_SEIREKI = JapaneseEra.SEIREKI; - /** - * The singleton instance for the Meiji era (1868-09-08 - 1912-07-29) - * which has the value -1. - */ - public static final Era ERA_MEIJI = JapaneseEra.MEIJI; - /** - * The singleton instance for the Taisho era (1912-07-30 - 1926-12-24) - * which has the value 0. - */ - public static final Era ERA_TAISHO = JapaneseEra.TAISHO; - /** - * The singleton instance for the Showa era (1926-12-25 - 1989-01-07) - * which has the value 1. - */ - public static final Era ERA_SHOWA = JapaneseEra.SHOWA; - /** - * The singleton instance for the Heisei era (1989-01-08 - current) - * which has the value 2. - */ - public static final Era ERA_HEISEI = JapaneseEra.HEISEI; /** * Serialization version. */ @@ -141,15 +116,6 @@ public final class JapaneseChronology extends Chronology implements Serializable private JapaneseChronology() { } - /** - * Resolve singleton. - * - * @return the singleton instance, not null - */ - private Object readResolve() { - return INSTANCE; - } - //----------------------------------------------------------------------- /** * Gets the ID of the chronology - 'Japanese'. @@ -183,36 +149,82 @@ public final class JapaneseChronology extends Chronology implements Serializable } //----------------------------------------------------------------------- + /** + * Obtains a local date in Japanese calendar system from the + * era, year-of-era, month-of-year and day-of-month fields. + * + * @param era the Japanese era, not null + * @param yearOfEra the year-of-era + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Japanese local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code JapaneseEra} + */ @Override public JapaneseDate date(Era era, int yearOfEra, int month, int dayOfMonth) { if (era instanceof JapaneseEra == false) { - throw new DateTimeException("Era must be JapaneseEra"); + throw new ClassCastException("Era must be JapaneseEra"); } return JapaneseDate.of((JapaneseEra) era, yearOfEra, month, dayOfMonth); } + /** + * Obtains a local date in Japanese calendar system from the + * proleptic-year, month-of-year and day-of-month fields. + * + * @param prolepticYear the proleptic-year + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Japanese local date, not null + * @throws DateTimeException if unable to create the date + */ @Override public JapaneseDate date(int prolepticYear, int month, int dayOfMonth) { return new JapaneseDate(LocalDate.of(prolepticYear, month, dayOfMonth)); } + /** + * Obtains a local date in Japanese calendar system from the + * era, year-of-era and day-of-year fields. + * + * @param era the Japanese era, not null + * @param yearOfEra the year-of-era + * @param dayOfYear the day-of-year + * @return the Japanese local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code JapaneseEra} + */ + @Override + public JapaneseDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { + return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + } + + /** + * Obtains a local date in Japanese calendar system from the + * proleptic-year and day-of-year fields. + * + * @param prolepticYear the proleptic-year + * @param dayOfYear the day-of-year + * @return the Japanese local date, not null + * @throws DateTimeException if unable to create the date + */ @Override public JapaneseDate dateYearDay(int prolepticYear, int dayOfYear) { LocalDate date = LocalDate.ofYearDay(prolepticYear, dayOfYear); return date(prolepticYear, date.getMonthValue(), date.getDayOfMonth()); } - @Override - public JapaneseDate date(TemporalAccessor temporal) { - if (temporal instanceof JapaneseDate) { - return (JapaneseDate) temporal; - } - return new JapaneseDate(LocalDate.from(temporal)); - } - - @Override - public JapaneseDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { - return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + /** + * Obtains a local date in the Japanese calendar system from the epoch-day. + * + * @param epochDay the epoch day + * @return the Japanese local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override // override with covariant return type + public JapaneseDate dateEpochDay(long epochDay) { + return new JapaneseDate(LocalDate.ofEpochDay(epochDay)); } @Override @@ -230,6 +242,14 @@ public final class JapaneseChronology extends Chronology implements Serializable return date(LocalDate.now(clock)); } + @Override + public JapaneseDate date(TemporalAccessor temporal) { + if (temporal instanceof JapaneseDate) { + return (JapaneseDate) temporal; + } + return new JapaneseDate(LocalDate.from(temporal)); + } + @Override public ChronoLocalDateTime localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime)super.localDateTime(temporal); @@ -264,7 +284,7 @@ public final class JapaneseChronology extends Chronology implements Serializable @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof JapaneseEra == false) { - throw new DateTimeException("Era must be JapaneseEra"); + throw new ClassCastException("Era must be JapaneseEra"); } JapaneseEra jera = (JapaneseEra) era; int gregorianYear = jera.getPrivateEra().getSinceDate().getYear() + yearOfEra - 1; @@ -273,20 +293,23 @@ public final class JapaneseChronology extends Chronology implements Serializable } LocalGregorianCalendar.Date jdate = JCAL.newCalendarDate(null); jdate.setEra(jera.getPrivateEra()).setDate(yearOfEra, 1, 1); + if (!JapaneseChronology.JCAL.validate(jdate)) { + throw new DateTimeException("Invalid yearOfEra value"); + } JCAL.normalize(jdate); if (jdate.getNormalizedYear() == gregorianYear) { return gregorianYear; } - throw new DateTimeException("invalid yearOfEra value"); + throw new DateTimeException("Invalid yearOfEra value"); } /** * Returns the calendar system era object from the given numeric value. * * See the description of each Era for the numeric values of: - * {@link #ERA_HEISEI}, {@link #ERA_SHOWA},{@link #ERA_TAISHO}, - * {@link #ERA_MEIJI}), only Meiji and later eras are supported. - * Prior to Meiji {@link #ERA_SEIREKI} is used. + * {@link JapaneseEra#HEISEI}, {@link JapaneseEra#SHOWA},{@link JapaneseEra#TAISHO}, + * {@link JapaneseEra#MEIJI}), only Meiji and later eras are supported. + * Prior to Meiji {@link JapaneseEra#SEIREKI} is used. * * @param eraValue the era value * @return the Japanese {@code Era} for the given numeric era value @@ -299,7 +322,7 @@ public final class JapaneseChronology extends Chronology implements Serializable @Override public List eras() { - return Arrays.asList(JapaneseEra.values()); + return Arrays.asList(JapaneseEra.values()); } //----------------------------------------------------------------------- @@ -322,20 +345,24 @@ public final class JapaneseChronology extends Chronology implements Serializable case NANO_OF_SECOND: case CLOCK_HOUR_OF_DAY: case CLOCK_HOUR_OF_AMPM: - case EPOCH_DAY: - case EPOCH_MONTH: + case EPOCH_DAY: // TODO: if year is restricted, then so is epoch-day return field.range(); } Calendar jcal = Calendar.getInstance(LOCALE); int fieldIndex; switch (field) { case ERA: - return ValueRange.of(jcal.getMinimum(Calendar.ERA) - JapaneseEra.ERA_OFFSET, + return ValueRange.of(JapaneseEra.SEIREKI.getValue(), jcal.getMaximum(Calendar.ERA) - JapaneseEra.ERA_OFFSET); case YEAR: case YEAR_OF_ERA: + // TODO: this is not right return ValueRange.of(Year.MIN_VALUE, jcal.getGreatestMinimum(Calendar.YEAR), jcal.getLeastMaximum(Calendar.YEAR), Year.MAX_VALUE); + case PROLEPTIC_MONTH: + // TODO: should be the range of months bound by the valid range of years + return ValueRange.of((jcal.getGreatestMinimum(Calendar.YEAR) - 1) * 12, + (jcal.getLeastMaximum(Calendar.YEAR)) * 12); case MONTH_OF_YEAR: return ValueRange.of(jcal.getMinimum(Calendar.MONTH) + 1, jcal.getGreatestMinimum(Calendar.MONTH) + 1, jcal.getLeastMaximum(Calendar.MONTH) + 1, jcal.getMaximum(Calendar.MONTH) + 1); diff --git a/jdk/src/share/classes/java/time/chrono/JapaneseDate.java b/jdk/src/share/classes/java/time/chrono/JapaneseDate.java index 75cd0a5aa74..7ba7fd37401 100644 --- a/jdk/src/share/classes/java/time/chrono/JapaneseDate.java +++ b/jdk/src/share/classes/java/time/chrono/JapaneseDate.java @@ -69,14 +69,16 @@ import java.time.DateTimeException; import java.time.LocalDate; import java.time.LocalTime; import java.time.Period; +import java.time.Year; import java.time.ZoneId; import java.time.temporal.ChronoField; -import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Calendar; import java.util.Objects; @@ -191,7 +193,7 @@ public final class JapaneseDate */ public static JapaneseDate of(Era era, int yearOfEra, int month, int dayOfMonth) { if (era instanceof JapaneseEra == false) { - throw new DateTimeException("Era must be JapaneseEra"); + throw new ClassCastException("Era must be JapaneseEra"); } return JapaneseDate.of((JapaneseEra) era, yearOfEra, month, dayOfMonth); } @@ -252,7 +254,7 @@ public final class JapaneseDate LocalGregorianCalendar.Date jdate = JapaneseChronology.JCAL.newCalendarDate(null); jdate.setEra(era.getPrivateEra()).setDate(yearOfEra, month, dayOfMonth); if (!JapaneseChronology.JCAL.validate(jdate)) { - throw new IllegalArgumentException(); + throw new DateTimeException("year, month, and day not valid for Era"); } LocalDate date = LocalDate.of(jdate.getNormalizedYear(), month, dayOfMonth); return new JapaneseDate(era, yearOfEra, date); @@ -307,22 +309,54 @@ public final class JapaneseDate } //----------------------------------------------------------------------- + /** + * Gets the chronology of this date, which is the Japanese calendar system. + *

    + * The {@code Chronology} represents the calendar system in use. + * The era and other fields in {@link ChronoField} are defined by the chronology. + * + * @return the Japanese chronology, not null + */ @Override public JapaneseChronology getChronology() { return JapaneseChronology.INSTANCE; } + /** + * Gets the era applicable at this date. + *

    + * The Japanese calendar system has multiple eras defined by {@link JapaneseEra}. + * + * @return the era applicable at this date, not null + */ + @Override + public JapaneseEra getEra() { + return era; + } + + /** + * Returns the length of the month represented by this date. + *

    + * This returns the length of the month in days. + * Month lengths match those of the ISO calendar system. + * + * @return the length of the month in days + */ @Override public int lengthOfMonth() { return isoDate.lengthOfMonth(); } + //----------------------------------------------------------------------- @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { if (isSupported(field)) { ChronoField f = (ChronoField) field; switch (f) { + case DAY_OF_MONTH: + case ALIGNED_WEEK_OF_MONTH: + return isoDate.range(field); case DAY_OF_YEAR: return actualRange(Calendar.DAY_OF_YEAR); case YEAR_OF_ERA: @@ -330,14 +364,14 @@ public final class JapaneseDate } return getChronology().range(f); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } private ValueRange actualRange(int calendarField) { Calendar jcal = Calendar.getInstance(JapaneseChronology.LOCALE); - jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); + jcal.set(Calendar.ERA, era.getValue() + JapaneseEra.ERA_OFFSET); // TODO: cannot calculate this way for SEIREKI jcal.set(yearOfEra, isoDate.getMonthValue() - 1, isoDate.getDayOfMonth()); return ValueRange.of(jcal.getActualMinimum(calendarField), jcal.getActualMaximum(calendarField)); @@ -346,6 +380,12 @@ public final class JapaneseDate @Override public long getLong(TemporalField field) { if (field instanceof ChronoField) { + // same as ISO: + // DAY_OF_WEEK, ALIGNED_DAY_OF_WEEK_IN_MONTH, DAY_OF_MONTH, EPOCH_DAY, + // ALIGNED_WEEK_OF_MONTH, MONTH_OF_YEAR, PROLEPTIC_MONTH, YEAR + // + // calendar specific fields + // ALIGNED_DAY_OF_WEEK_IN_YEAR, DAY_OF_YEAR, ALIGNED_WEEK_OF_YEAR, YEAR_OF_ERA, ERA switch ((ChronoField) field) { case YEAR_OF_ERA: return yearOfEra; @@ -355,8 +395,8 @@ public final class JapaneseDate LocalGregorianCalendar.Date jdate = toPrivateJapaneseDate(isoDate); return JapaneseChronology.JCAL.getDayOfYear(jdate); } + // TODO: ALIGNED_DAY_OF_WEEK_IN_YEAR and ALIGNED_WEEK_OF_YEAR ??? } - // TODO: review other fields return isoDate.getLong(field); } return field.getFrom(this); @@ -392,8 +432,7 @@ public final class JapaneseDate case YEAR_OF_ERA: case YEAR: case ERA: { - f.checkValidValue(newValue); - int nvalue = (int) newValue; + int nvalue = getChronology().range(f).checkValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return this.withYear(nvalue); @@ -405,15 +444,11 @@ public final class JapaneseDate } } } + // YEAR, PROLEPTIC_MONTH and others are same as ISO // TODO: review other fields, such as WEEK_OF_YEAR return with(isoDate.with(field, newValue)); } - return (JapaneseDate) ChronoLocalDate.super.with(field, newValue); - } - - @Override - public Era getEra() { - return era; + return ChronoLocalDate.super.with(field, newValue); } /** @@ -423,7 +458,7 @@ public final class JapaneseDate */ @Override public JapaneseDate with(TemporalAdjuster adjuster) { - return (JapaneseDate)super.with(adjuster); + return super.with(adjuster); } /** @@ -433,7 +468,7 @@ public final class JapaneseDate */ @Override public JapaneseDate plus(TemporalAmount amount) { - return (JapaneseDate)super.plus(amount); + return super.plus(amount); } /** @@ -443,7 +478,7 @@ public final class JapaneseDate */ @Override public JapaneseDate minus(TemporalAmount amount) { - return (JapaneseDate)super.minus(amount); + return super.minus(amount); } //----------------------------------------------------------------------- /** @@ -479,7 +514,7 @@ public final class JapaneseDate * @throws DateTimeException if {@code year} is invalid */ private JapaneseDate withYear(int year) { - return withYear((JapaneseEra) getEra(), year); + return withYear(getEra(), year); } //----------------------------------------------------------------------- @@ -505,32 +540,32 @@ public final class JapaneseDate @Override public JapaneseDate plus(long amountToAdd, TemporalUnit unit) { - return (JapaneseDate)super.plus(amountToAdd, unit); + return super.plus(amountToAdd, unit); } @Override public JapaneseDate minus(long amountToAdd, TemporalUnit unit) { - return (JapaneseDate)super.minus(amountToAdd, unit); + return super.minus(amountToAdd, unit); } @Override JapaneseDate minusYears(long yearsToSubtract) { - return (JapaneseDate)super.minusYears(yearsToSubtract); + return super.minusYears(yearsToSubtract); } @Override JapaneseDate minusMonths(long monthsToSubtract) { - return (JapaneseDate)super.minusMonths(monthsToSubtract); + return super.minusMonths(monthsToSubtract); } @Override JapaneseDate minusWeeks(long weeksToSubtract) { - return (JapaneseDate)super.minusWeeks(weeksToSubtract); + return super.minusWeeks(weeksToSubtract); } @Override JapaneseDate minusDays(long daysToSubtract) { - return (JapaneseDate)super.minusDays(daysToSubtract); + return super.minusDays(daysToSubtract); } private JapaneseDate with(LocalDate newDate) { @@ -539,7 +574,7 @@ public final class JapaneseDate @Override // for javadoc and covariant return type public final ChronoLocalDateTime atTime(LocalTime localTime) { - return (ChronoLocalDateTime)super.atTime(localTime); + return super.atTime(localTime); } @Override diff --git a/jdk/src/share/classes/java/time/chrono/JapaneseEra.java b/jdk/src/share/classes/java/time/chrono/JapaneseEra.java index 675f0d664ea..f89de19a271 100644 --- a/jdk/src/share/classes/java/time/chrono/JapaneseEra.java +++ b/jdk/src/share/classes/java/time/chrono/JapaneseEra.java @@ -24,6 +24,11 @@ */ /* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. @@ -56,6 +61,8 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.ERA; + import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; @@ -64,7 +71,12 @@ import java.io.ObjectStreamException; import java.io.Serializable; import java.time.DateTimeException; import java.time.LocalDate; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalField; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.time.temporal.ValueRange; import java.util.Arrays; +import java.util.Objects; import sun.util.calendar.CalendarDate; @@ -84,7 +96,7 @@ import sun.util.calendar.CalendarDate; * * @since 1.8 */ -final class JapaneseEra +public final class JapaneseEra implements Era, Serializable { // The offset value to 0-based index from the era value. @@ -202,7 +214,7 @@ final class JapaneseEra //----------------------------------------------------------------------- /** - * Obtains an instance of {@code JapaneseEra} from a value. + * Obtains an instance of {@code JapaneseEra} from an {@code int} value. *

    * The {@link #SHOWA} era that contains 1970-01-01 (ISO calendar system) has the value 1 * Later era is numbered 2 ({@link #HEISEI}). Earlier eras are numbered 0 ({@link #TAISHO}), @@ -210,22 +222,49 @@ final class JapaneseEra * {@link #SEIREKI} is used. * * @param japaneseEra the era to represent - * @return the {@code JapaneseEra} singleton, never null - * @throws DateTimeException if {@code japaneseEra} is invalid + * @return the {@code JapaneseEra} singleton, not null + * @throws DateTimeException if the value is invalid */ public static JapaneseEra of(int japaneseEra) { if (japaneseEra != SEIREKI.eraValue && (japaneseEra < MEIJI.eraValue || japaneseEra > HEISEI.eraValue)) { - throw new DateTimeException("japaneseEra is invalid"); + throw new DateTimeException("Invalid era: " + japaneseEra); } return KNOWN_ERAS[ordinal(japaneseEra)]; } + /** + * Returns the {@code JapaneseEra} with the name. + *

    + * The string must match exactly the name of the era. + * (Extraneous whitespace characters are not permitted.) + * + * @param japaneseEra the japaneseEra name; non-null + * @return the {@code JapaneseEra} singleton, never null + * @throws IllegalArgumentException if there is not JapaneseEra with the specified name + */ + public static JapaneseEra valueOf(String japaneseEra) { + Objects.requireNonNull(japaneseEra, "japaneseEra"); + for (JapaneseEra era : KNOWN_ERAS) { + if (era.getName().equals(japaneseEra)) { + return era; + } + } + throw new IllegalArgumentException("japaneseEra is invalid"); + } + /** * Returns an array of JapaneseEras. + *

    + * This method may be used to iterate over the JapaneseEras as follows: + *

    +     * for (JapaneseEra c : JapaneseEra.values())
    +     *     System.out.println(c);
    +     * 
    + * * @return an array of JapaneseEras */ - static JapaneseEra[] values() { + public static JapaneseEra[] values() { return Arrays.copyOf(KNOWN_ERAS, KNOWN_ERAS.length); } @@ -268,16 +307,17 @@ final class JapaneseEra /** * Returns the index into the arrays from the Era value. * the eraValue is a valid Era number, -999, -1..2. - * @param eravalue the era value to convert to the index + * + * @param eraValue the era value to convert to the index * @return the index of the current Era */ - private static int ordinal(int eravalue) { - return (eravalue == SEIREKI.eraValue) ? 0 : eravalue + ERA_OFFSET; + private static int ordinal(int eraValue) { + return (eraValue == SEIREKI.eraValue) ? 0 : eraValue + ERA_OFFSET; } //----------------------------------------------------------------------- /** - * Returns the numeric value of this {@code JapaneseEra}. + * Gets the numeric era {@code int} value. *

    * The {@link #SHOWA} era that contains 1970-01-01 (ISO calendar system) has the value 1. * Later eras are numbered from 2 ({@link #HEISEI}). @@ -290,9 +330,38 @@ final class JapaneseEra return eraValue; } - @Override - public JapaneseChronology getChronology() { - return JapaneseChronology.INSTANCE; + //----------------------------------------------------------------------- + /** + * Gets the range of valid values for the specified field. + *

    + * The range object expresses the minimum and maximum valid values for a field. + * This era is used to enhance the accuracy of the returned range. + * If it is not possible to return the range, because the field is not supported + * or for some other reason, an exception is thrown. + *

    + * If the field is a {@link ChronoField} then the query is implemented here. + * The {@code ERA} field returns the range. + * All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. + *

    + * If the field is not a {@code ChronoField}, then the result of this method + * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} + * passing {@code this} as the argument. + * Whether the range can be obtained is determined by the field. + *

    + * The range of valid Japanese eras can change over time due to the nature + * of the Japanese calendar system. + * + * @param field the field to query the range for, not null + * @return the range of valid values for the field, not null + * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the unit is not supported + */ + @Override // override as super would return range from 0 to 1 + public ValueRange range(TemporalField field) { + if (field == ERA) { + return JapaneseChronology.INSTANCE.range(ERA); + } + return Era.super.range(field); } //----------------------------------------------------------------------- diff --git a/jdk/src/share/classes/java/time/chrono/MinguoChronology.java b/jdk/src/share/classes/java/time/chrono/MinguoChronology.java index 7dcf8c44344..f977b496e0f 100644 --- a/jdk/src/share/classes/java/time/chrono/MinguoChronology.java +++ b/jdk/src/share/classes/java/time/chrono/MinguoChronology.java @@ -56,6 +56,7 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import java.io.Serializable; @@ -106,16 +107,6 @@ public final class MinguoChronology extends Chronology implements Serializable { */ public static final MinguoChronology INSTANCE = new MinguoChronology(); - /** - * The singleton instance for the era ROC. - */ - public static final Era ERA_ROC = MinguoEra.ROC; - - /** - * The singleton instance for the era BEFORE_ROC. - */ - public static final Era ERA_BEFORE_ROC = MinguoEra.BEFORE_ROC; - /** * Serialization version. */ @@ -131,15 +122,6 @@ public final class MinguoChronology extends Chronology implements Serializable { private MinguoChronology() { } - /** - * Resolve singleton. - * - * @return the singleton instance, not null - */ - private Object readResolve() { - return INSTANCE; - } - //----------------------------------------------------------------------- /** * Gets the ID of the chronology - 'Minguo'. @@ -173,32 +155,78 @@ public final class MinguoChronology extends Chronology implements Serializable { } //----------------------------------------------------------------------- + /** + * Obtains a local date in Minguo calendar system from the + * era, year-of-era, month-of-year and day-of-month fields. + * + * @param era the Minguo era, not null + * @param yearOfEra the year-of-era + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Minguo local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code MinguoEra} + */ + @Override + public MinguoDate date(Era era, int yearOfEra, int month, int dayOfMonth) { + return date(prolepticYear(era, yearOfEra), month, dayOfMonth); + } + + /** + * Obtains a local date in Minguo calendar system from the + * proleptic-year, month-of-year and day-of-month fields. + * + * @param prolepticYear the proleptic-year + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Minguo local date, not null + * @throws DateTimeException if unable to create the date + */ @Override public MinguoDate date(int prolepticYear, int month, int dayOfMonth) { return new MinguoDate(LocalDate.of(prolepticYear + YEARS_DIFFERENCE, month, dayOfMonth)); } + /** + * Obtains a local date in Minguo calendar system from the + * era, year-of-era and day-of-year fields. + * + * @param era the Minguo era, not null + * @param yearOfEra the year-of-era + * @param dayOfYear the day-of-year + * @return the Minguo local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code MinguoEra} + */ + @Override + public MinguoDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { + return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + } + + /** + * Obtains a local date in Minguo calendar system from the + * proleptic-year and day-of-year fields. + * + * @param prolepticYear the proleptic-year + * @param dayOfYear the day-of-year + * @return the Minguo local date, not null + * @throws DateTimeException if unable to create the date + */ @Override public MinguoDate dateYearDay(int prolepticYear, int dayOfYear) { return new MinguoDate(LocalDate.ofYearDay(prolepticYear + YEARS_DIFFERENCE, dayOfYear)); } - @Override - public MinguoDate date(TemporalAccessor temporal) { - if (temporal instanceof MinguoDate) { - return (MinguoDate) temporal; - } - return new MinguoDate(LocalDate.from(temporal)); - } - @Override - public MinguoDate date(Era era, int yearOfEra, int month, int dayOfMonth) { - return date(prolepticYear(era, yearOfEra), month, dayOfMonth); - - } - - @Override - public MinguoDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { - return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + /** + * Obtains a local date in the Minguo calendar system from the epoch-day. + * + * @param epochDay the epoch day + * @return the Minguo local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override // override with covariant return type + public MinguoDate dateEpochDay(long epochDay) { + return new MinguoDate(LocalDate.ofEpochDay(epochDay)); } @Override @@ -216,6 +244,14 @@ public final class MinguoChronology extends Chronology implements Serializable { return date(LocalDate.now(clock)); } + @Override + public MinguoDate date(TemporalAccessor temporal) { + if (temporal instanceof MinguoDate) { + return (MinguoDate) temporal; + } + return new MinguoDate(LocalDate.from(temporal)); + } + @Override public ChronoLocalDateTime localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime)super.localDateTime(temporal); @@ -250,7 +286,7 @@ public final class MinguoChronology extends Chronology implements Serializable { @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof MinguoEra == false) { - throw new DateTimeException("Era must be MinguoEra"); + throw new ClassCastException("Era must be MinguoEra"); } return (era == MinguoEra.ROC ? yearOfEra : 1 - yearOfEra); } @@ -269,6 +305,10 @@ public final class MinguoChronology extends Chronology implements Serializable { @Override public ValueRange range(ChronoField field) { switch (field) { + case PROLEPTIC_MONTH: { + ValueRange range = PROLEPTIC_MONTH.range(); + return ValueRange.of(range.getMinimum() - YEARS_DIFFERENCE * 12L, range.getMaximum() - YEARS_DIFFERENCE * 12L); + } case YEAR_OF_ERA: { ValueRange range = YEAR.range(); return ValueRange.of(1, range.getMaximum() - YEARS_DIFFERENCE, -range.getMinimum() + 1 + YEARS_DIFFERENCE); diff --git a/jdk/src/share/classes/java/time/chrono/MinguoDate.java b/jdk/src/share/classes/java/time/chrono/MinguoDate.java index a02bbd21cc8..07ce800ab06 100644 --- a/jdk/src/share/classes/java/time/chrono/MinguoDate.java +++ b/jdk/src/share/classes/java/time/chrono/MinguoDate.java @@ -72,12 +72,13 @@ import java.time.LocalTime; import java.time.Period; import java.time.ZoneId; import java.time.temporal.ChronoField; -import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -205,16 +206,46 @@ public final class MinguoDate } //----------------------------------------------------------------------- + /** + * Gets the chronology of this date, which is the Minguo calendar system. + *

    + * The {@code Chronology} represents the calendar system in use. + * The era and other fields in {@link ChronoField} are defined by the chronology. + * + * @return the Minguo chronology, not null + */ @Override public MinguoChronology getChronology() { return MinguoChronology.INSTANCE; } + /** + * Gets the era applicable at this date. + *

    + * The Minguo calendar system has two eras, 'ROC' and 'BEFORE_ROC', + * defined by {@link MinguoEra}. + * + * @return the era applicable at this date, not null + */ + @Override + public MinguoEra getEra() { + return (getProlepticYear() >= 1 ? MinguoEra.ROC : MinguoEra.BEFORE_ROC); + } + + /** + * Returns the length of the month represented by this date. + *

    + * This returns the length of the month in days. + * Month lengths match those of the ISO calendar system. + * + * @return the length of the month in days + */ @Override public int lengthOfMonth() { return isoDate.lengthOfMonth(); } + //----------------------------------------------------------------------- @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { @@ -233,7 +264,7 @@ public final class MinguoDate } return getChronology().range(f); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } @@ -242,6 +273,8 @@ public final class MinguoDate public long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { + case PROLEPTIC_MONTH: + return getProlepticMonth(); case YEAR_OF_ERA: { int prolepticYear = getProlepticYear(); return (prolepticYear >= 1 ? prolepticYear : 1 - prolepticYear); @@ -256,6 +289,10 @@ public final class MinguoDate return field.getFrom(this); } + private long getProlepticMonth() { + return getProlepticYear() * 12L + isoDate.getMonthValue() - 1; + } + private int getProlepticYear() { return isoDate.getYear() - YEARS_DIFFERENCE; } @@ -269,11 +306,13 @@ public final class MinguoDate return this; } switch (f) { + case PROLEPTIC_MONTH: + getChronology().range(f).checkValidValue(newValue, f); + return plusMonths(newValue - getProlepticMonth()); case YEAR_OF_ERA: case YEAR: case ERA: { - f.checkValidValue(newValue); - int nvalue = (int) newValue; + int nvalue = getChronology().range(f).checkValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return with(isoDate.withYear(getProlepticYear() >= 1 ? nvalue + YEARS_DIFFERENCE : (1 - nvalue) + YEARS_DIFFERENCE)); @@ -286,7 +325,7 @@ public final class MinguoDate } return with(isoDate.with(field, newValue)); } - return (MinguoDate) ChronoLocalDate.super.with(field, newValue); + return ChronoLocalDate.super.with(field, newValue); } /** @@ -296,7 +335,7 @@ public final class MinguoDate */ @Override public MinguoDate with(TemporalAdjuster adjuster) { - return (MinguoDate)super.with(adjuster); + return super.with(adjuster); } /** @@ -306,7 +345,7 @@ public final class MinguoDate */ @Override public MinguoDate plus(TemporalAmount amount) { - return (MinguoDate)super.plus(amount); + return super.plus(amount); } /** @@ -316,7 +355,7 @@ public final class MinguoDate */ @Override public MinguoDate minus(TemporalAmount amount) { - return (MinguoDate)super.minus(amount); + return super.minus(amount); } //----------------------------------------------------------------------- @@ -337,37 +376,37 @@ public final class MinguoDate @Override public MinguoDate plus(long amountToAdd, TemporalUnit unit) { - return (MinguoDate)super.plus(amountToAdd, unit); + return super.plus(amountToAdd, unit); } @Override public MinguoDate minus(long amountToAdd, TemporalUnit unit) { - return (MinguoDate)super.minus(amountToAdd, unit); + return super.minus(amountToAdd, unit); } @Override MinguoDate plusWeeks(long weeksToAdd) { - return (MinguoDate)super.plusWeeks(weeksToAdd); + return super.plusWeeks(weeksToAdd); } @Override MinguoDate minusYears(long yearsToSubtract) { - return (MinguoDate)super.minusYears(yearsToSubtract); + return super.minusYears(yearsToSubtract); } @Override MinguoDate minusMonths(long monthsToSubtract) { - return (MinguoDate)super.minusMonths(monthsToSubtract); + return super.minusMonths(monthsToSubtract); } @Override MinguoDate minusWeeks(long weeksToSubtract) { - return (MinguoDate)super.minusWeeks(weeksToSubtract); + return super.minusWeeks(weeksToSubtract); } @Override MinguoDate minusDays(long daysToSubtract) { - return (MinguoDate)super.minusDays(daysToSubtract); + return super.minusDays(daysToSubtract); } private MinguoDate with(LocalDate newDate) { @@ -376,7 +415,7 @@ public final class MinguoDate @Override // for javadoc and covariant return type public final ChronoLocalDateTime atTime(LocalTime localTime) { - return (ChronoLocalDateTime)super.atTime(localTime); + return super.atTime(localTime); } @Override @@ -419,7 +458,7 @@ public final class MinguoDate out.writeByte(get(DAY_OF_MONTH)); } - static ChronoLocalDate readExternal(DataInput in) throws IOException { + static ChronoLocalDate readExternal(DataInput in) throws IOException { int year = in.readInt(); int month = in.readByte(); int dayOfMonth = in.readByte(); diff --git a/jdk/src/share/classes/java/time/chrono/MinguoEra.java b/jdk/src/share/classes/java/time/chrono/MinguoEra.java index a3646f7a3c9..0563515834d 100644 --- a/jdk/src/share/classes/java/time/chrono/MinguoEra.java +++ b/jdk/src/share/classes/java/time/chrono/MinguoEra.java @@ -24,6 +24,11 @@ */ /* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. @@ -65,7 +70,34 @@ import java.time.DateTimeException; * An era in the Minguo calendar system. *

    * The Minguo calendar system has two eras. - * The date {@code 0001-01-01 (Minguo)} is equal to {@code 1912-01-01 (ISO)}. + * The current era, for years from 1 onwards, is known as the 'Republic of China' era. + * All previous years, zero or earlier in the proleptic count or one and greater + * in the year-of-era count, are part of the 'Before Republic of China' era. + *

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    year-of-eraeraproleptic-yearISO proleptic-year
    2ROC21913
    1ROC11912
    1BEFORE_ROC01911
    2BEFORE_ROC-11910
    *

    * Do not use {@code ordinal()} to obtain the numeric representation of {@code MinguoEra}. * Use {@code getValue()} instead. @@ -75,16 +107,16 @@ import java.time.DateTimeException; * * @since 1.8 */ -enum MinguoEra implements Era { +public enum MinguoEra implements Era { /** - * The singleton instance for the era BEFORE_ROC, 'Before Republic of China'. - * This has the numeric value of {@code 0}. + * The singleton instance for the era before the current one, 'Before Republic of China Era', + * which has the numeric value 0. */ BEFORE_ROC, /** - * The singleton instance for the era ROC, 'Republic of China'. - * This has the numeric value of {@code 1}. + * The singleton instance for the current era, 'Republic of China Era', + * which has the numeric value 1. */ ROC; @@ -95,18 +127,18 @@ enum MinguoEra implements Era { * {@code MinguoEra} is an enum representing the Minguo eras of BEFORE_ROC/ROC. * This factory allows the enum to be obtained from the {@code int} value. * - * @param era the BEFORE_ROC/ROC value to represent, from 0 (BEFORE_ROC) to 1 (ROC) + * @param minguoEra the BEFORE_ROC/ROC value to represent, from 0 (BEFORE_ROC) to 1 (ROC) * @return the era singleton, not null * @throws DateTimeException if the value is invalid */ - public static MinguoEra of(int era) { - switch (era) { + public static MinguoEra of(int minguoEra) { + switch (minguoEra) { case 0: return BEFORE_ROC; case 1: return ROC; default: - throw new DateTimeException("Invalid era: " + era); + throw new DateTimeException("Invalid era: " + minguoEra); } } @@ -123,24 +155,7 @@ enum MinguoEra implements Era { return ordinal(); } - @Override - public MinguoChronology getChronology() { - return MinguoChronology.INSTANCE; - } - - // JDK8 default methods: //----------------------------------------------------------------------- - @Override - public MinguoDate date(int year, int month, int day) { - return (MinguoDate)(getChronology().date(this, year, month, day)); - } - - @Override - public MinguoDate dateYearDay(int year, int dayOfYear) { - return (MinguoDate)(getChronology().dateYearDay(this, year, dayOfYear)); - } - - //------------------------------------------------------------------------- private Object writeReplace() { return new Ser(Ser.MINGUO_ERA_TYPE, this); } diff --git a/jdk/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java b/jdk/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java index daf4cf91e24..aee743526ab 100644 --- a/jdk/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java +++ b/jdk/src/share/classes/java/time/chrono/ThaiBuddhistChronology.java @@ -56,6 +56,7 @@ */ package java.time.chrono; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import java.io.Serializable; @@ -106,15 +107,6 @@ public final class ThaiBuddhistChronology extends Chronology implements Serializ * Singleton instance of the Buddhist chronology. */ public static final ThaiBuddhistChronology INSTANCE = new ThaiBuddhistChronology(); - /** - * The singleton instance for the era before the current one - Before Buddhist - - * which has the value 0. - */ - public static final Era ERA_BEFORE_BE = ThaiBuddhistEra.BEFORE_BE; - /** - * The singleton instance for the current era - Buddhist - which has the value 1. - */ - public static final Era ERA_BE = ThaiBuddhistEra.BE; /** * Serialization version. @@ -166,15 +158,6 @@ public final class ThaiBuddhistChronology extends Chronology implements Serializ private ThaiBuddhistChronology() { } - /** - * Resolve singleton. - * - * @return the singleton instance, not null - */ - private Object readResolve() { - return INSTANCE; - } - //----------------------------------------------------------------------- /** * Gets the ID of the chronology - 'ThaiBuddhist'. @@ -208,32 +191,78 @@ public final class ThaiBuddhistChronology extends Chronology implements Serializ } //----------------------------------------------------------------------- + /** + * Obtains a local date in Thai Buddhist calendar system from the + * era, year-of-era, month-of-year and day-of-month fields. + * + * @param era the Thai Buddhist era, not null + * @param yearOfEra the year-of-era + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Thai Buddhist local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code ThaiBuddhistEra} + */ + @Override + public ThaiBuddhistDate date(Era era, int yearOfEra, int month, int dayOfMonth) { + return date(prolepticYear(era, yearOfEra), month, dayOfMonth); + } + + /** + * Obtains a local date in Thai Buddhist calendar system from the + * proleptic-year, month-of-year and day-of-month fields. + * + * @param prolepticYear the proleptic-year + * @param month the month-of-year + * @param dayOfMonth the day-of-month + * @return the Thai Buddhist local date, not null + * @throws DateTimeException if unable to create the date + */ @Override public ThaiBuddhistDate date(int prolepticYear, int month, int dayOfMonth) { return new ThaiBuddhistDate(LocalDate.of(prolepticYear - YEARS_DIFFERENCE, month, dayOfMonth)); } + /** + * Obtains a local date in Thai Buddhist calendar system from the + * era, year-of-era and day-of-year fields. + * + * @param era the Thai Buddhist era, not null + * @param yearOfEra the year-of-era + * @param dayOfYear the day-of-year + * @return the Thai Buddhist local date, not null + * @throws DateTimeException if unable to create the date + * @throws ClassCastException if the {@code era} is not a {@code ThaiBuddhistEra} + */ + @Override + public ThaiBuddhistDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { + return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + } + + /** + * Obtains a local date in Thai Buddhist calendar system from the + * proleptic-year and day-of-year fields. + * + * @param prolepticYear the proleptic-year + * @param dayOfYear the day-of-year + * @return the Thai Buddhist local date, not null + * @throws DateTimeException if unable to create the date + */ @Override public ThaiBuddhistDate dateYearDay(int prolepticYear, int dayOfYear) { return new ThaiBuddhistDate(LocalDate.ofYearDay(prolepticYear - YEARS_DIFFERENCE, dayOfYear)); } - @Override - public ThaiBuddhistDate date(TemporalAccessor temporal) { - if (temporal instanceof ThaiBuddhistDate) { - return (ThaiBuddhistDate) temporal; - } - return new ThaiBuddhistDate(LocalDate.from(temporal)); - } - @Override - public ThaiBuddhistDate date(Era era, int yearOfEra, int month, int dayOfMonth) { - return date(prolepticYear(era, yearOfEra), month, dayOfMonth); - - } - - @Override - public ThaiBuddhistDate dateYearDay(Era era, int yearOfEra, int dayOfYear) { - return dateYearDay(prolepticYear(era, yearOfEra), dayOfYear); + /** + * Obtains a local date in the Thai Buddhist calendar system from the epoch-day. + * + * @param epochDay the epoch day + * @return the Thai Buddhist local date, not null + * @throws DateTimeException if unable to create the date + */ + @Override // override with covariant return type + public ThaiBuddhistDate dateEpochDay(long epochDay) { + return new ThaiBuddhistDate(LocalDate.ofEpochDay(epochDay)); } @Override @@ -251,6 +280,14 @@ public final class ThaiBuddhistChronology extends Chronology implements Serializ return date(LocalDate.now(clock)); } + @Override + public ThaiBuddhistDate date(TemporalAccessor temporal) { + if (temporal instanceof ThaiBuddhistDate) { + return (ThaiBuddhistDate) temporal; + } + return new ThaiBuddhistDate(LocalDate.from(temporal)); + } + @Override public ChronoLocalDateTime localDateTime(TemporalAccessor temporal) { return (ChronoLocalDateTime)super.localDateTime(temporal); @@ -285,7 +322,7 @@ public final class ThaiBuddhistChronology extends Chronology implements Serializ @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof ThaiBuddhistEra == false) { - throw new DateTimeException("Era must be BuddhistEra"); + throw new ClassCastException("Era must be BuddhistEra"); } return (era == ThaiBuddhistEra.BE ? yearOfEra : 1 - yearOfEra); } @@ -304,6 +341,10 @@ public final class ThaiBuddhistChronology extends Chronology implements Serializ @Override public ValueRange range(ChronoField field) { switch (field) { + case PROLEPTIC_MONTH: { + ValueRange range = PROLEPTIC_MONTH.range(); + return ValueRange.of(range.getMinimum() + YEARS_DIFFERENCE * 12L, range.getMaximum() + YEARS_DIFFERENCE * 12L); + } case YEAR_OF_ERA: { ValueRange range = YEAR.range(); return ValueRange.of(1, -(range.getMinimum() + YEARS_DIFFERENCE) + 1, range.getMaximum() + YEARS_DIFFERENCE); diff --git a/jdk/src/share/classes/java/time/chrono/ThaiBuddhistDate.java b/jdk/src/share/classes/java/time/chrono/ThaiBuddhistDate.java index e1645c5bf36..b879a14e586 100644 --- a/jdk/src/share/classes/java/time/chrono/ThaiBuddhistDate.java +++ b/jdk/src/share/classes/java/time/chrono/ThaiBuddhistDate.java @@ -72,12 +72,13 @@ import java.time.LocalTime; import java.time.Period; import java.time.ZoneId; import java.time.temporal.ChronoField; -import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.time.temporal.ValueRange; import java.util.Objects; @@ -205,16 +206,46 @@ public final class ThaiBuddhistDate } //----------------------------------------------------------------------- + /** + * Gets the chronology of this date, which is the Thai Buddhist calendar system. + *

    + * The {@code Chronology} represents the calendar system in use. + * The era and other fields in {@link ChronoField} are defined by the chronology. + * + * @return the Thai Buddhist chronology, not null + */ @Override public ThaiBuddhistChronology getChronology() { return ThaiBuddhistChronology.INSTANCE; } + /** + * Gets the era applicable at this date. + *

    + * The Thai Buddhist calendar system has two eras, 'BE' and 'BEFORE_BE', + * defined by {@link ThaiBuddhistEra}. + * + * @return the era applicable at this date, not null + */ + @Override + public ThaiBuddhistEra getEra() { + return (getProlepticYear() >= 1 ? ThaiBuddhistEra.BE : ThaiBuddhistEra.BEFORE_BE); + } + + /** + * Returns the length of the month represented by this date. + *

    + * This returns the length of the month in days. + * Month lengths match those of the ISO calendar system. + * + * @return the length of the month in days + */ @Override public int lengthOfMonth() { return isoDate.lengthOfMonth(); } + //----------------------------------------------------------------------- @Override public ValueRange range(TemporalField field) { if (field instanceof ChronoField) { @@ -233,7 +264,7 @@ public final class ThaiBuddhistDate } return getChronology().range(f); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } @@ -242,6 +273,8 @@ public final class ThaiBuddhistDate public long getLong(TemporalField field) { if (field instanceof ChronoField) { switch ((ChronoField) field) { + case PROLEPTIC_MONTH: + return getProlepticMonth(); case YEAR_OF_ERA: { int prolepticYear = getProlepticYear(); return (prolepticYear >= 1 ? prolepticYear : 1 - prolepticYear); @@ -256,6 +289,10 @@ public final class ThaiBuddhistDate return field.getFrom(this); } + private long getProlepticMonth() { + return getProlepticYear() * 12L + isoDate.getMonthValue() - 1; + } + private int getProlepticYear() { return isoDate.getYear() + YEARS_DIFFERENCE; } @@ -269,11 +306,13 @@ public final class ThaiBuddhistDate return this; } switch (f) { + case PROLEPTIC_MONTH: + getChronology().range(f).checkValidValue(newValue, f); + return plusMonths(newValue - getProlepticMonth()); case YEAR_OF_ERA: case YEAR: case ERA: { - f.checkValidValue(newValue); - int nvalue = (int) newValue; + int nvalue = getChronology().range(f).checkValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return with(isoDate.withYear((getProlepticYear() >= 1 ? nvalue : 1 - nvalue) - YEARS_DIFFERENCE)); @@ -286,7 +325,7 @@ public final class ThaiBuddhistDate } return with(isoDate.with(field, newValue)); } - return (ThaiBuddhistDate) ChronoLocalDate.super.with(field, newValue); + return ChronoLocalDate.super.with(field, newValue); } /** @@ -296,7 +335,7 @@ public final class ThaiBuddhistDate */ @Override public ThaiBuddhistDate with(TemporalAdjuster adjuster) { - return (ThaiBuddhistDate)super.with(adjuster); + return super.with(adjuster); } /** @@ -306,7 +345,7 @@ public final class ThaiBuddhistDate */ @Override public ThaiBuddhistDate plus(TemporalAmount amount) { - return (ThaiBuddhistDate)super.plus(amount); + return super.plus(amount); } /** @@ -316,7 +355,7 @@ public final class ThaiBuddhistDate */ @Override public ThaiBuddhistDate minus(TemporalAmount amount) { - return (ThaiBuddhistDate)super.minus(amount); + return super.minus(amount); } //----------------------------------------------------------------------- @@ -332,7 +371,7 @@ public final class ThaiBuddhistDate @Override ThaiBuddhistDate plusWeeks(long weeksToAdd) { - return (ThaiBuddhistDate)super.plusWeeks(weeksToAdd); + return super.plusWeeks(weeksToAdd); } @Override @@ -342,32 +381,32 @@ public final class ThaiBuddhistDate @Override public ThaiBuddhistDate plus(long amountToAdd, TemporalUnit unit) { - return (ThaiBuddhistDate)super.plus(amountToAdd, unit); + return super.plus(amountToAdd, unit); } @Override public ThaiBuddhistDate minus(long amountToAdd, TemporalUnit unit) { - return (ThaiBuddhistDate)super.minus(amountToAdd, unit); + return super.minus(amountToAdd, unit); } @Override ThaiBuddhistDate minusYears(long yearsToSubtract) { - return (ThaiBuddhistDate)super.minusYears(yearsToSubtract); + return super.minusYears(yearsToSubtract); } @Override ThaiBuddhistDate minusMonths(long monthsToSubtract) { - return (ThaiBuddhistDate)super.minusMonths(monthsToSubtract); + return super.minusMonths(monthsToSubtract); } @Override ThaiBuddhistDate minusWeeks(long weeksToSubtract) { - return (ThaiBuddhistDate)super.minusWeeks(weeksToSubtract); + return super.minusWeeks(weeksToSubtract); } @Override ThaiBuddhistDate minusDays(long daysToSubtract) { - return (ThaiBuddhistDate)super.minusDays(daysToSubtract); + return super.minusDays(daysToSubtract); } private ThaiBuddhistDate with(LocalDate newDate) { @@ -376,7 +415,7 @@ public final class ThaiBuddhistDate @Override // for javadoc and covariant return type public final ChronoLocalDateTime atTime(LocalTime localTime) { - return (ChronoLocalDateTime)super.atTime(localTime); + return super.atTime(localTime); } @Override diff --git a/jdk/src/share/classes/java/time/chrono/ThaiBuddhistEra.java b/jdk/src/share/classes/java/time/chrono/ThaiBuddhistEra.java index 24c1bb38199..d1fb55fc740 100644 --- a/jdk/src/share/classes/java/time/chrono/ThaiBuddhistEra.java +++ b/jdk/src/share/classes/java/time/chrono/ThaiBuddhistEra.java @@ -24,6 +24,11 @@ */ /* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. @@ -56,7 +61,6 @@ */ package java.time.chrono; - import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; @@ -66,37 +70,66 @@ import java.time.DateTimeException; * An era in the Thai Buddhist calendar system. *

    * The Thai Buddhist calendar system has two eras. + * The current era, for years from 1 onwards, is known as the 'Buddhist' era. + * All previous years, zero or earlier in the proleptic count or one and greater + * in the year-of-era count, are part of the 'Before Buddhist' era. *

    - * Do not use ordinal() to obtain the numeric representation of a ThaiBuddhistEra - * instance. Use getValue() instead. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    year-of-eraeraproleptic-yearISO proleptic-year
    2BE2-542
    1BE1-543
    1BEFORE_BE0-544
    2BEFORE_BE-1-545
    + *

    + * Do not use {@code ordinal()} to obtain the numeric representation of {@code ThaiBuddhistEra}. + * Use {@code getValue()} instead. * *

    Specification for implementors

    * This is an immutable and thread-safe enum. * * @since 1.8 */ -enum ThaiBuddhistEra implements Era { +public enum ThaiBuddhistEra implements Era { /** * The singleton instance for the era before the current one, 'Before Buddhist Era', - * which has the value 0. + * which has the numeric value 0. */ BEFORE_BE, /** - * The singleton instance for the current era, 'Buddhist Era', which has the value 1. + * The singleton instance for the current era, 'Buddhist Era', + * which has the numeric value 1. */ BE; //----------------------------------------------------------------------- /** - * Obtains an instance of {@code ThaiBuddhistEra} from a value. + * Obtains an instance of {@code ThaiBuddhistEra} from an {@code int} value. *

    - * The current era (from ISO year -543 onwards) has the value 1 - * The previous era has the value 0. + * {@code ThaiBuddhistEra} is an enum representing the Thai Buddhist eras of BEFORE_BE/BE. + * This factory allows the enum to be obtained from the {@code int} value. * * @param thaiBuddhistEra the era to represent, from 0 to 1 * @return the BuddhistEra singleton, never null - * @throws IllegalCalendarFieldValueException if the era is invalid + * @throws DateTimeException if the era is invalid */ public static ThaiBuddhistEra of(int thaiBuddhistEra) { switch (thaiBuddhistEra) { @@ -105,16 +138,15 @@ enum ThaiBuddhistEra implements Era { case 1: return BE; default: - throw new DateTimeException("Era is not valid for ThaiBuddhistEra"); + throw new DateTimeException("Invalid era: " + thaiBuddhistEra); } } //----------------------------------------------------------------------- /** - * Gets the era numeric value. + * Gets the numeric era {@code int} value. *

    - * The current era (from ISO year -543 onwards) has the value 1 - * The previous era has the value 0. + * The era BEFORE_BE has the value 0, while the era BE has the value 1. * * @return the era value, from 0 (BEFORE_BE) to 1 (BE) */ @@ -123,23 +155,6 @@ enum ThaiBuddhistEra implements Era { return ordinal(); } - @Override - public ThaiBuddhistChronology getChronology() { - return ThaiBuddhistChronology.INSTANCE; - } - - // JDK8 default methods: - //----------------------------------------------------------------------- - @Override - public ThaiBuddhistDate date(int year, int month, int day) { - return (ThaiBuddhistDate)(getChronology().date(this, year, month, day)); - } - - @Override - public ThaiBuddhistDate dateYearDay(int year, int dayOfYear) { - return (ThaiBuddhistDate)(getChronology().dateYearDay(this, year, dayOfYear)); - } - //----------------------------------------------------------------------- private Object writeReplace() { return new Ser(Ser.THAIBUDDHIST_ERA_TYPE, this); diff --git a/jdk/src/share/classes/java/time/format/DateTimeBuilder.java b/jdk/src/share/classes/java/time/format/DateTimeBuilder.java deleted file mode 100644 index 43f85bb3de1..00000000000 --- a/jdk/src/share/classes/java/time/format/DateTimeBuilder.java +++ /dev/null @@ -1,595 +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. 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. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package java.time.format; - -import static java.time.temporal.Adjusters.nextOrSame; -import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; -import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; -import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH; -import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR; -import static java.time.temporal.ChronoField.AMPM_OF_DAY; -import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_AMPM; -import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_DAY; -import static java.time.temporal.ChronoField.DAY_OF_MONTH; -import static java.time.temporal.ChronoField.DAY_OF_WEEK; -import static java.time.temporal.ChronoField.DAY_OF_YEAR; -import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; -import static java.time.temporal.ChronoField.ERA; -import static java.time.temporal.ChronoField.HOUR_OF_AMPM; -import static java.time.temporal.ChronoField.HOUR_OF_DAY; -import static java.time.temporal.ChronoField.MICRO_OF_DAY; -import static java.time.temporal.ChronoField.MICRO_OF_SECOND; -import static java.time.temporal.ChronoField.MILLI_OF_DAY; -import static java.time.temporal.ChronoField.MILLI_OF_SECOND; -import static java.time.temporal.ChronoField.MINUTE_OF_DAY; -import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; -import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static java.time.temporal.ChronoField.NANO_OF_DAY; -import static java.time.temporal.ChronoField.NANO_OF_SECOND; -import static java.time.temporal.ChronoField.SECOND_OF_DAY; -import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; -import static java.time.temporal.ChronoField.YEAR; -import static java.time.temporal.ChronoField.YEAR_OF_ERA; - -import java.time.DateTimeException; -import java.time.DayOfWeek; -import java.time.LocalDate; -import java.time.LocalTime; -import java.time.ZoneId; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.Chronology; -import java.time.chrono.Era; -import java.time.chrono.IsoChronology; -import java.time.chrono.JapaneseChronology; -import java.time.temporal.ChronoField; -import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalField; -import java.time.temporal.TemporalQuery; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * Builder that can holds date and time fields and related date and time objects. - *

    - * This class still needs major revision before JDK1.8 ships. - *

    - * The builder is used to hold onto different elements of date and time. - * It holds two kinds of object: - *

      - *
    • a {@code Map} from {@link TemporalField} to {@code long} value, where the - * value may be outside the valid range for the field - *
    • a list of objects, such as {@code Chronology} or {@code ZoneId} - *

    - * - *

    Specification for implementors

    - * This class is mutable and not thread-safe. - * It should only be used from a single thread. - * - * @since 1.8 - */ -final class DateTimeBuilder - implements TemporalAccessor, Cloneable { - - /** - * The map of other fields. - */ - private Map otherFields; - /** - * The map of date-time fields. - */ - private final EnumMap standardFields = new EnumMap(ChronoField.class); - /** - * The chronology. - */ - private Chronology chrono; - /** - * The zone. - */ - private ZoneId zone; - /** - * The date. - */ - private LocalDate date; - /** - * The time. - */ - private LocalTime time; - - //----------------------------------------------------------------------- - /** - * Creates an empty instance of the builder. - */ - public DateTimeBuilder() { - } - - //----------------------------------------------------------------------- - private Long getFieldValue0(TemporalField field) { - if (field instanceof ChronoField) { - return standardFields.get(field); - } else if (otherFields != null) { - return otherFields.get(field); - } - return null; - } - - /** - * Adds a field-value pair to the builder. - *

    - * This adds a field to the builder. - * If the field is not already present, then the field-value pair is added to the map. - * If the field is already present and it has the same value as that specified, no action occurs. - * If the field is already present and it has a different value to that specified, then - * an exception is thrown. - * - * @param field the field to add, not null - * @param value the value to add, not null - * @return {@code this}, for method chaining - * @throws DateTimeException if the field is already present with a different value - */ - DateTimeBuilder addFieldValue(TemporalField field, long value) { - Objects.requireNonNull(field, "field"); - Long old = getFieldValue0(field); // check first for better error message - if (old != null && old.longValue() != value) { - throw new DateTimeException("Conflict found: " + field + " " + old + " differs from " + field + " " + value + ": " + this); - } - return putFieldValue0(field, value); - } - - private DateTimeBuilder putFieldValue0(TemporalField field, long value) { - if (field instanceof ChronoField) { - standardFields.put((ChronoField) field, value); - } else { - if (otherFields == null) { - otherFields = new LinkedHashMap(); - } - otherFields.put(field, value); - } - return this; - } - - //----------------------------------------------------------------------- - void addObject(Chronology chrono) { - this.chrono = chrono; - } - - void addObject(ZoneId zone) { - this.zone = zone; - } - - void addObject(LocalDate date) { - this.date = date; - } - - void addObject(LocalTime time) { - this.time = time; - } - - //----------------------------------------------------------------------- - /** - * Resolves the builder, evaluating the date and time. - *

    - * This examines the contents of the builder and resolves it to produce the best - * available date and time, throwing an exception if a problem occurs. - * Calling this method changes the state of the builder. - * - * @return {@code this}, for method chaining - */ - DateTimeBuilder resolve() { - // handle standard fields - mergeDate(); - mergeTime(); - // TODO: cross validate remaining fields? - return this; - } - - private void mergeDate() { - if (standardFields.containsKey(EPOCH_DAY)) { - checkDate(LocalDate.ofEpochDay(standardFields.remove(EPOCH_DAY))); - return; - } - - Era era = null; - if (chrono == IsoChronology.INSTANCE) { - // normalize fields - if (standardFields.containsKey(EPOCH_MONTH)) { - long em = standardFields.remove(EPOCH_MONTH); - addFieldValue(MONTH_OF_YEAR, (em % 12) + 1); - addFieldValue(YEAR, (em / 12) + 1970); - } - } else { - // TODO: revisit EPOCH_MONTH calculation in non-ISO chronology - // Handle EPOCH_MONTH here for non-ISO Chronology - if (standardFields.containsKey(EPOCH_MONTH)) { - long em = standardFields.remove(EPOCH_MONTH); - ChronoLocalDate chronoDate = chrono.date(LocalDate.ofEpochDay(0L)); - chronoDate = chronoDate.plus(em, ChronoUnit.MONTHS); - LocalDate date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - checkDate(date); - return; - } - List eras = chrono.eras(); - if (!eras.isEmpty()) { - if (standardFields.containsKey(ERA)) { - long index = standardFields.remove(ERA); - era = chrono.eraOf((int) index); - } else { - era = eras.get(eras.size() - 1); // current Era - } - if (standardFields.containsKey(YEAR_OF_ERA)) { - Long y = standardFields.remove(YEAR_OF_ERA); - putFieldValue0(YEAR, y); - } - } - - } - - // build date - if (standardFields.containsKey(YEAR)) { - if (standardFields.containsKey(MONTH_OF_YEAR)) { - if (standardFields.containsKey(DAY_OF_MONTH)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int moy = Math.toIntExact(standardFields.remove(MONTH_OF_YEAR)); - int dom = Math.toIntExact(standardFields.remove(DAY_OF_MONTH)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.of(y, moy, dom); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.date(y, moy, dom); - } else { - chronoDate = era.date(y, moy, dom); - } - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - if (standardFields.containsKey(ALIGNED_WEEK_OF_MONTH)) { - if (standardFields.containsKey(ALIGNED_DAY_OF_WEEK_IN_MONTH)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int moy = Math.toIntExact(standardFields.remove(MONTH_OF_YEAR)); - int aw = Math.toIntExact(standardFields.remove(ALIGNED_WEEK_OF_MONTH)); - int ad = Math.toIntExact(standardFields.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.of(y, moy, 1).plusDays((aw - 1) * 7 + (ad - 1)); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.date(y, moy, 1); - } else { - chronoDate = era.date(y, moy, 1); - } - chronoDate = chronoDate.plus((aw - 1) * 7 + (ad - 1), ChronoUnit.DAYS); - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - if (standardFields.containsKey(DAY_OF_WEEK)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int moy = Math.toIntExact(standardFields.remove(MONTH_OF_YEAR)); - int aw = Math.toIntExact(standardFields.remove(ALIGNED_WEEK_OF_MONTH)); - int dow = Math.toIntExact(standardFields.remove(DAY_OF_WEEK)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.of(y, moy, 1).plusDays((aw - 1) * 7).with(nextOrSame(DayOfWeek.of(dow))); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.date(y, moy, 1); - } else { - chronoDate = era.date(y, moy, 1); - } - chronoDate = chronoDate.plus((aw - 1) * 7, ChronoUnit.DAYS).with(nextOrSame(DayOfWeek.of(dow))); - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - } - } - if (standardFields.containsKey(DAY_OF_YEAR)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int doy = Math.toIntExact(standardFields.remove(DAY_OF_YEAR)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.ofYearDay(y, doy); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.dateYearDay(y, doy); - } else { - chronoDate = era.dateYearDay(y, doy); - } - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - if (standardFields.containsKey(ALIGNED_WEEK_OF_YEAR)) { - if (standardFields.containsKey(ALIGNED_DAY_OF_WEEK_IN_YEAR)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int aw = Math.toIntExact(standardFields.remove(ALIGNED_WEEK_OF_YEAR)); - int ad = Math.toIntExact(standardFields.remove(ALIGNED_DAY_OF_WEEK_IN_YEAR)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.of(y, 1, 1).plusDays((aw - 1) * 7 + (ad - 1)); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.dateYearDay(y, 1); - } else { - chronoDate = era.dateYearDay(y, 1); - } - chronoDate = chronoDate.plus((aw - 1) * 7 + (ad - 1), ChronoUnit.DAYS); - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - if (standardFields.containsKey(DAY_OF_WEEK)) { - int y = Math.toIntExact(standardFields.remove(YEAR)); - int aw = Math.toIntExact(standardFields.remove(ALIGNED_WEEK_OF_YEAR)); - int dow = Math.toIntExact(standardFields.remove(DAY_OF_WEEK)); - LocalDate date; - if (chrono == IsoChronology.INSTANCE) { - date = LocalDate.of(y, 1, 1).plusDays((aw - 1) * 7).with(nextOrSame(DayOfWeek.of(dow))); - } else { - ChronoLocalDate chronoDate; - if (era == null) { - chronoDate = chrono.dateYearDay(y, 1); - } else { - chronoDate = era.dateYearDay(y, 1); - } - chronoDate = chronoDate.plus((aw - 1) * 7, ChronoUnit.DAYS).with(nextOrSame(DayOfWeek.of(dow))); - date = LocalDate.ofEpochDay(chronoDate.toEpochDay()); - } - checkDate(date); - return; - } - } - } - } - - private void checkDate(LocalDate date) { - addObject(date); - for (ChronoField field : standardFields.keySet()) { - long val1; - try { - val1 = date.getLong(field); - } catch (DateTimeException ex) { - continue; - } - Long val2 = standardFields.get(field); - if (val1 != val2) { - throw new DateTimeException("Conflict found: Field " + field + " " + val1 + " differs from " + field + " " + val2 + " derived from " + date); - } - } - } - - private void mergeTime() { - if (standardFields.containsKey(CLOCK_HOUR_OF_DAY)) { - long ch = standardFields.remove(CLOCK_HOUR_OF_DAY); - addFieldValue(HOUR_OF_DAY, ch == 24 ? 0 : ch); - } - if (standardFields.containsKey(CLOCK_HOUR_OF_AMPM)) { - long ch = standardFields.remove(CLOCK_HOUR_OF_AMPM); - addFieldValue(HOUR_OF_AMPM, ch == 12 ? 0 : ch); - } - if (standardFields.containsKey(AMPM_OF_DAY) && standardFields.containsKey(HOUR_OF_AMPM)) { - long ap = standardFields.remove(AMPM_OF_DAY); - long hap = standardFields.remove(HOUR_OF_AMPM); - addFieldValue(HOUR_OF_DAY, ap * 12 + hap); - } -// if (timeFields.containsKey(HOUR_OF_DAY) && timeFields.containsKey(MINUTE_OF_HOUR)) { -// long hod = timeFields.remove(HOUR_OF_DAY); -// long moh = timeFields.remove(MINUTE_OF_HOUR); -// addFieldValue(MINUTE_OF_DAY, hod * 60 + moh); -// } -// if (timeFields.containsKey(MINUTE_OF_DAY) && timeFields.containsKey(SECOND_OF_MINUTE)) { -// long mod = timeFields.remove(MINUTE_OF_DAY); -// long som = timeFields.remove(SECOND_OF_MINUTE); -// addFieldValue(SECOND_OF_DAY, mod * 60 + som); -// } - if (standardFields.containsKey(NANO_OF_DAY)) { - long nod = standardFields.remove(NANO_OF_DAY); - addFieldValue(SECOND_OF_DAY, nod / 1000_000_000L); - addFieldValue(NANO_OF_SECOND, nod % 1000_000_000L); - } - if (standardFields.containsKey(MICRO_OF_DAY)) { - long cod = standardFields.remove(MICRO_OF_DAY); - addFieldValue(SECOND_OF_DAY, cod / 1000_000L); - addFieldValue(MICRO_OF_SECOND, cod % 1000_000L); - } - if (standardFields.containsKey(MILLI_OF_DAY)) { - long lod = standardFields.remove(MILLI_OF_DAY); - addFieldValue(SECOND_OF_DAY, lod / 1000); - addFieldValue(MILLI_OF_SECOND, lod % 1000); - } - if (standardFields.containsKey(SECOND_OF_DAY)) { - long sod = standardFields.remove(SECOND_OF_DAY); - addFieldValue(HOUR_OF_DAY, sod / 3600); - addFieldValue(MINUTE_OF_HOUR, (sod / 60) % 60); - addFieldValue(SECOND_OF_MINUTE, sod % 60); - } - if (standardFields.containsKey(MINUTE_OF_DAY)) { - long mod = standardFields.remove(MINUTE_OF_DAY); - addFieldValue(HOUR_OF_DAY, mod / 60); - addFieldValue(MINUTE_OF_HOUR, mod % 60); - } - -// long sod = nod / 1000_000_000L; -// addFieldValue(HOUR_OF_DAY, sod / 3600); -// addFieldValue(MINUTE_OF_HOUR, (sod / 60) % 60); -// addFieldValue(SECOND_OF_MINUTE, sod % 60); -// addFieldValue(NANO_OF_SECOND, nod % 1000_000_000L); - if (standardFields.containsKey(MILLI_OF_SECOND) && standardFields.containsKey(MICRO_OF_SECOND)) { - long los = standardFields.remove(MILLI_OF_SECOND); - long cos = standardFields.get(MICRO_OF_SECOND); - addFieldValue(MICRO_OF_SECOND, los * 1000 + (cos % 1000)); - } - - Long hod = standardFields.get(HOUR_OF_DAY); - Long moh = standardFields.get(MINUTE_OF_HOUR); - Long som = standardFields.get(SECOND_OF_MINUTE); - Long nos = standardFields.get(NANO_OF_SECOND); - if (hod != null) { - int hodVal = Math.toIntExact(hod); - if (moh != null) { - int mohVal = Math.toIntExact(moh); - if (som != null) { - int somVal = Math.toIntExact(som); - if (nos != null) { - int nosVal = Math.toIntExact(nos); - addObject(LocalTime.of(hodVal, mohVal, somVal, nosVal)); - } else { - addObject(LocalTime.of(hodVal, mohVal, somVal)); - } - } else { - addObject(LocalTime.of(hodVal, mohVal)); - } - } else { - addObject(LocalTime.of(hodVal, 0)); - } - } - } - - //----------------------------------------------------------------------- - @Override - public boolean isSupported(TemporalField field) { - if (field == null) { - return false; - } - return standardFields.containsKey(field) || - (otherFields != null && otherFields.containsKey(field)) || - (date != null && date.isSupported(field)) || - (time != null && time.isSupported(field)); - } - - @Override - public long getLong(TemporalField field) { - Objects.requireNonNull(field, "field"); - Long value = getFieldValue0(field); - if (value == null) { - if (date != null && date.isSupported(field)) { - return date.getLong(field); - } - if (time != null && time.isSupported(field)) { - return time.getLong(field); - } - throw new DateTimeException("Field not found: " + field); - } - return value; - } - - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { - return (R) zone; - } else if (query == Queries.chronology()) { - return (R) chrono; - } else if (query == Queries.localDate()) { - return (R) date; - } else if (query == Queries.localTime()) { - return (R) time; - } else if (query == Queries.zone() || query == Queries.offset()) { - return query.queryFrom(this); - } else if (query == Queries.precision()) { - return null; // not a complete date/time - } - // inline TemporalAccessor.super.query(query) as an optimization - // non-JDK classes are not permitted to make this optimization - return query.queryFrom(this); - } - - //----------------------------------------------------------------------- - @Override - public String toString() { - StringBuilder buf = new StringBuilder(128); - buf.append("DateTimeBuilder["); - Map fields = new HashMap<>(); - fields.putAll(standardFields); - if (otherFields != null) { - fields.putAll(otherFields); - } - if (fields.size() > 0) { - buf.append("fields=").append(fields); - } - buf.append(", ").append(chrono); - buf.append(", ").append(zone); - buf.append(", ").append(date); - buf.append(", ").append(time); - buf.append(']'); - return buf.toString(); - } - -} diff --git a/jdk/src/share/classes/java/time/format/DateTimeFormatStyleProvider.java b/jdk/src/share/classes/java/time/format/DateTimeFormatStyleProvider.java deleted file mode 100644 index eba19f88d6e..00000000000 --- a/jdk/src/share/classes/java/time/format/DateTimeFormatStyleProvider.java +++ /dev/null @@ -1,147 +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. 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. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package java.time.format; - -import java.text.SimpleDateFormat; -import java.time.chrono.Chronology; -import java.util.Locale; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import sun.util.locale.provider.LocaleProviderAdapter; -import sun.util.locale.provider.LocaleResources; - -/** - * A provider to obtain date-time formatters for a style. - *

    - * - *

    Specification for implementors

    - * This implementation is based on extraction of data from a {@link SimpleDateFormat}. - * This class is immutable and thread-safe. - * This Implementations caches the returned formatters. - * - * @since 1.8 - */ -final class DateTimeFormatStyleProvider { - // TODO: Better implementation based on CLDR - - /** Cache of formatters. */ - private static final ConcurrentMap FORMATTER_CACHE = new ConcurrentHashMap<>(16, 0.75f, 2); - - private DateTimeFormatStyleProvider() {} - - /** - * Gets an Instance of the provider of format styles. - * - * @return the provider, not null - */ - static DateTimeFormatStyleProvider getInstance() { - return new DateTimeFormatStyleProvider(); - } - - /** - * Gets a localized date, time or date-time formatter. - *

    - * The formatter will be the most appropriate to use for the date and time style in the locale. - * For example, some locales will use the month name while others will use the number. - * - * @param dateStyle the date formatter style to obtain, null to obtain a time formatter - * @param timeStyle the time formatter style to obtain, null to obtain a date formatter - * @param chrono the chronology to use, not null - * @param locale the locale to use, not null - * @return the date-time formatter, not null - * @throws IllegalArgumentException if both format styles are null or if the locale is not recognized - */ - public DateTimeFormatter getFormatter( - FormatStyle dateStyle, FormatStyle timeStyle, Chronology chrono, Locale locale) { - if (dateStyle == null && timeStyle == null) { - throw new IllegalArgumentException("Date and Time style must not both be null"); - } - String key = chrono.getId() + '|' + locale.toString() + '|' + dateStyle + timeStyle; - Object cached = FORMATTER_CACHE.get(key); - if (cached != null) { - return (DateTimeFormatter) cached; - } - - LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale); - String pattern = lr.getCldrDateTimePattern(convertStyle(timeStyle), convertStyle(dateStyle), - chrono.getCalendarType()); - DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendPattern(pattern).toFormatter(locale); - FORMATTER_CACHE.putIfAbsent(key, formatter); - return formatter; - } - - /** - * Converts the enum style to the java.util.Calendar style. Standalone styles - * are not supported. - * - * @param style the enum style - * @return the int style, or -1 if style is null, indicating unrequired - */ - private int convertStyle(FormatStyle style) { - if (style == null) { - return -1; - } - return style.ordinal(); // indices happen to align - } - -} diff --git a/jdk/src/share/classes/java/time/format/DateTimeFormatter.java b/jdk/src/share/classes/java/time/format/DateTimeFormatter.java index 58a1c9263a9..5c6bb2336b1 100644 --- a/jdk/src/share/classes/java/time/format/DateTimeFormatter.java +++ b/jdk/src/share/classes/java/time/format/DateTimeFormatter.java @@ -79,45 +79,343 @@ import java.text.ParsePosition; import java.time.DateTimeException; import java.time.ZoneId; import java.time.ZoneOffset; -import java.time.format.DateTimeFormatterBuilder.CompositePrinterParser; import java.time.chrono.Chronology; +import java.time.chrono.IsoChronology; +import java.time.format.DateTimeFormatterBuilder.CompositePrinterParser; import java.time.temporal.ChronoField; import java.time.temporal.IsoFields; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.Set; /** * Formatter for printing and parsing date-time objects. *

    * This class provides the main application entry point for printing and parsing * and provides common implementations of {@code DateTimeFormatter}: - *

      - *
    • Using pattern letters, such as {@code yyyy-MMM-dd} - *
    • Using localized styles, such as {@code long} or {@code medium} - *
    • Using predefined constants, such as {@code ISO_LOCAL_DATE} - *

    + *
      + *
    • Using predefined constants, such as {@link #ISO_LOCAL_DATE}
    • + *
    • Using pattern letters, such as {@code uuuu-MMM-dd}
    • + *
    • Using localized styles, such as {@code long} or {@code medium}
    • + *
    + *

    + * More complex formatters are provided by + * {@link DateTimeFormatterBuilder DateTimeFormatterBuilder}. * *

    - * In most cases, provided formatters will be sufficient. - * For more complex formatters, a {@link DateTimeFormatterBuilder builder} is provided. - * The main date-time classes provide two methods - one for printing, - * {@code toString(DateTimeFormatter formatter)}, and one for parsing, + * The main date-time classes provide two methods - one for formatting, + * {@code format(DateTimeFormatter formatter)}, and one for parsing, * {@code parse(CharSequence text, DateTimeFormatter formatter)}. - * For example: - *

    + * 

    For example: + *

      *  String text = date.toString(formatter);
      *  LocalDate date = LocalDate.parse(text, formatter);
    - * 
    - * Some aspects of formatting and parsing are dependent on the locale. - * The locale can be changed using the {@link #withLocale(Locale)} method - * which returns a new formatter in the requested locale. + *
    *

    - * Some applications may need to use the older {@link Format} class for formatting. - * The {@link #toFormat()} method returns an implementation of the old API. + * In addition to the format, formatters can be created with desired Locale, + * Chronology, ZoneId, and formatting symbols. + *

    + * The {@link #withLocale withLocale} method returns a new formatter that + * overrides the locale. The locale affects some aspects of formatting and + * parsing. For example, the {@link #ofLocalizedDate ofLocalizedDate} provides a + * formatter that uses the locale specific date format. + *

    + * The {@link #withChronology withChronology} method returns a new formatter + * that overrides the chronology. If overridden, the date-time value is + * converted to the chronology before formatting. During parsing the date-time + * value is converted to the chronology before it is returned. + *

    + * The {@link #withZone withZone} method returns a new formatter that overrides + * the zone. If overridden, the date-time value is converted to a ZonedDateTime + * with the requested ZoneId before formatting. During parsing the ZoneId is + * applied before the value is returned. + *

    + * The {@link #withSymbols withSymbols} method returns a new formatter that + * overrides the {@link DateTimeFormatSymbols}. The symbols are used for + * formatting and parsing. + *

    + * Some applications may need to use the older {@link Format java.text.Format} + * class for formatting. The {@link #toFormat()} method returns an + * implementation of {@code java.text.Format}. + *

    + *

    Predefined Formatters

    + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    FormatterDescriptionExample
    {@link #ofLocalizedDate ofLocalizedDate(dateStyle)} Formatter with date style from the locale '2011-12-03'
    {@link #ofLocalizedTime ofLocalizedTime(timeStyle)} Formatter with time style from the locale '10:15:30'
    {@link #ofLocalizedDateTime ofLocalizedDateTime(dateTimeStyle)} Formatter with a style for date and time from the locale '3 Jun 2008 11:05:30'
    {@link #ofLocalizedDateTime ofLocalizedDateTime(dateStyle,timeStyle)} + * Formatter with date and time styles from the locale '3 Jun 2008 11:05'
    {@link #BASIC_ISO_DATE}Basic ISO date '20111203'
    {@link #ISO_LOCAL_DATE} ISO Local Date '2011-12-03'
    {@link #ISO_OFFSET_DATE} ISO Date with offset '2011-12-03+01:00'
    {@link #ISO_DATE} ISO Date with or without offset '2011-12-03+01:00'; '2011-12-03'
    {@link #ISO_LOCAL_TIME} Time without offset '10:15:30'
    {@link #ISO_OFFSET_TIME} Time with offset '10:15:30+01:00'
    {@link #ISO_TIME} Time with or without offset '10:15:30+01:00'; '10:15:30'
    {@link #ISO_LOCAL_DATE_TIME} ISO Local Date and Time '2011-12-03T10:15:30'
    {@link #ISO_OFFSET_DATE_TIME} Date Time with Offset + * 2011-12-03T10:15:30+01:00'
    {@link #ISO_ZONED_DATE_TIME} Zoned Date Time '2011-12-03T10:15:30+01:00[Europe/Paris]'
    {@link #ISO_DATE_TIME} Date and time with ZoneId '2011-12-03T10:15:30+01:00[Europe/Paris]'
    {@link #ISO_ORDINAL_DATE} Year and day of year '2012-337'
    {@link #ISO_WEEK_DATE} Year and Week 2012-W48-6'
    {@link #ISO_INSTANT} Date and Time of an Instant '2011-12-03T10:15:30Z'
    {@link #RFC_1123_DATE_TIME} RFC 1123 / RFC 822 'Tue, 3 Jun 2008 11:05:30 GMT'
    + * + *

    Patterns for Formatting and Parsing

    + * Patterns are based on a simple sequence of letters and symbols. + * A pattern is used to create a Formatter using the + * {@link #ofPattern(String)} and {@link #ofPattern(String, Locale)} methods. + * For example, + * {@code "d MMM uuuu"} will format 2011-12-03 as '3 Dec 2011'. + * A formatter created from a pattern can be used as many times as necessary, + * it is immutable and is thread-safe. + *

    + * For example: + *

    + *  DateTimeFormatter formatter = DateTimeFormatter.pattern("yyyy MM dd");
    + *  String text = date.toString(formatter);
    + *  LocalDate date = LocalDate.parse(text, formatter);
    + * 
    + *

    + * All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The + * following pattern letters are defined: + *

    + *  Symbol  Meaning                     Presentation      Examples
    + *  ------  -------                     ------------      -------
    + *   G       era                         text              AD; Anno Domini; A
    + *   u       year                        year              2004; 04
    + *   y       year-of-era                 year              2004; 04
    + *   D       day-of-year                 number            189
    + *   M/L     month-of-year               number/text       7; 07; Jul; July; J
    + *   d       day-of-month                number            10
    + *
    + *   Q/q     quarter-of-year             number/text       3; 03; Q3; 3rd quarter
    + *   Y       week-based-year             year              1996; 96
    + *   w       week-of-week-based-year     number            27
    + *   W       week-of-month               number            4
    + *   E       day-of-week                 text              Tue; Tuesday; T
    + *   e/c     localized day-of-week       number/text       2; 02; Tue; Tuesday; T
    + *   F       week-of-month               number            3
    + *
    + *   a       am-pm-of-day                text              PM
    + *   h       clock-hour-of-am-pm (1-12)  number            12
    + *   K       hour-of-am-pm (0-11)        number            0
    + *   k       clock-hour-of-am-pm (1-24)  number            0
    + *
    + *   H       hour-of-day (0-23)          number            0
    + *   m       minute-of-hour              number            30
    + *   s       second-of-minute            number            55
    + *   S       fraction-of-second          fraction          978
    + *   A       milli-of-day                number            1234
    + *   n       nano-of-second              number            987654321
    + *   N       nano-of-day                 number            1234000000
    + *
    + *   V       time-zone ID                zone-id           America/Los_Angeles; Z; -08:30
    + *   z       time-zone name              zone-name         Pacific Standard Time; PST
    + *   O       localized zone-offset       offset-O          GMT+8; GMT+08:00; UTC-08:00;
    + *   X       zone-offset 'Z' for zero    offset-X          Z; -08; -0830; -08:30; -083015; -08:30:15;
    + *   x       zone-offset                 offset-x          +0000; -08; -0830; -08:30; -083015; -08:30:15;
    + *   Z       zone-offset                 offset-Z          +0000; -0800; -08:00;
    + *
    + *   p       pad next                    pad modifier      1
    + *
    + *   '       escape for text             delimiter
    + *   ''      single quote                literal           '
    + *   [       optional section start
    + *   ]       optional section end
    + *   #       reserved for future use
    + *   {       reserved for future use
    + *   }       reserved for future use
    + * 
    + *

    + * The count of pattern letters determines the format. + *

    + * Text: The text style is determined based on the number of pattern + * letters used. Less than 4 pattern letters will use the + * {@link TextStyle#SHORT short form}. Exactly 4 pattern letters will use the + * {@link TextStyle#FULL full form}. Exactly 5 pattern letters will use the + * {@link TextStyle#NARROW narrow form}. + * Pattern letters 'L', 'c', and 'q' specify the stand-alone form of the text styles. + *

    + * Number: If the count of letters is one, then the value is output using + * the minimum number of digits and without padding. Otherwise, the count of digits + * is used as the width of the output field, with the value zero-padded as necessary. + * The following pattern letters have constraints on the count of letters. + * Only one letter of 'c' and 'F' can be specified. + * Up to two letters of 'd', 'H', 'h', 'K', 'k', 'm', and 's' can be specified. + * Up to three letters of 'D' can be specified. + *

    + * Number/Text: If the count of pattern letters is 3 or greater, use the + * Text rules above. Otherwise use the Number rules above. + *

    + * Fraction: Outputs the nano-of-second field as a fraction-of-second. + * The nano-of-second value has nine digits, thus the count of pattern letters + * is from 1 to 9. If it is less than 9, then the nano-of-second value is + * truncated, with only the most significant digits being output. When parsing + * in strict mode, the number of parsed digits must match the count of pattern + * letters. When parsing in lenient mode, the number of parsed digits must be at + * least the count of pattern letters, up to 9 digits. + *

    + * Year: The count of letters determines the minimum field width below + * which padding is used. If the count of letters is two, then a + * {@link DateTimeFormatterBuilder#appendValueReduced reduced} two digit form is + * used. For printing, this outputs the rightmost two digits. For parsing, this + * will parse using the base value of 2000, resulting in a year within the range + * 2000 to 2099 inclusive. If the count of letters is less than four (but not + * two), then the sign is only output for negative years as per + * {@link SignStyle#NORMAL}. Otherwise, the sign is output if the pad width is + * exceeded, as per {@link SignStyle#EXCEEDS_PAD}. + *

    + * ZoneId: This outputs the time-zone ID, such as 'Europe/Paris'. If the + * count of letters is two, then the time-zone ID is output. Any other count of + * letters throws {@code IllegalArgumentException}. + *

    + * Zone names: This outputs the display name of the time-zone ID. If the + * count of letters is one, two or three, then the short name is output. If the + * count of letters is four, then the full name is output. Five or more letters + * throws {@code IllegalArgumentException}. + *

    + * Offset X and x: This formats the offset based on the number of pattern + * letters. One letter outputs just the hour, such as '+01', unless the minute + * is non-zero in which case the minute is also output, such as '+0130'. Two + * letters outputs the hour and minute, without a colon, such as '+0130'. Three + * letters outputs the hour and minute, with a colon, such as '+01:30'. Four + * letters outputs the hour and minute and optional second, without a colon, + * such as '+013015'. Five letters outputs the hour and minute and optional + * second, with a colon, such as '+01:30:15'. Six or more letters throws + * {@code IllegalArgumentException}. Pattern letter 'X' (upper case) will output + * 'Z' when the offset to be output would be zero, whereas pattern letter 'x' + * (lower case) will output '+00', '+0000', or '+00:00'. + *

    + * Offset O: This formats the localized offset based on the number of + * pattern letters. One letter outputs the {@linkplain TextStyle#SHORT short} + * form of the localized offset, which is localized offset text, such as 'GMT', + * with hour without leading zero, optional 2-digit minute and second if + * non-zero, and colon, for example 'GMT+8'. Four letters outputs the + * {@linkplain TextStyle#FULL full} form, which is localized offset text, + * such as 'GMT, with 2-digit hour and minute field, optional second field + * if non-zero, and colon, for example 'GMT+08:00'. Any other count of letters + * throws {@code IllegalArgumentException}. + *

    + * Offset Z: This formats the offset based on the number of pattern + * letters. One, two or three letters outputs the hour and minute, without a + * colon, such as '+0130'. The output will be '+0000' when the offset is zero. + * Four letters outputs the {@linkplain TextStyle#FULL full} form of localized + * offset, equivalent to four letters of Offset-O. The output will be the + * corresponding localized offset text if the offset is zero. Five + * letters outputs the hour, minute, with optional second if non-zero, with + * colon. It outputs 'Z' if the offset is zero. + * Six or more letters throws {@code IllegalArgumentException}. + *

    + * Optional section: The optional section markers work exactly like + * calling {@link DateTimeFormatterBuilder#optionalStart()} and + * {@link DateTimeFormatterBuilder#optionalEnd()}. + *

    + * Pad modifier: Modifies the pattern that immediately follows to be + * padded with spaces. The pad width is determined by the number of pattern + * letters. This is the same as calling + * {@link DateTimeFormatterBuilder#padNext(int)}. + *

    + * For example, 'ppH' outputs the hour-of-day padded on the left with spaces to + * a width of 2. + *

    + * Any unrecognized letter is an error. Any non-letter character, other than + * '[', ']', '{', '}', '#' and the single quote will be output directly. + * Despite this, it is recommended to use single quotes around all characters + * that you want to output directly to ensure that future changes do not break + * your application. * *

    Specification for implementors

    * This class is immutable and thread-safe. @@ -138,6 +436,14 @@ public final class DateTimeFormatter { * The symbols to use for formatting, not null. */ private final DateTimeFormatSymbols symbols; + /** + * The resolver style to use, not null. + */ + private final ResolverStyle resolverStyle; + /** + * The fields to use in resolving, null for all fields. + */ + private final Set resolverFields; /** * The chronology to use for formatting, null for no override. */ @@ -151,129 +457,17 @@ public final class DateTimeFormatter { /** * Creates a formatter using the specified pattern. *

    - * This method will create a formatter based on a simple pattern of letters and symbols. - * For example, {@code d MMM yyyy} will format 2011-12-03 as '3 Dec 2011'. + * This method will create a formatter based on a simple + * pattern of letters and symbols + * as described in the class documentation. + * For example, {@code d MMM uuuu} will format 2011-12-03 as '3 Dec 2011'. *

    - * The returned formatter will use the default locale, but this can be changed - * using {@link DateTimeFormatter#withLocale(Locale)}. + * The formatter will use the {@link Locale#getDefault(Locale.Category) default FORMAT locale}. + * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter + * Alternatively use the {@link #ofPattern(String, Locale)} variant of this method. *

    - * All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. - * The following pattern letters are defined: - *

    -     *  Symbol  Meaning                     Presentation      Examples
    -     *  ------  -------                     ------------      -------
    -     *   G       era                         text              A; AD; Anno Domini
    -     *   y       year                        year              2004; 04
    -     *   D       day-of-year                 number            189
    -     *   M       month-of-year               number/text       7; 07; Jul; July; J
    -     *   d       day-of-month                number            10
    -     *
    -     *   Q       quarter-of-year             number/text       3; 03; Q3
    -     *   Y       week-based-year             year              1996; 96
    -     *   w       week-of-year                number            27
    -     *   W       week-of-month               number            27
    -     *   e       localized day-of-week       number            2; Tue; Tuesday; T
    -     *   E       day-of-week                 number/text       2; Tue; Tuesday; T
    -     *   F       week-of-month               number            3
    -     *
    -     *   a       am-pm-of-day                text              PM
    -     *   h       clock-hour-of-am-pm (1-12)  number            12
    -     *   K       hour-of-am-pm (0-11)        number            0
    -     *   k       clock-hour-of-am-pm (1-24)  number            0
    -     *
    -     *   H       hour-of-day (0-23)          number            0
    -     *   m       minute-of-hour              number            30
    -     *   s       second-of-minute            number            55
    -     *   S       fraction-of-second          fraction          978
    -     *   A       milli-of-day                number            1234
    -     *   n       nano-of-second              number            987654321
    -     *   N       nano-of-day                 number            1234000000
    -     *
    -     *   V       time-zone ID                zone-id           America/Los_Angeles; Z; -08:30
    -     *   z       time-zone name              zone-name         Pacific Standard Time; PST
    -     *   X       zone-offset 'Z' for zero    offset-X          Z; -08; -0830; -08:30; -083015; -08:30:15;
    -     *   x       zone-offset                 offset-x          +0000; -08; -0830; -08:30; -083015; -08:30:15;
    -     *   Z       zone-offset                 offset-Z          +0000; -0800; -08:00;
    -     *
    -     *   p       pad next                    pad modifier      1
    -     *
    -     *   '       escape for text             delimiter
    -     *   ''      single quote                literal           '
    -     *   [       optional section start
    -     *   ]       optional section end
    -     *   {}      reserved for future use
    -     * 
    - *

    - * The count of pattern letters determine the format. - *

    - * Text: The text style is determined based on the number of pattern letters used. - * Less than 4 pattern letters will use the {@link TextStyle#SHORT short form}. - * Exactly 4 pattern letters will use the {@link TextStyle#FULL full form}. - * Exactly 5 pattern letters will use the {@link TextStyle#NARROW narrow form}. - *

    - * Number: If the count of letters is one, then the value is output using the minimum number - * of digits and without padding as per {@link DateTimeFormatterBuilder#appendValue(java.time.temporal.TemporalField)}. - * Otherwise, the count of digits is used as the width of the output field as per - * {@link DateTimeFormatterBuilder#appendValue(java.time.temporal.TemporalField, int)}. - *

    - * Number/Text: If the count of pattern letters is 3 or greater, use the Text rules above. - * Otherwise use the Number rules above. - *

    - * Fraction: Outputs the nano-of-second field as a fraction-of-second. - * The nano-of-second value has nine digits, thus the count of pattern letters is from 1 to 9. - * If it is less than 9, then the nano-of-second value is truncated, with only the most - * significant digits being output. - * When parsing in strict mode, the number of parsed digits must match the count of pattern letters. - * When parsing in lenient mode, the number of parsed digits must be at least the count of pattern - * letters, up to 9 digits. - *

    - * Year: The count of letters determines the minimum field width below which padding is used. - * If the count of letters is two, then a {@link DateTimeFormatterBuilder#appendValueReduced reduced} - * two digit form is used. - * For printing, this outputs the rightmost two digits. For parsing, this will parse using the - * base value of 2000, resulting in a year within the range 2000 to 2099 inclusive. - * If the count of letters is less than four (but not two), then the sign is only output for negative - * years as per {@link SignStyle#NORMAL}. - * Otherwise, the sign is output if the pad width is exceeded, as per {@link SignStyle#EXCEEDS_PAD} - *

    - * ZoneId: This outputs the time-zone ID, such as 'Europe/Paris'. - * If the count of letters is two, then the time-zone ID is output. - * Any other count of letters throws {@code IllegalArgumentException}. - *

    - * Zone names: This outputs the display name of the time-zone ID. - * If the count of letters is one, two or three, then the short name is output. - * If the count of letters is four, then the full name is output. - * Five or more letters throws {@code IllegalArgumentException}. - *

    - * Offset X and x: This formats the offset based on the number of pattern letters. - * One letter outputs just the hour', such as '+01', unless the minute is non-zero - * in which case the minute is also output, such as '+0130'. - * Two letters outputs the hour and minute, without a colon, such as '+0130'. - * Three letters outputs the hour and minute, with a colon, such as '+01:30'. - * Four letters outputs the hour and minute and optional second, without a colon, such as '+013015'. - * Five letters outputs the hour and minute and optional second, with a colon, such as '+01:30:15'. - * Six or more letters throws {@code IllegalArgumentException}. - * Pattern letter 'X' (upper case) will output 'Z' when the offset to be output would be zero, - * whereas pattern letter 'x' (lower case) will output '+00', '+0000', or '+00:00'. - *

    - * Offset Z: This formats the offset based on the number of pattern letters. - * One, two or three letters outputs the hour and minute, without a colon, such as '+0130'. - * Four or more letters throws {@code IllegalArgumentException}. - * The output will be '+0000' when the offset is zero. - *

    - * Optional section: The optional section markers work exactly like calling - * {@link DateTimeFormatterBuilder#optionalStart()} and {@link DateTimeFormatterBuilder#optionalEnd()}. - *

    - * Pad modifier: Modifies the pattern that immediately follows to be padded with spaces. - * The pad width is determined by the number of pattern letters. - * This is the same as calling {@link DateTimeFormatterBuilder#padNext(int)}. - *

    - * For example, 'ppH' outputs the hour-of-day padded on the left with spaces to a width of 2. - *

    - * Any unrecognized letter is an error. - * Any non-letter character, other than '[', ']', '{', '}' and the single quote will be output directly. - * Despite this, it is recommended to use single quotes around all characters that you want to - * output directly to ensure that future changes do not break your application. + * The returned formatter has no override chronology or zone. + * It uses {@link ResolverStyle#SMART SMART} resolver style. * * @param pattern the pattern to use, not null * @return the formatter based on the pattern, not null @@ -285,15 +479,18 @@ public final class DateTimeFormatter { } /** - * Creates a formatter using the specified pattern. + * Creates a formatter using the specified pattern and locale. *

    - * This method will create a formatter based on a simple pattern of letters and symbols. - * For example, {@code d MMM yyyy} will format 2011-12-03 as '3 Dec 2011'. + * This method will create a formatter based on a simple + * pattern of letters and symbols + * as described in the class documentation. + * For example, {@code d MMM uuuu} will format 2011-12-03 as '3 Dec 2011'. *

    - * See {@link #ofPattern(String)} for details of the pattern. + * The formatter will use the specified locale. + * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter *

    - * The returned formatter will use the specified locale, but this can be changed - * using {@link DateTimeFormatter#withLocale(Locale)}. + * The returned formatter has no override chronology or zone. + * It uses {@link ResolverStyle#SMART SMART} resolver style. * * @param pattern the pattern to use, not null * @param locale the locale to use, not null @@ -307,7 +504,7 @@ public final class DateTimeFormatter { //----------------------------------------------------------------------- /** - * Returns a locale specific date format. + * Returns a locale specific date format for the ISO chronology. *

    * This returns a formatter that will format or parse a date. * The exact format pattern used varies by locale. @@ -320,17 +517,22 @@ public final class DateTimeFormatter { * Note that the localized pattern is looked up lazily. * This {@code DateTimeFormatter} holds the style required and the locale, * looking up the pattern required on demand. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. * * @param dateStyle the formatter style to obtain, not null * @return the date formatter, not null */ public static DateTimeFormatter ofLocalizedDate(FormatStyle dateStyle) { Objects.requireNonNull(dateStyle, "dateStyle"); - return new DateTimeFormatterBuilder().appendLocalized(dateStyle, null).toFormatter(); + return new DateTimeFormatterBuilder().appendLocalized(dateStyle, null) + .toFormatter(ResolverStyle.SMART, IsoChronology.INSTANCE); } /** - * Returns a locale specific time format. + * Returns a locale specific time format for the ISO chronology. *

    * This returns a formatter that will format or parse a time. * The exact format pattern used varies by locale. @@ -343,17 +545,22 @@ public final class DateTimeFormatter { * Note that the localized pattern is looked up lazily. * This {@code DateTimeFormatter} holds the style required and the locale, * looking up the pattern required on demand. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. * * @param timeStyle the formatter style to obtain, not null * @return the time formatter, not null */ public static DateTimeFormatter ofLocalizedTime(FormatStyle timeStyle) { Objects.requireNonNull(timeStyle, "timeStyle"); - return new DateTimeFormatterBuilder().appendLocalized(null, timeStyle).toFormatter(); + return new DateTimeFormatterBuilder().appendLocalized(null, timeStyle) + .toFormatter(ResolverStyle.SMART, IsoChronology.INSTANCE); } /** - * Returns a locale specific date-time formatter, which is typically of short length. + * Returns a locale specific date-time formatter for the ISO chronology. *

    * This returns a formatter that will format or parse a date-time. * The exact format pattern used varies by locale. @@ -366,17 +573,22 @@ public final class DateTimeFormatter { * Note that the localized pattern is looked up lazily. * This {@code DateTimeFormatter} holds the style required and the locale, * looking up the pattern required on demand. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. * * @param dateTimeStyle the formatter style to obtain, not null * @return the date-time formatter, not null */ public static DateTimeFormatter ofLocalizedDateTime(FormatStyle dateTimeStyle) { Objects.requireNonNull(dateTimeStyle, "dateTimeStyle"); - return new DateTimeFormatterBuilder().appendLocalized(dateTimeStyle, dateTimeStyle).toFormatter(); + return new DateTimeFormatterBuilder().appendLocalized(dateTimeStyle, dateTimeStyle) + .toFormatter(ResolverStyle.SMART, IsoChronology.INSTANCE); } /** - * Returns a locale specific date and time format. + * Returns a locale specific date and time format for the ISO chronology. *

    * This returns a formatter that will format or parse a date-time. * The exact format pattern used varies by locale. @@ -389,6 +601,10 @@ public final class DateTimeFormatter { * Note that the localized pattern is looked up lazily. * This {@code DateTimeFormatter} holds the style required and the locale, * looking up the pattern required on demand. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. * * @param dateStyle the date formatter style to obtain, not null * @param timeStyle the time formatter style to obtain, not null @@ -397,13 +613,14 @@ public final class DateTimeFormatter { public static DateTimeFormatter ofLocalizedDateTime(FormatStyle dateStyle, FormatStyle timeStyle) { Objects.requireNonNull(dateStyle, "dateStyle"); Objects.requireNonNull(timeStyle, "timeStyle"); - return new DateTimeFormatterBuilder().appendLocalized(dateStyle, timeStyle).toFormatter(); + return new DateTimeFormatterBuilder().appendLocalized(dateStyle, timeStyle) + .toFormatter(ResolverStyle.SMART, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date without an offset, - * such as '2011-12-03'. + * The ISO date formatter that formats or parses a date without an + * offset, such as '2011-12-03'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended local date format. @@ -418,23 +635,27 @@ public final class DateTimeFormatter { *

  • A dash *
  • Two digits for the {@link ChronoField#DAY_OF_MONTH day-of-month}. * This is pre-padded by zero to ensure two digits. - *

    + * + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_LOCAL_DATE; static { ISO_LOCAL_DATE = new DateTimeFormatterBuilder() - .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD) - .appendLiteral('-') - .appendValue(MONTH_OF_YEAR, 2) - .appendLiteral('-') - .appendValue(DAY_OF_MONTH, 2) - .toFormatter(); + .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD) + .appendLiteral('-') + .appendValue(MONTH_OF_YEAR, 2) + .appendLiteral('-') + .appendValue(DAY_OF_MONTH, 2) + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date with an offset, - * such as '2011-12-03+01:00'. + * The ISO date formatter that formats or parses a date with an + * offset, such as '2011-12-03+01:00'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended offset date format. @@ -444,20 +665,24 @@ public final class DateTimeFormatter { *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_OFFSET_DATE; static { ISO_OFFSET_DATE = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_DATE) - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_DATE) + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date with the + * The ISO date formatter that formats or parses a date with the * offset if available, such as '2011-12-03' or '2011-12-03+01:00'. *

    * This returns an immutable formatter capable of formatting and parsing @@ -469,25 +694,29 @@ public final class DateTimeFormatter { *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_DATE; static { ISO_DATE = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_DATE) - .optionalStart() - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_DATE) + .optionalStart() + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO time formatter that formats or parses a time without an offset, - * such as '10:15' or '10:15:30'. + * The ISO time formatter that formats or parses a time without an + * offset, such as '10:15' or '10:15:30'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended local time format. @@ -506,26 +735,29 @@ public final class DateTimeFormatter { *

  • A decimal point *
  • One to nine digits for the {@link ChronoField#NANO_OF_SECOND nano-of-second}. * As many digits will be output as required. - *

    + * + *

    + * The returned formatter has no override chronology or zone. + * It uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_LOCAL_TIME; static { ISO_LOCAL_TIME = new DateTimeFormatterBuilder() - .appendValue(HOUR_OF_DAY, 2) - .appendLiteral(':') - .appendValue(MINUTE_OF_HOUR, 2) - .optionalStart() - .appendLiteral(':') - .appendValue(SECOND_OF_MINUTE, 2) - .optionalStart() - .appendFraction(NANO_OF_SECOND, 0, 9, true) - .toFormatter(); + .appendValue(HOUR_OF_DAY, 2) + .appendLiteral(':') + .appendValue(MINUTE_OF_HOUR, 2) + .optionalStart() + .appendLiteral(':') + .appendValue(SECOND_OF_MINUTE, 2) + .optionalStart() + .appendFraction(NANO_OF_SECOND, 0, 9, true) + .toFormatter(ResolverStyle.STRICT, null); } //----------------------------------------------------------------------- /** - * Returns the ISO time formatter that formats or parses a time with an offset, - * such as '10:15+01:00' or '10:15:30+01:00'. + * The ISO time formatter that formats or parses a time with an + * offset, such as '10:15+01:00' or '10:15:30+01:00'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended offset time format. @@ -535,20 +767,23 @@ public final class DateTimeFormatter { *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * + *

    + * The returned formatter has no override chronology or zone. + * It uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_OFFSET_TIME; static { ISO_OFFSET_TIME = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_TIME) - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_TIME) + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, null); } //----------------------------------------------------------------------- /** - * Returns the ISO time formatter that formats or parses a time, with the + * The ISO time formatter that formats or parses a time, with the * offset if available, such as '10:15', '10:15:30' or '10:15:30+01:00'. *

    * This returns an immutable formatter capable of formatting and parsing @@ -560,25 +795,28 @@ public final class DateTimeFormatter { *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has no override chronology or zone. + * It uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_TIME; static { ISO_TIME = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_TIME) - .optionalStart() - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_TIME) + .optionalStart() + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, null); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date-time - * without an offset, such as '2011-12-03T10:15:30'. + * The ISO date-time formatter that formats or parses a date-time without + * an offset, such as '2011-12-03T10:15:30'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended offset date-time format. @@ -587,22 +825,26 @@ public final class DateTimeFormatter { *

  • The {@link #ISO_LOCAL_DATE} *
  • The letter 'T'. Parsing is case insensitive. *
  • The {@link #ISO_LOCAL_TIME} - *

    + * + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_LOCAL_DATE_TIME; static { ISO_LOCAL_DATE_TIME = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_DATE) - .appendLiteral('T') - .append(ISO_LOCAL_TIME) - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_DATE) + .appendLiteral('T') + .append(ISO_LOCAL_TIME) + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date-time - * with an offset, such as '2011-12-03T10:15:30+01:00'. + * The ISO date-time formatter that formats or parses a date-time with an + * offset, such as '2011-12-03T10:15:30+01:00'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 extended offset date-time format. @@ -612,25 +854,30 @@ public final class DateTimeFormatter { *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_OFFSET_DATE_TIME; static { ISO_OFFSET_DATE_TIME = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .append(ISO_LOCAL_DATE_TIME) - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .append(ISO_LOCAL_DATE_TIME) + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date-time with + * The ISO-like date-time formatter that formats or parses a date-time with * offset and zone, such as '2011-12-03T10:15:30+01:00[Europe/Paris]'. *

    * This returns an immutable formatter capable of formatting and parsing * a format that extends the ISO-8601 extended offset date-time format * to add the time-zone. + * The section in square brackets is not part of the ISO-8601 standard. * The format consists of: *

      *
    • The {@link #ISO_OFFSET_DATE_TIME} @@ -639,28 +886,33 @@ public final class DateTimeFormatter { *
    • The {@link ZoneId#getId() zone ID}. This is not part of the ISO-8601 standard. * Parsing is case sensitive. *
    • A close square bracket ']'. - *

    + * + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_ZONED_DATE_TIME; static { ISO_ZONED_DATE_TIME = new DateTimeFormatterBuilder() - .append(ISO_OFFSET_DATE_TIME) - .optionalStart() - .appendLiteral('[') - .parseCaseSensitive() - .appendZoneRegionId() - .appendLiteral(']') - .toFormatter(); + .append(ISO_OFFSET_DATE_TIME) + .optionalStart() + .appendLiteral('[') + .parseCaseSensitive() + .appendZoneRegionId() + .appendLiteral(']') + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date-time - * with the offset and zone if available, such as '2011-12-03T10:15:30', + * The ISO-like date-time formatter that formats or parses a date-time with + * the offset and zone if available, such as '2011-12-03T10:15:30', * '2011-12-03T10:15:30+01:00' or '2011-12-03T10:15:30+01:00[Europe/Paris]'. *

    * This returns an immutable formatter capable of formatting and parsing - * the ISO-8601 extended offset date-time format. + * the ISO-8601 extended local or offset date-time format, as well as the + * extended non-ISO form specifying the time-zone. * The format consists of: *

      *
    • The {@link #ISO_LOCAL_DATE_TIME} @@ -672,28 +924,32 @@ public final class DateTimeFormatter { *
    • The {@link ZoneId#getId() zone ID}. This is not part of the ISO-8601 standard. * Parsing is case sensitive. *
    • A close square bracket ']'. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_DATE_TIME; static { ISO_DATE_TIME = new DateTimeFormatterBuilder() - .append(ISO_LOCAL_DATE_TIME) - .optionalStart() - .appendOffsetId() - .optionalStart() - .appendLiteral('[') - .parseCaseSensitive() - .appendZoneRegionId() - .appendLiteral(']') - .toFormatter(); + .append(ISO_LOCAL_DATE_TIME) + .optionalStart() + .appendOffsetId() + .optionalStart() + .appendLiteral('[') + .parseCaseSensitive() + .appendZoneRegionId() + .appendLiteral(']') + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses the ordinal date + * The ISO date formatter that formats or parses the ordinal date * without an offset, such as '2012-337'. *

    * This returns an immutable formatter capable of formatting and parsing @@ -710,26 +966,30 @@ public final class DateTimeFormatter { *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_ORDINAL_DATE; static { ISO_ORDINAL_DATE = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD) - .appendLiteral('-') - .appendValue(DAY_OF_YEAR, 3) - .optionalStart() - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD) + .appendLiteral('-') + .appendValue(DAY_OF_YEAR, 3) + .optionalStart() + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses the week-based date + * The ISO date formatter that formats or parses the week-based date * without an offset, such as '2012-W48-6'. *

    * This returns an immutable formatter capable of formatting and parsing @@ -750,50 +1010,67 @@ public final class DateTimeFormatter { *

  • The {@link ZoneOffset#getId() offset ID}. If the offset has seconds then * they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_WEEK_DATE; static { ISO_WEEK_DATE = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .appendValue(IsoFields.WEEK_BASED_YEAR, 4, 10, SignStyle.EXCEEDS_PAD) - .appendLiteral("-W") - .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 2) - .appendLiteral('-') - .appendValue(DAY_OF_WEEK, 1) - .optionalStart() - .appendOffsetId() - .toFormatter(); + .parseCaseInsensitive() + .appendValue(IsoFields.WEEK_BASED_YEAR, 4, 10, SignStyle.EXCEEDS_PAD) + .appendLiteral("-W") + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR, 2) + .appendLiteral('-') + .appendValue(DAY_OF_WEEK, 1) + .optionalStart() + .appendOffsetId() + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- /** - * Returns the ISO instant formatter that formats or parses an instant in UTC. + * The ISO instant formatter that formats or parses an instant in UTC, + * such as '2011-12-03T10:15:30Z'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 instant format. + *

    + * This is a special case formatter intended to allow a human readable form + * of an {@link java.time.Instant}. The {@code Instant} class is designed to + * only represent a point in time and internally stores a value in nanoseconds + * from a fixed epoch of 1970-01-01Z. As such, an {@code Instant} cannot be + * formatted as a date or time without providing some form of time-zone. + * This formatter allows the {@code Instant} to be formatted, by providing + * a suitable conversion using {@code ZoneOffset.UTC}. + *

    * The format consists of: *

      *
    • The {@link #ISO_OFFSET_DATE_TIME} where the instant is converted from * {@link ChronoField#INSTANT_SECONDS} and {@link ChronoField#NANO_OF_SECOND} * using the {@code UTC} offset. Parsing is case insensitive. - *

    + * + *

    + * The returned formatter has no override chronology or zone. + * It uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter ISO_INSTANT; static { ISO_INSTANT = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .appendInstant() - .toFormatter(); + .parseCaseInsensitive() + .appendInstant() + .toFormatter(ResolverStyle.STRICT, null); } //----------------------------------------------------------------------- /** - * Returns the ISO date formatter that formats or parses a date without an offset, - * such as '20111203'. + * The ISO date formatter that formats or parses a date without an + * offset, such as '20111203'. *

    * This returns an immutable formatter capable of formatting and parsing * the ISO-8601 basic local date format. @@ -809,21 +1086,25 @@ public final class DateTimeFormatter { *

  • The {@link ZoneOffset#getId() offset ID} without colons. If the offset has * seconds then they will be handled even though this is not part of the ISO-8601 standard. * Parsing is case insensitive. - *

    + * *

    * As this formatter has an optional element, it may be necessary to parse using * {@link DateTimeFormatter#parseBest}. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#STRICT STRICT} resolver style. */ public static final DateTimeFormatter BASIC_ISO_DATE; static { BASIC_ISO_DATE = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .appendValue(YEAR, 4) - .appendValue(MONTH_OF_YEAR, 2) - .appendValue(DAY_OF_MONTH, 2) - .optionalStart() - .appendOffset("+HHMMss", "Z") - .toFormatter(); + .parseCaseInsensitive() + .appendValue(YEAR, 4) + .appendValue(MONTH_OF_YEAR, 2) + .appendValue(DAY_OF_MONTH, 2) + .optionalStart() + .appendOffset("+HHMMss", "Z") + .toFormatter(ResolverStyle.STRICT, IsoChronology.INSTANCE); } //----------------------------------------------------------------------- @@ -862,9 +1143,13 @@ public final class DateTimeFormatter { *

  • A space *
  • The {@link ZoneOffset#getId() offset ID} without colons or seconds. * An offset of zero uses "GMT". North American zone names and military zone names are not handled. - *

    + * *

    * Parsing is case insensitive. + *

    + * The returned formatter has a chronology of ISO set to ensure dates in + * other calendar systems are correctly converted. + * It has no override zone and uses the {@link ResolverStyle#SMART SMART} resolver style. */ public static final DateTimeFormatter RFC_1123_DATE_TIME; static { @@ -892,28 +1177,28 @@ public final class DateTimeFormatter { moy.put(11L, "Nov"); moy.put(12L, "Dec"); RFC_1123_DATE_TIME = new DateTimeFormatterBuilder() - .parseCaseInsensitive() - .parseLenient() - .optionalStart() - .appendText(DAY_OF_WEEK, dow) - .appendLiteral(", ") - .optionalEnd() - .appendValue(DAY_OF_MONTH, 1, 2, SignStyle.NOT_NEGATIVE) - .appendLiteral(' ') - .appendText(MONTH_OF_YEAR, moy) - .appendLiteral(' ') - .appendValue(YEAR, 4) // 2 digit year not handled - .appendLiteral(' ') - .appendValue(HOUR_OF_DAY, 2) - .appendLiteral(':') - .appendValue(MINUTE_OF_HOUR, 2) - .optionalStart() - .appendLiteral(':') - .appendValue(SECOND_OF_MINUTE, 2) - .optionalEnd() - .appendLiteral(' ') - .appendOffset("+HHMM", "GMT") // should handle UT/Z/EST/EDT/CST/CDT/MST/MDT/PST/MDT - .toFormatter(); + .parseCaseInsensitive() + .parseLenient() + .optionalStart() + .appendText(DAY_OF_WEEK, dow) + .appendLiteral(", ") + .optionalEnd() + .appendValue(DAY_OF_MONTH, 1, 2, SignStyle.NOT_NEGATIVE) + .appendLiteral(' ') + .appendText(MONTH_OF_YEAR, moy) + .appendLiteral(' ') + .appendValue(YEAR, 4) // 2 digit year not handled + .appendLiteral(' ') + .appendValue(HOUR_OF_DAY, 2) + .appendLiteral(':') + .appendValue(MINUTE_OF_HOUR, 2) + .optionalStart() + .appendLiteral(':') + .appendValue(SECOND_OF_MINUTE, 2) + .optionalEnd() + .appendLiteral(' ') + .appendOffset("+HHMM", "GMT") // should handle UT/Z/EST/EDT/CST/CDT/MST/MDT/PST/MDT + .toFormatter(ResolverStyle.SMART, IsoChronology.INSTANCE); } /** @@ -922,14 +1207,20 @@ public final class DateTimeFormatter { * @param printerParser the printer/parser to use, not null * @param locale the locale to use, not null * @param symbols the symbols to use, not null + * @param resolverStyle the resolver style to use, not null + * @param resolverFields the fields to use during resolving, null for all fields * @param chrono the chronology to use, null for no override * @param zone the zone to use, null for no override */ - DateTimeFormatter(CompositePrinterParser printerParser, Locale locale, - DateTimeFormatSymbols symbols, Chronology chrono, ZoneId zone) { + DateTimeFormatter(CompositePrinterParser printerParser, + Locale locale, DateTimeFormatSymbols symbols, + ResolverStyle resolverStyle, Set resolverFields, + Chronology chrono, ZoneId zone) { this.printerParser = Objects.requireNonNull(printerParser, "printerParser"); + this.resolverFields = resolverFields; this.locale = Objects.requireNonNull(locale, "locale"); this.symbols = Objects.requireNonNull(symbols, "symbols"); + this.resolverStyle = Objects.requireNonNull(resolverStyle, "resolverStyle"); this.chrono = chrono; this.zone = zone; } @@ -962,7 +1253,7 @@ public final class DateTimeFormatter { if (this.locale.equals(locale)) { return this; } - return new DateTimeFormatter(printerParser, locale, symbols, chrono, zone); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); } //----------------------------------------------------------------------- @@ -987,7 +1278,7 @@ public final class DateTimeFormatter { if (this.symbols.equals(symbols)) { return this; } - return new DateTimeFormatter(printerParser, locale, symbols, chrono, zone); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); } //----------------------------------------------------------------------- @@ -998,7 +1289,7 @@ public final class DateTimeFormatter { * By default, a formatter has no override chronology, returning null. * See {@link #withChronology(Chronology)} for more details on overriding. * - * @return the chronology of this formatter, null if no override + * @return the override chronology of this formatter, null if no override */ public Chronology getChronology() { return chrono; @@ -1013,26 +1304,35 @@ public final class DateTimeFormatter { *

    * If an override is added, then any date that is formatted or parsed will be affected. *

    - * When formatting, if the {@code Temporal} object contains a date then it will + * When formatting, if the temporal object contains a date, then it will * be converted to a date in the override chronology. - * Any time or zone will be retained unless overridden. - * The converted result will behave in a manner equivalent to an implementation - * of {@code ChronoLocalDate},{@code ChronoLocalDateTime} or {@code ChronoZonedDateTime}. + * Whether the temporal contains a date is determined by querying the + * {@link ChronoField#EPOCH_DAY EPOCH_DAY} field. + * Any time or zone will be retained unaltered unless overridden. *

    - * When parsing, the override chronology will be used to interpret the - * {@link java.time.temporal.ChronoField fields} into a date unless the - * formatter directly parses a valid chronology. + * If the temporal object does not contain a date, but does contain one + * or more {@code ChronoField} date fields, then a {@code DateTimeException} + * is thrown. In all other cases, the override chronology is added to the temporal, + * replacing any previous chronology, but without changing the date/time. + *

    + * When parsing, there are two distinct cases to consider. + * If a chronology has been parsed directly from the text, perhaps because + * {@link DateTimeFormatterBuilder#appendChronologyId()} was used, then + * this override chronology has no effect. + * If no zone has been parsed, then this override chronology will be used + * to interpret the {@code ChronoField} values into a date according to the + * date resolving rules of the chronology. *

    * This instance is immutable and unaffected by this method call. * - * @param chrono the new chronology, not null + * @param chrono the new chronology, null if no override * @return a formatter based on this formatter with the requested override chronology, not null */ public DateTimeFormatter withChronology(Chronology chrono) { if (Objects.equals(this.chrono, chrono)) { return this; } - return new DateTimeFormatter(printerParser, locale, symbols, chrono, zone); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); } //----------------------------------------------------------------------- @@ -1043,7 +1343,7 @@ public final class DateTimeFormatter { * By default, a formatter has no override zone, returning null. * See {@link #withZone(ZoneId)} for more details on overriding. * - * @return the chronology of this formatter, null if no override + * @return the override zone of this formatter, null if no override */ public ZoneId getZone() { return zone; @@ -1058,28 +1358,192 @@ public final class DateTimeFormatter { *

    * If an override is added, then any instant that is formatted or parsed will be affected. *

    - * When formatting, if the {@code Temporal} object contains an instant then it will + * When formatting, if the temporal object contains an instant, then it will * be converted to a zoned date-time using the override zone. + * Whether the temporal is an instant is determined by querying the + * {@link ChronoField#INSTANT_SECONDS INSTANT_SECONDS} field. * If the input has a chronology then it will be retained unless overridden. * If the input does not have a chronology, such as {@code Instant}, then * the ISO chronology will be used. - * The converted result will behave in a manner equivalent to an implementation - * of {@code ChronoZonedDateTime}. *

    - * When parsing, the override zone will be used to interpret the - * {@link java.time.temporal.ChronoField fields} into an instant unless the - * formatter directly parses a valid zone. + * If the temporal object does not contain an instant, but does contain + * an offset then an additional check is made. If the normalized override + * zone is an offset that differs from the offset of the temporal, then + * a {@code DateTimeException} is thrown. In all other cases, the override + * zone is added to the temporal, replacing any previous zone, but without + * changing the date/time. + *

    + * When parsing, there are two distinct cases to consider. + * If a zone has been parsed directly from the text, perhaps because + * {@link DateTimeFormatterBuilder#appendZoneId()} was used, then + * this override zone has no effect. + * If no zone has been parsed, then this override zone will be included in + * the result of the parse where it can be used to build instants and date-times. *

    * This instance is immutable and unaffected by this method call. * - * @param zone the new override zone, not null + * @param zone the new override zone, null if no override * @return a formatter based on this formatter with the requested override zone, not null */ public DateTimeFormatter withZone(ZoneId zone) { if (Objects.equals(this.zone, zone)) { return this; } - return new DateTimeFormatter(printerParser, locale, symbols, chrono, zone); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); + } + + //----------------------------------------------------------------------- + /** + * Gets the resolver style to use during parsing. + *

    + * This returns the resolver style, used during the second phase of parsing + * when fields are resolved into dates and times. + * By default, a formatter has the {@link ResolverStyle#SMART SMART} resolver style. + * See {@link #withResolverStyle(ResolverStyle)} for more details. + * + * @return the resolver style of this formatter, not null + */ + public ResolverStyle getResolverStyle() { + return resolverStyle; + } + + /** + * Returns a copy of this formatter with a new resolver style. + *

    + * This returns a formatter with similar state to this formatter but + * with the resolver style set. By default, a formatter has the + * {@link ResolverStyle#SMART SMART} resolver style. + *

    + * Changing the resolver style only has an effect during parsing. + * Parsing a text string occurs in two phases. + * Phase 1 is a basic text parse according to the fields added to the builder. + * Phase 2 resolves the parsed field-value pairs into date and/or time objects. + * The resolver style is used to control how phase 2, resolving, happens. + * See {@code ResolverStyle} for more information on the options available. + *

    + * This instance is immutable and unaffected by this method call. + * + * @param resolverStyle the new resolver style, not null + * @return a formatter based on this formatter with the requested resolver style, not null + */ + public DateTimeFormatter withResolverStyle(ResolverStyle resolverStyle) { + Objects.requireNonNull(resolverStyle, "resolverStyle"); + if (Objects.equals(this.resolverStyle, resolverStyle)) { + return this; + } + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); + } + + //----------------------------------------------------------------------- + /** + * Gets the resolver fields to use during parsing. + *

    + * This returns the resolver fields, used during the second phase of parsing + * when fields are resolved into dates and times. + * By default, a formatter has no resolver fields, and thus returns null. + * See {@link #withResolverFields(Set)} for more details. + * + * @return the immutable set of resolver fields of this formatter, null if no fields + */ + public Set getResolverFields() { + return resolverFields; + } + + /** + * Returns a copy of this formatter with a new set of resolver fields. + *

    + * This returns a formatter with similar state to this formatter but with + * the resolver fields set. By default, a formatter has no resolver fields. + *

    + * Changing the resolver fields only has an effect during parsing. + * Parsing a text string occurs in two phases. + * Phase 1 is a basic text parse according to the fields added to the builder. + * Phase 2 resolves the parsed field-value pairs into date and/or time objects. + * The resolver fields are used to filter the field-value pairs between phase 1 and 2. + *

    + * This can be used to select between two or more ways that a date or time might + * be resolved. For example, if the formatter consists of year, month, day-of-month + * and day-of-year, then there are two ways to resolve a date. + * Calling this method with the arguments {@link ChronoField#YEAR YEAR} and + * {@link ChronoField#DAY_OF_YEAR DAY_OF_YEAR} will ensure that the date is + * resolved using the year and day-of-year, effectively meaning that the month + * and day-of-month are ignored during the resolving phase. + *

    + * In a similar manner, this method can be used to ignore secondary fields that + * would otherwise be cross-checked. For example, if the formatter consists of year, + * month, day-of-month and day-of-week, then there is only one way to resolve a + * date, but the parsed value for day-of-week will be cross-checked against the + * resolved date. Calling this method with the arguments {@link ChronoField#YEAR YEAR}, + * {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} and + * {@link ChronoField#DAY_OF_MONTH DAY_OF_MONTH} will ensure that the date is + * resolved correctly, but without any cross-check for the day-of-week. + *

    + * In implementation terms, this method behaves as follows. The result of the + * parsing phase can be considered to be a map of field to value. The behavior + * of this method is to cause that map to be filtered between phase 1 and 2, + * removing all fields other than those specified as arguments to this method. + *

    + * This instance is immutable and unaffected by this method call. + * + * @param resolverFields the new set of resolver fields, null if no fields + * @return a formatter based on this formatter with the requested resolver style, not null + */ + public DateTimeFormatter withResolverFields(TemporalField... resolverFields) { + Objects.requireNonNull(resolverFields, "resolverFields"); + Set fields = new HashSet<>(Arrays.asList(resolverFields)); + if (Objects.equals(this.resolverFields, fields)) { + return this; + } + fields = Collections.unmodifiableSet(fields); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, fields, chrono, zone); + } + + /** + * Returns a copy of this formatter with a new set of resolver fields. + *

    + * This returns a formatter with similar state to this formatter but with + * the resolver fields set. By default, a formatter has no resolver fields. + *

    + * Changing the resolver fields only has an effect during parsing. + * Parsing a text string occurs in two phases. + * Phase 1 is a basic text parse according to the fields added to the builder. + * Phase 2 resolves the parsed field-value pairs into date and/or time objects. + * The resolver fields are used to filter the field-value pairs between phase 1 and 2. + *

    + * This can be used to select between two or more ways that a date or time might + * be resolved. For example, if the formatter consists of year, month, day-of-month + * and day-of-year, then there are two ways to resolve a date. + * Calling this method with the arguments {@link ChronoField#YEAR YEAR} and + * {@link ChronoField#DAY_OF_YEAR DAY_OF_YEAR} will ensure that the date is + * resolved using the year and day-of-year, effectively meaning that the month + * and day-of-month are ignored during the resolving phase. + *

    + * In a similar manner, this method can be used to ignore secondary fields that + * would otherwise be cross-checked. For example, if the formatter consists of year, + * month, day-of-month and day-of-week, then there is only one way to resolve a + * date, but the parsed value for day-of-week will be cross-checked against the + * resolved date. Calling this method with the arguments {@link ChronoField#YEAR YEAR}, + * {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} and + * {@link ChronoField#DAY_OF_MONTH DAY_OF_MONTH} will ensure that the date is + * resolved correctly, but without any cross-check for the day-of-week. + *

    + * In implementation terms, this method behaves as follows. The result of the + * parsing phase can be considered to be a map of field to value. The behavior + * of this method is to cause that map to be filtered between phase 1 and 2, + * removing all fields other than those specified as arguments to this method. + *

    + * This instance is immutable and unaffected by this method call. + * + * @param resolverFields the new set of resolver fields, null if no fields + * @return a formatter based on this formatter with the requested resolver style, not null + */ + public DateTimeFormatter withResolverFields(Set resolverFields) { + Objects.requireNonNull(resolverFields, "resolverFields"); + if (Objects.equals(this.resolverFields, resolverFields)) { + return this; + } + resolverFields = Collections.unmodifiableSet(new HashSet<>(resolverFields)); + return new DateTimeFormatter(printerParser, locale, symbols, resolverStyle, resolverFields, chrono, zone); } //----------------------------------------------------------------------- @@ -1151,7 +1615,7 @@ public final class DateTimeFormatter { public TemporalAccessor parse(CharSequence text) { Objects.requireNonNull(text, "text"); try { - return parseToBuilder(text, null).resolve(); + return parseResolved0(text, null); } catch (DateTimeParseException ex) { throw ex; } catch (RuntimeException ex) { @@ -1193,7 +1657,7 @@ public final class DateTimeFormatter { Objects.requireNonNull(text, "text"); Objects.requireNonNull(position, "position"); try { - return parseToBuilder(text, position).resolve(); + return parseResolved0(text, position); } catch (DateTimeParseException | IndexOutOfBoundsException ex) { throw ex; } catch (RuntimeException ex) { @@ -1225,8 +1689,7 @@ public final class DateTimeFormatter { Objects.requireNonNull(text, "text"); Objects.requireNonNull(query, "query"); try { - DateTimeBuilder builder = parseToBuilder(text, null).resolve(); - return builder.query(query); + return parseResolved0(text, null).query(query); } catch (DateTimeParseException ex) { throw ex; } catch (RuntimeException ex) { @@ -1238,7 +1701,7 @@ public final class DateTimeFormatter { * Fully parses the text producing an object of one of the specified types. *

    * This parse method is convenient for use when the parser can handle optional elements. - * For example, a pattern of 'yyyy-MM-dd HH.mm[Z]]' can be fully parsed to a {@code ZonedDateTime}, + * For example, a pattern of 'uuuu-MM-dd HH.mm[ VV]' can be fully parsed to a {@code ZonedDateTime}, * or partially parsed to a {@code LocalDateTime}. * The queries must be specified in order, starting from the best matching full-parse option * and ending with the worst matching minimal parse option. @@ -1272,10 +1735,10 @@ public final class DateTimeFormatter { throw new IllegalArgumentException("At least two queries must be specified"); } try { - DateTimeBuilder builder = parseToBuilder(text, null).resolve(); + TemporalAccessor resolved = parseResolved0(text, null); for (TemporalQuery query : queries) { try { - return (TemporalAccessor) builder.query(query); + return (TemporalAccessor) resolved.query(query); } catch (RuntimeException ex) { // continue } @@ -1289,7 +1752,7 @@ public final class DateTimeFormatter { } private DateTimeParseException createError(CharSequence text, RuntimeException ex) { - String abbr = ""; + String abbr; if (text.length() > 64) { abbr = text.subSequence(0, 64).toString() + "..."; } else { @@ -1300,23 +1763,23 @@ public final class DateTimeFormatter { //----------------------------------------------------------------------- /** - * Parses the text to a builder. + * Parses and resolves the specified text. *

    - * This parses to a {@code DateTimeBuilder} ensuring that the text is fully parsed. - * This method throws {@link DateTimeParseException} if unable to parse, or - * some other {@code DateTimeException} if another date/time problem occurs. + * This parses to a {@code TemporalAccessor} ensuring that the text is fully parsed. * * @param text the text to parse, not null * @param position the position to parse from, updated with length parsed * and the index of any error, null if parsing whole string - * @return the engine representing the result of the parse, not null + * @return the resolved result of the parse, not null * @throws DateTimeParseException if the parse fails + * @throws DateTimeException if an error occurs while resolving the date or time + * @throws IndexOutOfBoundsException if the position is invalid */ - private DateTimeBuilder parseToBuilder(final CharSequence text, final ParsePosition position) { + private TemporalAccessor parseResolved0(final CharSequence text, final ParsePosition position) { ParsePosition pos = (position != null ? position : new ParsePosition(0)); - DateTimeParseContext result = parseUnresolved0(text, pos); - if (result == null || pos.getErrorIndex() >= 0 || (position == null && pos.getIndex() < text.length())) { - String abbr = ""; + Parsed unresolved = parseUnresolved0(text, pos); + if (unresolved == null || pos.getErrorIndex() >= 0 || (position == null && pos.getIndex() < text.length())) { + String abbr; if (text.length() > 64) { abbr = text.subSequence(0, 64).toString() + "..."; } else { @@ -1330,7 +1793,7 @@ public final class DateTimeFormatter { pos.getIndex(), text, pos.getIndex()); } } - return result.resolveFields().toBuilder(); + return unresolved.resolve(resolverStyle, resolverFields); } /** @@ -1376,7 +1839,7 @@ public final class DateTimeFormatter { return parseUnresolved0(text, position); } - private DateTimeParseContext parseUnresolved0(CharSequence text, ParsePosition position) { + private Parsed parseUnresolved0(CharSequence text, ParsePosition position) { Objects.requireNonNull(text, "text"); Objects.requireNonNull(position, "position"); DateTimeParseContext context = new DateTimeParseContext(this); @@ -1387,7 +1850,7 @@ public final class DateTimeFormatter { return null; } position.setIndex(pos); // errorIndex not updated from input - return context; + return context.toParsed(); } //----------------------------------------------------------------------- @@ -1496,7 +1959,7 @@ public final class DateTimeFormatter { Objects.requireNonNull(text, "text"); try { if (parseType == null) { - return formatter.parseToBuilder(text, null).resolve(); + return formatter.parseResolved0(text, null); } return formatter.parse(text, parseType); } catch (DateTimeParseException ex) { @@ -1508,7 +1971,7 @@ public final class DateTimeFormatter { @Override public Object parseObject(String text, ParsePosition pos) { Objects.requireNonNull(text, "text"); - DateTimeParseContext unresolved; + Parsed unresolved; try { unresolved = formatter.parseUnresolved0(text, pos); } catch (IndexOutOfBoundsException ex) { @@ -1524,11 +1987,11 @@ public final class DateTimeFormatter { return null; } try { - DateTimeBuilder builder = unresolved.resolveFields().toBuilder().resolve(); + TemporalAccessor resolved = unresolved.resolve(formatter.resolverStyle, formatter.resolverFields); if (parseType == null) { - return builder; + return resolved; } - return builder.query(parseType); + return resolved.query(parseType); } catch (RuntimeException ex) { pos.setErrorIndex(0); return null; diff --git a/jdk/src/share/classes/java/time/format/DateTimeFormatterBuilder.java b/jdk/src/share/classes/java/time/format/DateTimeFormatterBuilder.java index e413d4b1e64..d209f5c8baf 100644 --- a/jdk/src/share/classes/java/time/format/DateTimeFormatterBuilder.java +++ b/jdk/src/share/classes/java/time/format/DateTimeFormatterBuilder.java @@ -83,11 +83,9 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.chrono.Chronology; import java.time.chrono.IsoChronology; -import java.time.chrono.JapaneseChronology; import java.time.format.DateTimeTextProvider.LocaleStore; import java.time.temporal.ChronoField; import java.time.temporal.IsoFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -111,7 +109,10 @@ import java.util.Objects; import java.util.Set; import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; import sun.util.locale.provider.TimeZoneNameUtility; /** @@ -129,6 +130,8 @@ import sun.util.locale.provider.TimeZoneNameUtility; *

  • OffsetId/Offset - the {@linkplain ZoneOffset zone offset}
  • *
  • ZoneId - the {@linkplain ZoneId time-zone} id
  • *
  • ZoneText - the name of the time-zone
  • + *
  • ChronologyId - the {@linkplain Chronology chronology} id
  • + *
  • ChronologyText - the name of the chronology
  • *
  • Literal - a text literal
  • *
  • Nested and Optional - formats can be nested or made optional
  • *
  • Other - the printer and parser interfaces can be used to add user supplied formatting
  • @@ -150,7 +153,7 @@ public final class DateTimeFormatterBuilder { * Query for a time-zone that is region-only. */ private static final TemporalQuery QUERY_REGION_ONLY = (temporal) -> { - ZoneId zone = temporal.query(Queries.zoneId()); + ZoneId zone = temporal.query(TemporalQuery.zoneId()); return (zone != null && zone instanceof ZoneOffset == false ? zone : null); }; @@ -286,6 +289,40 @@ public final class DateTimeFormatterBuilder { return this; } + //----------------------------------------------------------------------- + /** + * Appends a default value for a field to the formatter for use in parsing. + *

    + * This appends an instruction to the builder to inject a default value + * into the parsed result. This is especially useful in conjunction with + * optional parts of the formatter. + *

    + * For example, consider a formatter that parses the year, followed by + * an optional month, with a further optional day-of-month. Using such a + * formatter would require the calling code to check whether a full date, + * year-month or just a year had been parsed. This method can be used to + * default the month and day-of-month to a sensible value, such as the + * first of the month, allowing the calling code to always get a date. + *

    + * During formatting, this method has no effect. + *

    + * During parsing, the current state of the parse is inspected. + * If the specified field has no associated value, because it has not been + * parsed successfully at that point, then the specified value is injected + * into the parse result. Injection is immediate, thus the field-value pair + * will be visible to any subsequent elements in the formatter. + * As such, this method is normally called at the end of the builder. + * + * @param field the field to default the value of, not null + * @param value the value to default the field to + * @return this, for chaining, not null + */ + public DateTimeFormatterBuilder parseDefaulting(TemporalField field, long value) { + Objects.requireNonNull(field, "field"); + appendInternal(new DefaultValueParser(field, value)); + return this; + } + //----------------------------------------------------------------------- /** * Appends the value of a date-time field to the formatter using a normal @@ -655,7 +692,7 @@ public final class DateTimeFormatterBuilder { * This appends an instruction to format/parse the offset ID to the builder. *

    * During formatting, the offset is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#offset()}. + * to querying the temporal with {@link TemporalQuery#offset()}. * It will be printed using the format defined below. * If the offset cannot be obtained then an exception is thrown unless the * section of the formatter is optional. @@ -692,6 +729,44 @@ public final class DateTimeFormatterBuilder { return this; } + /** + * Appends the localized zone offset, such as 'GMT+01:00', to the formatter. + *

    + * This appends a localized zone offset to the builder, the format of the + * localized offset is controlled by the specified {@link FormatStyle style} + * to this method: + *

      + *
    • {@link TextStyle#FULL full} - formats with localized offset text, such + * as 'GMT, 2-digit hour and minute field, optional second field if non-zero, + * and colon. + *
    • {@link TextStyle#SHORT short} - formats with localized offset text, + * such as 'GMT, hour without leading zero, optional 2-digit minute and + * second if non-zero, and colon. + *

    + *

    + * During formatting, the offset is obtained using a mechanism equivalent + * to querying the temporal with {@link TemporalQuery#offset()}. + * If the offset cannot be obtained then an exception is thrown unless the + * section of the formatter is optional. + *

    + * During parsing, the offset is parsed using the format defined above. + * If the offset cannot be parsed then an exception is thrown unless the + * section of the formatter is optional. + *

    + * @param style the format style to use, not null + * @return this, for chaining, not null + * @throws IllegalArgumentException if style is neither {@link TextStyle#FULL + * full} nor {@link TextStyle#SHORT short} + */ + public DateTimeFormatterBuilder appendLocalizedOffset(TextStyle style) { + Objects.requireNonNull(style, "style"); + if (style != TextStyle.FULL && style != TextStyle.SHORT) { + throw new IllegalArgumentException("Style must be either full or short"); + } + appendInternal(new LocalizedOffsetIdPrinterParser(style)); + return this; + } + //----------------------------------------------------------------------- /** * Appends the time-zone ID, such as 'Europe/Paris' or '+02:00', to the formatter. @@ -702,7 +777,7 @@ public final class DateTimeFormatterBuilder { * for use with this method, see {@link #appendZoneOrOffsetId()}. *

    * During formatting, the zone is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#zoneId()}. + * to querying the temporal with {@link TemporalQuery#zoneId()}. * It will be printed using the result of {@link ZoneId#getId()}. * If the zone cannot be obtained then an exception is thrown unless the * section of the formatter is optional. @@ -725,25 +800,25 @@ public final class DateTimeFormatterBuilder { *

    * For example, the following will parse: *

    -     *   "Europe/London"           -> ZoneId.of("Europe/London")
    -     *   "Z"                       -> ZoneOffset.UTC
    -     *   "UT"                      -> ZoneOffset.UTC
    -     *   "UTC"                     -> ZoneOffset.UTC
    -     *   "GMT"                     -> ZoneOffset.UTC
    -     *   "UT0"                     -> ZoneOffset.UTC
    -     *   "UTC0"                    -> ZoneOffset.UTC
    -     *   "GMT0"                    -> ZoneOffset.UTC
    -     *   "+01:30"                  -> ZoneOffset.of("+01:30")
    -     *   "UT+01:30"                -> ZoneOffset.of("+01:30")
    -     *   "UTC+01:30"               -> ZoneOffset.of("+01:30")
    -     *   "GMT+01:30"               -> ZoneOffset.of("+01:30")
    +     *   "Europe/London"           -- ZoneId.of("Europe/London")
    +     *   "Z"                       -- ZoneOffset.UTC
    +     *   "UT"                      -- ZoneOffset.UTC
    +     *   "UTC"                     -- ZoneOffset.UTC
    +     *   "GMT"                     -- ZoneOffset.UTC
    +     *   "UT0"                     -- ZoneOffset.UTC
    +     *   "UTC0"                    -- ZoneOffset.UTC
    +     *   "GMT0"                    -- ZoneOffset.UTC
    +     *   "+01:30"                  -- ZoneOffset.of("+01:30")
    +     *   "UT+01:30"                -- ZoneOffset.of("+01:30")
    +     *   "UTC+01:30"               -- ZoneOffset.of("+01:30")
    +     *   "GMT+01:30"               -- ZoneOffset.of("+01:30")
          * 
    * * @return this, for chaining, not null * @see #appendZoneRegionId() */ public DateTimeFormatterBuilder appendZoneId() { - appendInternal(new ZoneIdPrinterParser(Queries.zoneId(), "ZoneId()")); + appendInternal(new ZoneIdPrinterParser(TemporalQuery.zoneId(), "ZoneId()")); return this; } @@ -755,7 +830,7 @@ public final class DateTimeFormatterBuilder { * only if it is a region-based ID. *

    * During formatting, the zone is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#zoneId()}. + * to querying the temporal with {@link TemporalQuery#zoneId()}. * If the zone is a {@code ZoneOffset} or it cannot be obtained then * an exception is thrown unless the section of the formatter is optional. * If the zone is not an offset, then the zone will be printed using @@ -779,18 +854,18 @@ public final class DateTimeFormatterBuilder { *

    * For example, the following will parse: *

    -     *   "Europe/London"           -> ZoneId.of("Europe/London")
    -     *   "Z"                       -> ZoneOffset.UTC
    -     *   "UT"                      -> ZoneOffset.UTC
    -     *   "UTC"                     -> ZoneOffset.UTC
    -     *   "GMT"                     -> ZoneOffset.UTC
    -     *   "UT0"                     -> ZoneOffset.UTC
    -     *   "UTC0"                    -> ZoneOffset.UTC
    -     *   "GMT0"                    -> ZoneOffset.UTC
    -     *   "+01:30"                  -> ZoneOffset.of("+01:30")
    -     *   "UT+01:30"                -> ZoneOffset.of("+01:30")
    -     *   "UTC+01:30"               -> ZoneOffset.of("+01:30")
    -     *   "GMT+01:30"               -> ZoneOffset.of("+01:30")
    +     *   "Europe/London"           -- ZoneId.of("Europe/London")
    +     *   "Z"                       -- ZoneOffset.UTC
    +     *   "UT"                      -- ZoneOffset.UTC
    +     *   "UTC"                     -- ZoneOffset.UTC
    +     *   "GMT"                     -- ZoneOffset.UTC
    +     *   "UT0"                     -- ZoneOffset.UTC
    +     *   "UTC0"                    -- ZoneOffset.UTC
    +     *   "GMT0"                    -- ZoneOffset.UTC
    +     *   "+01:30"                  -- ZoneOffset.of("+01:30")
    +     *   "UT+01:30"                -- ZoneOffset.of("+01:30")
    +     *   "UTC+01:30"               -- ZoneOffset.of("+01:30")
    +     *   "GMT+01:30"               -- ZoneOffset.of("+01:30")
          * 
    *

    * Note that this method is is identical to {@code appendZoneId()} except @@ -817,7 +892,7 @@ public final class DateTimeFormatterBuilder { * then attempts to find an offset, such as that on {@code OffsetDateTime}. *

    * During formatting, the zone is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#zone()}. + * to querying the temporal with {@link TemporalQuery#zone()}. * It will be printed using the result of {@link ZoneId#getId()}. * If the zone cannot be obtained then an exception is thrown unless the * section of the formatter is optional. @@ -840,18 +915,18 @@ public final class DateTimeFormatterBuilder { *

    * For example, the following will parse: *

    -     *   "Europe/London"           -> ZoneId.of("Europe/London")
    -     *   "Z"                       -> ZoneOffset.UTC
    -     *   "UT"                      -> ZoneOffset.UTC
    -     *   "UTC"                     -> ZoneOffset.UTC
    -     *   "GMT"                     -> ZoneOffset.UTC
    -     *   "UT0"                     -> ZoneOffset.UTC
    -     *   "UTC0"                    -> ZoneOffset.UTC
    -     *   "GMT0"                    -> ZoneOffset.UTC
    -     *   "+01:30"                  -> ZoneOffset.of("+01:30")
    -     *   "UT+01:30"                -> ZoneOffset.of("+01:30")
    -     *   "UTC+01:30"               -> ZoneOffset.of("+01:30")
    -     *   "GMT+01:30"               -> ZoneOffset.of("+01:30")
    +     *   "Europe/London"           -- ZoneId.of("Europe/London")
    +     *   "Z"                       -- ZoneOffset.UTC
    +     *   "UT"                      -- ZoneOffset.UTC
    +     *   "UTC"                     -- ZoneOffset.UTC
    +     *   "GMT"                     -- ZoneOffset.UTC
    +     *   "UT0"                     -- ZoneOffset.UTC
    +     *   "UTC0"                    -- ZoneOffset.UTC
    +     *   "GMT0"                    -- ZoneOffset.UTC
    +     *   "+01:30"                  -- ZoneOffset.of("+01:30")
    +     *   "UT+01:30"                -- ZoneOffset.of("+01:30")
    +     *   "UTC+01:30"               -- ZoneOffset.of("+01:30")
    +     *   "GMT+01:30"               -- ZoneOffset.of("+01:30")
          * 
    *

    * Note that this method is is identical to {@code appendZoneId()} except @@ -861,7 +936,7 @@ public final class DateTimeFormatterBuilder { * @see #appendZoneId() */ public DateTimeFormatterBuilder appendZoneOrOffsetId() { - appendInternal(new ZoneIdPrinterParser(Queries.zone(), "ZoneOrOffsetId()")); + appendInternal(new ZoneIdPrinterParser(TemporalQuery.zone(), "ZoneOrOffsetId()")); return this; } @@ -872,7 +947,7 @@ public final class DateTimeFormatterBuilder { * the builder. *

    * During formatting, the zone is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#zoneId()}. + * to querying the temporal with {@link TemporalQuery#zoneId()}. * If the zone is a {@code ZoneOffset} it will be printed using the * result of {@link ZoneOffset#getId()}. * If the zone is not an offset, the textual name will be looked up @@ -908,7 +983,7 @@ public final class DateTimeFormatterBuilder { * the builder. *

    * During formatting, the zone is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#zoneId()}. + * to querying the temporal with {@link TemporalQuery#zoneId()}. * If the zone is a {@code ZoneOffset} it will be printed using the * result of {@link ZoneOffset#getId()}. * If the zone is not an offset, the textual name will be looked up @@ -951,7 +1026,7 @@ public final class DateTimeFormatterBuilder { * This appends an instruction to format/parse the chronology ID to the builder. *

    * During formatting, the chronology is obtained using a mechanism equivalent - * to querying the temporal with {@link Queries#chronology()}. + * to querying the temporal with {@link TemporalQuery#chronology()}. * It will be printed using the result of {@link Chronology#getId()}. * If the chronology cannot be obtained then an exception is thrown unless the * section of the formatter is optional. @@ -1098,24 +1173,25 @@ public final class DateTimeFormatterBuilder { * Appends the elements defined by the specified pattern to the builder. *

    * All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. - * The characters '{' and '}' are reserved for future use. + * The characters '#', '{' and '}' are reserved for future use. * The characters '[' and ']' indicate optional patterns. * The following pattern letters are defined: *

          *  Symbol  Meaning                     Presentation      Examples
          *  ------  -------                     ------------      -------
    -     *   G       era                         text              A; AD; Anno Domini
    -     *   y       year                        year              2004; 04
    +     *   G       era                         text              AD; Anno Domini; A
    +     *   u       year                        year              2004; 04
    +     *   y       year-of-era                 year              2004; 04
          *   D       day-of-year                 number            189
    -     *   M       month-of-year               number/text       7; 07; Jul; July; J
    +     *   M/L     month-of-year               number/text       7; 07; Jul; July; J
          *   d       day-of-month                number            10
          *
    -     *   Q       quarter-of-year             number/text       3; 03; Q3
    +     *   Q/q     quarter-of-year             number/text       3; 03; Q3; 3rd quarter
          *   Y       week-based-year             year              1996; 96
    -     *   w       week-of-year                number            27
    -     *   W       week-of-month               number            27
    -     *   e       localized day-of-week       number            2; Tue; Tuesday; T
    -     *   E       day-of-week                 number/text       2; Tue; Tuesday; T
    +     *   w       week-of-week-based-year     number            27
    +     *   W       week-of-month               number            4
    +     *   E       day-of-week                 text              Tue; Tuesday; T
    +     *   e/c     localized day-of-week       number/text       2; 02; Tue; Tuesday; T
          *   F       week-of-month               number            3
          *
          *   a       am-pm-of-day                text              PM
    @@ -1133,6 +1209,7 @@ public final class DateTimeFormatterBuilder {
          *
          *   V       time-zone ID                zone-id           America/Los_Angeles; Z; -08:30
          *   z       time-zone name              zone-name         Pacific Standard Time; PST
    +     *   O       localized zone-offset       offset-O          GMT+8; GMT+08:00; UTC-08:00;
          *   X       zone-offset 'Z' for zero    offset-X          Z; -08; -0830; -08:30; -083015; -08:30:15;
          *   x       zone-offset                 offset-x          +0000; -08; -0830; -08:30; -083015; -08:30:15;
          *   Z       zone-offset                 offset-Z          +0000; -0800; -08:00;
    @@ -1143,116 +1220,169 @@ public final class DateTimeFormatterBuilder {
          *   ''      single quote                literal           '
          *   [       optional section start
          *   ]       optional section end
    -     *   {}      reserved for future use
    +     *   #       reserved for future use
    +     *   {       reserved for future use
    +     *   }       reserved for future use
          * 
    *

    * The count of pattern letters determine the format. + * See DateTimeFormatter for a user-focused description of the patterns. + * The following tables define how the pattern letters map to the builder. *

    - * Text: The text style is determined based on the number of pattern letters used. - * Less than 4 pattern letters will use the {@link TextStyle#SHORT short form}. - * Exactly 4 pattern letters will use the {@link TextStyle#FULL full form}. - * Exactly 5 pattern letters will use the {@link TextStyle#NARROW narrow form}. - *

    - * Number: If the count of letters is one, then the value is printed using the minimum number - * of digits and without padding as per {@link #appendValue(java.time.temporal.TemporalField)}. Otherwise, the - * count of digits is used as the width of the output field as per {@link #appendValue(java.time.temporal.TemporalField, int)}. - *

    - * Number/Text: If the count of pattern letters is 3 or greater, use the Text rules above. - * Otherwise use the Number rules above. - *

    - * Fraction: Outputs the nano-of-second field as a fraction-of-second. - * The nano-of-second value has nine digits, thus the count of pattern letters is from 1 to 9. - * If it is less than 9, then the nano-of-second value is truncated, with only the most - * significant digits being output. - * When parsing in strict mode, the number of parsed digits must match the count of pattern letters. - * When parsing in lenient mode, the number of parsed digits must be at least the count of pattern - * letters, up to 9 digits. - *

    - * Year: The count of letters determines the minimum field width below which padding is used. - * If the count of letters is two, then a {@link #appendValueReduced reduced} two digit form is used. - * For formatting, this outputs the rightmost two digits. For parsing, this will parse using the - * base value of 2000, resulting in a year within the range 2000 to 2099 inclusive. - * If the count of letters is less than four (but not two), then the sign is only output for negative - * years as per {@link SignStyle#NORMAL}. - * Otherwise, the sign is output if the pad width is exceeded, as per {@link SignStyle#EXCEEDS_PAD} - *

    - * ZoneId: This outputs the time-zone ID, such as 'Europe/Paris'. - * If the count of letters is two, then the time-zone ID is output. - * Any other count of letters throws {@code IllegalArgumentException}. + * Date fields: Pattern letters to output a date. *

    -     *  Pattern     Equivalent builder methods
    -     *   VV          appendZoneId()
    +     *  Pattern  Count  Equivalent builder methods
    +     *  -------  -----  --------------------------
    +     *    G       1      appendText(ChronoField.ERA, TextStyle.SHORT)
    +     *    GG      2      appendText(ChronoField.ERA, TextStyle.SHORT)
    +     *    GGG     3      appendText(ChronoField.ERA, TextStyle.SHORT)
    +     *    GGGG    4      appendText(ChronoField.ERA, TextStyle.FULL)
    +     *    GGGGG   5      appendText(ChronoField.ERA, TextStyle.NARROW)
    +     *
    +     *    u       1      appendValue(ChronoField.YEAR, 1, 19, SignStyle.NORMAL);
    +     *    uu      2      appendValueReduced(ChronoField.YEAR, 2, 2000);
    +     *    uuu     3      appendValue(ChronoField.YEAR, 3, 19, SignStyle.NORMAL);
    +     *    u..u    4..n   appendValue(ChronoField.YEAR, n, 19, SignStyle.EXCEEDS_PAD);
    +     *    y       1      appendValue(ChronoField.YEAR_OF_ERA, 1, 19, SignStyle.NORMAL);
    +     *    yy      2      appendValueReduced(ChronoField.YEAR_OF_ERA, 2, 2000);
    +     *    yyy     3      appendValue(ChronoField.YEAR_OF_ERA, 3, 19, SignStyle.NORMAL);
    +     *    y..y    4..n   appendValue(ChronoField.YEAR_OF_ERA, n, 19, SignStyle.EXCEEDS_PAD);
    +     *    Y       1      append special localized WeekFields element for numeric week-based-year
    +     *    YY      2      append special localized WeekFields element for reduced numeric week-based-year 2 digits;
    +     *    YYY     3      append special localized WeekFields element for numeric week-based-year (3, 19, SignStyle.NORMAL);
    +     *    Y..Y    4..n   append special localized WeekFields element for numeric week-based-year (n, 19, SignStyle.EXCEEDS_PAD);
    +     *
    +     *    Q       1      appendValue(IsoFields.QUARTER_OF_YEAR);
    +     *    QQ      2      appendValue(IsoFields.QUARTER_OF_YEAR, 2);
    +     *    QQQ     3      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.SHORT)
    +     *    QQQQ    4      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.FULL)
    +     *    QQQQQ   5      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.NARROW)
    +     *    q       1      appendValue(IsoFields.QUARTER_OF_YEAR);
    +     *    qq      2      appendValue(IsoFields.QUARTER_OF_YEAR, 2);
    +     *    qqq     3      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.SHORT_STANDALONE)
    +     *    qqqq    4      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.FULL_STANDALONE)
    +     *    qqqqq   5      appendText(IsoFields.QUARTER_OF_YEAR, TextStyle.NARROW_STANDALONE)
    +     *
    +     *    M       1      appendValue(ChronoField.MONTH_OF_YEAR);
    +     *    MM      2      appendValue(ChronoField.MONTH_OF_YEAR, 2);
    +     *    MMM     3      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.SHORT)
    +     *    MMMM    4      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.FULL)
    +     *    MMMMM   5      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.NARROW)
    +     *    L       1      appendValue(ChronoField.MONTH_OF_YEAR);
    +     *    LL      2      appendValue(ChronoField.MONTH_OF_YEAR, 2);
    +     *    LLL     3      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.SHORT_STANDALONE)
    +     *    LLLL    4      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.FULL_STANDALONE)
    +     *    LLLLL   5      appendText(ChronoField.MONTH_OF_YEAR, TextStyle.NARROW_STANDALONE)
    +     *
    +     *    w       1      append special localized WeekFields element for numeric week-of-year
    +     *    ww      1      append special localized WeekFields element for numeric week-of-year, zero-padded
    +     *    W       1      append special localized WeekFields element for numeric week-of-month
    +     *    d       1      appendValue(ChronoField.DAY_OF_MONTH)
    +     *    dd      2      appendValue(ChronoField.DAY_OF_MONTH, 2)
    +     *    D       1      appendValue(ChronoField.DAY_OF_YEAR)
    +     *    DD      2      appendValue(ChronoField.DAY_OF_YEAR, 2)
    +     *    DDD     3      appendValue(ChronoField.DAY_OF_YEAR, 3)
    +     *    F       1      appendValue(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH)
    +     *    E       1      appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT)
    +     *    EE      2      appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT)
    +     *    EEE     3      appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT)
    +     *    EEEE    4      appendText(ChronoField.DAY_OF_WEEK, TextStyle.FULL)
    +     *    EEEEE   5      appendText(ChronoField.DAY_OF_WEEK, TextStyle.NARROW)
    +     *    e       1      append special localized WeekFields element for numeric day-of-week
    +     *    ee      2      append special localized WeekFields element for numeric day-of-week, zero-padded
    +     *    eee     3      appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT)
    +     *    eeee    4      appendText(ChronoField.DAY_OF_WEEK, TextStyle.FULL)
    +     *    eeeee   5      appendText(ChronoField.DAY_OF_WEEK, TextStyle.NARROW)
    +     *    c       1      append special localized WeekFields element for numeric day-of-week
    +     *    ccc     3      appendText(ChronoField.DAY_OF_WEEK, TextStyle.SHORT_STANDALONE)
    +     *    cccc    4      appendText(ChronoField.DAY_OF_WEEK, TextStyle.FULL_STANDALONE)
    +     *    ccccc   5      appendText(ChronoField.DAY_OF_WEEK, TextStyle.NARROW_STANDALONE)
          * 
    *

    - * Zone names: This outputs the display name of the time-zone ID. - * If the count of letters is one, two or three, then the short name is output. - * If the count of letters is four, then the full name is output. - * Five or more letters throws {@code IllegalArgumentException}. + * Time fields: Pattern letters to output a time. *

    -     *  Pattern     Equivalent builder methods
    -     *   z           appendZoneText(TextStyle.SHORT)
    -     *   zz          appendZoneText(TextStyle.SHORT)
    -     *   zzz         appendZoneText(TextStyle.SHORT)
    -     *   zzzz        appendZoneText(TextStyle.FULL)
    +     *  Pattern  Count  Equivalent builder methods
    +     *  -------  -----  --------------------------
    +     *    a       1      appendText(ChronoField.AMPM_OF_DAY, TextStyle.SHORT)
    +     *    h       1      appendValue(ChronoField.CLOCK_HOUR_OF_AMPM)
    +     *    hh      2      appendValue(ChronoField.CLOCK_HOUR_OF_AMPM, 2)
    +     *    H       1      appendValue(ChronoField.HOUR_OF_DAY)
    +     *    HH      2      appendValue(ChronoField.HOUR_OF_DAY, 2)
    +     *    k       1      appendValue(ChronoField.CLOCK_HOUR_OF_DAY)
    +     *    kk      2      appendValue(ChronoField.CLOCK_HOUR_OF_DAY, 2)
    +     *    K       1      appendValue(ChronoField.HOUR_OF_AMPM)
    +     *    KK      2      appendValue(ChronoField.HOUR_OF_AMPM, 2)
    +     *    m       1      appendValue(ChronoField.MINUTE_OF_HOUR)
    +     *    mm      2      appendValue(ChronoField.MINUTE_OF_HOUR, 2)
    +     *    s       1      appendValue(ChronoField.SECOND_OF_MINUTE)
    +     *    ss      2      appendValue(ChronoField.SECOND_OF_MINUTE, 2)
    +     *
    +     *    S..S    1..n   appendFraction(ChronoField.NANO_OF_SECOND, n, n, false)
    +     *    A       1      appendValue(ChronoField.MILLI_OF_DAY)
    +     *    A..A    2..n   appendValue(ChronoField.MILLI_OF_DAY, n)
    +     *    n       1      appendValue(ChronoField.NANO_OF_SECOND)
    +     *    n..n    2..n   appendValue(ChronoField.NANO_OF_SECOND, n)
    +     *    N       1      appendValue(ChronoField.NANO_OF_DAY)
    +     *    N..N    2..n   appendValue(ChronoField.NANO_OF_DAY, n)
          * 
    *

    - * Offset X and x: This formats the offset based on the number of pattern letters. - * One letter outputs just the hour', such as '+01', unless the minute is non-zero - * in which case the minute is also output, such as '+0130'. - * Two letters outputs the hour and minute, without a colon, such as '+0130'. - * Three letters outputs the hour and minute, with a colon, such as '+01:30'. - * Four letters outputs the hour and minute and optional second, without a colon, such as '+013015'. - * Five letters outputs the hour and minute and optional second, with a colon, such as '+01:30:15'. - * Six or more letters throws {@code IllegalArgumentException}. - * Pattern letter 'X' (upper case) will output 'Z' when the offset to be output would be zero, - * whereas pattern letter 'x' (lower case) will output '+00', '+0000', or '+00:00'. + * Zone ID: Pattern letters to output {@code ZoneId}. *

    -     *  Pattern     Equivalent builder methods
    -     *   X           appendOffset("+HHmm","Z")
    -     *   XX          appendOffset("+HHMM","Z")
    -     *   XXX         appendOffset("+HH:MM","Z")
    -     *   XXXX        appendOffset("+HHMMss","Z")
    -     *   XXXXX       appendOffset("+HH:MM:ss","Z")
    -     *   x           appendOffset("+HHmm","+00")
    -     *   xx          appendOffset("+HHMM","+0000")
    -     *   xxx         appendOffset("+HH:MM","+00:00")
    -     *   xxxx        appendOffset("+HHMMss","+0000")
    -     *   xxxxx       appendOffset("+HH:MM:ss","+00:00")
    +     *  Pattern  Count  Equivalent builder methods
    +     *  -------  -----  --------------------------
    +     *    VV      2      appendZoneId()
    +     *    z       1      appendZoneText(TextStyle.SHORT)
    +     *    zz      2      appendZoneText(TextStyle.SHORT)
    +     *    zzz     3      appendZoneText(TextStyle.SHORT)
    +     *    zzzz    4      appendZoneText(TextStyle.FULL)
          * 
    *

    - * Offset Z: This formats the offset based on the number of pattern letters. - * One, two or three letters outputs the hour and minute, without a colon, such as '+0130'. - * Four or more letters throws {@code IllegalArgumentException}. - * The output will be '+0000' when the offset is zero. + * Zone offset: Pattern letters to output {@code ZoneOffset}. *

    -     *  Pattern     Equivalent builder methods
    -     *   Z           appendOffset("+HHMM","+0000")
    -     *   ZZ          appendOffset("+HHMM","+0000")
    -     *   ZZZ         appendOffset("+HHMM","+0000")
    +     *  Pattern  Count  Equivalent builder methods
    +     *  -------  -----  --------------------------
    +     *    O       1      appendLocalizedOffsetPrefixed(TextStyle.SHORT);
    +     *    OOOO    4      appendLocalizedOffsetPrefixed(TextStyle.FULL);
    +     *    X       1      appendOffset("+HHmm","Z")
    +     *    XX      2      appendOffset("+HHMM","Z")
    +     *    XXX     3      appendOffset("+HH:MM","Z")
    +     *    XXXX    4      appendOffset("+HHMMss","Z")
    +     *    XXXXX   5      appendOffset("+HH:MM:ss","Z")
    +     *    x       1      appendOffset("+HHmm","+00")
    +     *    xx      2      appendOffset("+HHMM","+0000")
    +     *    xxx     3      appendOffset("+HH:MM","+00:00")
    +     *    xxxx    4      appendOffset("+HHMMss","+0000")
    +     *    xxxxx   5      appendOffset("+HH:MM:ss","+00:00")
    +     *    Z       1      appendOffset("+HHMM","+0000")
    +     *    ZZ      2      appendOffset("+HHMM","+0000")
    +     *    ZZZ     3      appendOffset("+HHMM","+0000")
    +     *    ZZZZ    4      appendLocalizedOffset(TextStyle.FULL);
    +     *    ZZZZZ   5      appendOffset("+HH:MM:ss","Z")
          * 
    *

    - * Optional section: The optional section markers work exactly like calling {@link #optionalStart()} - * and {@link #optionalEnd()}. + * Modifiers: Pattern letters that modify the rest of the pattern: + *

    +     *  Pattern  Count  Equivalent builder methods
    +     *  -------  -----  --------------------------
    +     *    [       1      optionalStart()
    +     *    ]       1      optionalEnd()
    +     *    p..p    1..n   padNext(n)
    +     * 
    *

    - * Pad modifier: Modifies the pattern that immediately follows to be padded with spaces. - * The pad width is determined by the number of pattern letters. - * This is the same as calling {@link #padNext(int)}. - *

    - * For example, 'ppH' outputs the hour-of-day padded on the left with spaces to a width of 2. - *

    - * Any unrecognized letter is an error. - * Any non-letter character, other than '[', ']', '{', '}' and the single quote will be output directly. - * Despite this, it is recommended to use single quotes around all characters that you want to - * output directly to ensure that future changes do not break your application. + * Any sequence of letters not specified above, unrecognized letter or + * reserved character will throw an exception. + * Future versions may add to the set of patterns. + * It is recommended to use single quotes around all characters that you want + * to output directly to ensure that future changes do not break your application. *

    * Note that the pattern string is similar, but not identical, to * {@link java.text.SimpleDateFormat SimpleDateFormat}. * The pattern string is also similar, but not identical, to that defined by the * Unicode Common Locale Data Repository (CLDR/LDML). - * Pattern letters 'E' and 'u' are merged, which changes the meaning of "E" and "EE" to be numeric. - * Pattern letters 'X' is aligned with Unicode CLDR/LDML, which affects pattern 'X'. - * Pattern letter 'y' and 'Y' parse years of two digits and more than 4 digits differently. - * Pattern letters 'n', 'A', 'N', 'I' and 'p' are added. + * Pattern letters 'X' and 'u' are aligned with Unicode CLDR/LDML. + * By contrast, {@code SimpleDateFormat} uses 'u' for the numeric day of week. + * Pattern letters 'y' and 'Y' parse years of two digits and more than 4 digits differently. + * Pattern letters 'n', 'A', 'N', and 'p' are added. * Number types will reject large numbers. * * @param pattern the pattern to add, not null @@ -1308,10 +1438,23 @@ public final class DateTimeFormatterBuilder { } appendZoneId(); } else if (cur == 'Z') { - if (count > 3) { + if (count < 4) { + appendOffset("+HHMM", "+0000"); + } else if (count == 4) { + appendLocalizedOffset(TextStyle.FULL); + } else if (count == 5) { + appendOffset("+HH:MM:ss","Z"); + } else { throw new IllegalArgumentException("Too many pattern letters: " + cur); } - appendOffset("+HHMM", "+0000"); + } else if (cur == 'O') { + if (count == 1) { + appendLocalizedOffset(TextStyle.SHORT); + } else if (count == 4) { + appendLocalizedOffset(TextStyle.FULL); + } else { + throw new IllegalArgumentException("Pattern letter count must be 1 or 4: " + cur); + } } else if (cur == 'X') { if (count > 5) { throw new IllegalArgumentException("Too many pattern letters: " + cur); @@ -1323,18 +1466,21 @@ public final class DateTimeFormatterBuilder { } String zero = (count == 1 ? "+00" : (count % 2 == 0 ? "+0000" : "+00:00")); appendOffset(OffsetIdPrinterParser.PATTERNS[count + (count == 1 ? 0 : 1)], zero); - } else if (cur == 'w' || cur == 'e') { + } else if (cur == 'W') { // Fields defined by Locale if (count > 1) { throw new IllegalArgumentException("Too many pattern letters: " + cur); } appendInternal(new WeekBasedFieldPrinterParser(cur, count)); - } else if (cur == 'W') { + } else if (cur == 'w') { // Fields defined by Locale if (count > 2) { throw new IllegalArgumentException("Too many pattern letters: " + cur); } appendInternal(new WeekBasedFieldPrinterParser(cur, count)); + } else if (cur == 'Y') { + // Fields defined by Locale + appendInternal(new WeekBasedFieldPrinterParser(cur, count)); } else { throw new IllegalArgumentException("Unknown pattern letter: " + cur); } @@ -1371,7 +1517,7 @@ public final class DateTimeFormatterBuilder { } optionalEnd(); - } else if (cur == '{' || cur == '}') { + } else if (cur == '{' || cur == '}' || cur == '#') { throw new IllegalArgumentException("Pattern includes reserved character: '" + cur + "'"); } else { appendLiteral(cur); @@ -1379,10 +1525,12 @@ public final class DateTimeFormatterBuilder { } } + @SuppressWarnings("fallthrough") private void parseField(char cur, int count, TemporalField field) { + boolean standalone = false; switch (cur) { + case 'u': case 'y': - case 'Y': if (count == 2) { appendValueReduced(field, 2, 2000); } else if (count < 4) { @@ -1391,31 +1539,55 @@ public final class DateTimeFormatterBuilder { appendValue(field, count, 19, SignStyle.EXCEEDS_PAD); } break; + case 'c': + if (count == 2) { + throw new IllegalArgumentException("Invalid pattern \"cc\""); + } + /*fallthrough*/ + case 'L': + case 'q': + standalone = true; + /*fallthrough*/ case 'M': case 'Q': case 'E': + case 'e': switch (count) { case 1: - appendValue(field); - break; case 2: - appendValue(field, 2); + if (cur == 'c' || cur == 'e') { + appendInternal(new WeekBasedFieldPrinterParser(cur, count)); + } else if (cur == 'E') { + appendText(field, TextStyle.SHORT); + } else { + if (count == 1) { + appendValue(field); + } else { + appendValue(field, 2); + } + } break; case 3: - appendText(field, TextStyle.SHORT); + appendText(field, standalone ? TextStyle.SHORT_STANDALONE : TextStyle.SHORT); break; case 4: - appendText(field, TextStyle.FULL); + appendText(field, standalone ? TextStyle.FULL_STANDALONE : TextStyle.FULL); break; case 5: - appendText(field, TextStyle.NARROW); + appendText(field, standalone ? TextStyle.NARROW_STANDALONE : TextStyle.NARROW); break; default: throw new IllegalArgumentException("Too many pattern letters: " + cur); } break; - case 'G': case 'a': + if (count == 1) { + appendText(field, TextStyle.SHORT); + } else { + throw new IllegalArgumentException("Too many pattern letters: " + cur); + } + break; + case 'G': switch (count) { case 1: case 2: @@ -1435,6 +1607,37 @@ public final class DateTimeFormatterBuilder { case 'S': appendFraction(NANO_OF_SECOND, count, count, false); break; + case 'F': + if (count == 1) { + appendValue(field); + } else { + throw new IllegalArgumentException("Too many pattern letters: " + cur); + } + break; + case 'd': + case 'h': + case 'H': + case 'k': + case 'K': + case 'm': + case 's': + if (count == 1) { + appendValue(field); + } else if (count == 2) { + appendValue(field, count); + } else { + throw new IllegalArgumentException("Too many pattern letters: " + cur); + } + break; + case 'D': + if (count == 1) { + appendValue(field); + } else if (count <= 3) { + appendValue(field, count); + } else { + throw new IllegalArgumentException("Too many pattern letters: " + cur); + } + break; default: if (count == 1) { appendValue(field); @@ -1448,44 +1651,43 @@ public final class DateTimeFormatterBuilder { /** Map of letters to fields. */ private static final Map FIELD_MAP = new HashMap<>(); static { - FIELD_MAP.put('G', ChronoField.ERA); // Java, LDML (different to both for 1/2 chars) - FIELD_MAP.put('y', ChronoField.YEAR); // LDML - // FIELD_MAP.put('y', ChronoField.YEAR_OF_ERA); // Java, LDML // TODO redefine from above - // FIELD_MAP.put('u', ChronoField.YEAR); // LDML // TODO - // FIELD_MAP.put('Y', IsoFields.WEEK_BASED_YEAR); // Java7, LDML (needs localized week number) // TODO + // SDF = SimpleDateFormat + FIELD_MAP.put('G', ChronoField.ERA); // SDF, LDML (different to both for 1/2 chars) + FIELD_MAP.put('y', ChronoField.YEAR_OF_ERA); // SDF, LDML + FIELD_MAP.put('u', ChronoField.YEAR); // LDML (different in SDF) FIELD_MAP.put('Q', IsoFields.QUARTER_OF_YEAR); // LDML (removed quarter from 310) - FIELD_MAP.put('M', ChronoField.MONTH_OF_YEAR); // Java, LDML - // FIELD_MAP.put('w', WeekFields.weekOfYear()); // Java, LDML (needs localized week number) - // FIELD_MAP.put('W', WeekFields.weekOfMonth()); // Java, LDML (needs localized week number) - FIELD_MAP.put('D', ChronoField.DAY_OF_YEAR); // Java, LDML - FIELD_MAP.put('d', ChronoField.DAY_OF_MONTH); // Java, LDML - FIELD_MAP.put('F', ChronoField.ALIGNED_WEEK_OF_MONTH); // Java, LDML - FIELD_MAP.put('E', ChronoField.DAY_OF_WEEK); // Java, LDML (different to both for 1/2 chars) - // FIELD_MAP.put('e', WeekFields.dayOfWeek()); // LDML (needs localized week number) - FIELD_MAP.put('a', ChronoField.AMPM_OF_DAY); // Java, LDML - FIELD_MAP.put('H', ChronoField.HOUR_OF_DAY); // Java, LDML - FIELD_MAP.put('k', ChronoField.CLOCK_HOUR_OF_DAY); // Java, LDML - FIELD_MAP.put('K', ChronoField.HOUR_OF_AMPM); // Java, LDML - FIELD_MAP.put('h', ChronoField.CLOCK_HOUR_OF_AMPM); // Java, LDML - FIELD_MAP.put('m', ChronoField.MINUTE_OF_HOUR); // Java, LDML - FIELD_MAP.put('s', ChronoField.SECOND_OF_MINUTE); // Java, LDML - FIELD_MAP.put('S', ChronoField.NANO_OF_SECOND); // LDML (Java uses milli-of-second number) + FIELD_MAP.put('q', IsoFields.QUARTER_OF_YEAR); // LDML (stand-alone) + FIELD_MAP.put('M', ChronoField.MONTH_OF_YEAR); // SDF, LDML + FIELD_MAP.put('L', ChronoField.MONTH_OF_YEAR); // SDF, LDML (stand-alone) + FIELD_MAP.put('D', ChronoField.DAY_OF_YEAR); // SDF, LDML + FIELD_MAP.put('d', ChronoField.DAY_OF_MONTH); // SDF, LDML + FIELD_MAP.put('F', ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH); // SDF, LDML + FIELD_MAP.put('E', ChronoField.DAY_OF_WEEK); // SDF, LDML (different to both for 1/2 chars) + FIELD_MAP.put('c', ChronoField.DAY_OF_WEEK); // LDML (stand-alone) + FIELD_MAP.put('e', ChronoField.DAY_OF_WEEK); // LDML (needs localized week number) + FIELD_MAP.put('a', ChronoField.AMPM_OF_DAY); // SDF, LDML + FIELD_MAP.put('H', ChronoField.HOUR_OF_DAY); // SDF, LDML + FIELD_MAP.put('k', ChronoField.CLOCK_HOUR_OF_DAY); // SDF, LDML + FIELD_MAP.put('K', ChronoField.HOUR_OF_AMPM); // SDF, LDML + FIELD_MAP.put('h', ChronoField.CLOCK_HOUR_OF_AMPM); // SDF, LDML + FIELD_MAP.put('m', ChronoField.MINUTE_OF_HOUR); // SDF, LDML + FIELD_MAP.put('s', ChronoField.SECOND_OF_MINUTE); // SDF, LDML + FIELD_MAP.put('S', ChronoField.NANO_OF_SECOND); // LDML (SDF uses milli-of-second number) FIELD_MAP.put('A', ChronoField.MILLI_OF_DAY); // LDML FIELD_MAP.put('n', ChronoField.NANO_OF_SECOND); // 310 (proposed for LDML) FIELD_MAP.put('N', ChronoField.NANO_OF_DAY); // 310 (proposed for LDML) // 310 - z - time-zone names, matches LDML and SimpleDateFormat 1 to 4 // 310 - Z - matches SimpleDateFormat and LDML - // 310 - V - time-zone id, matches proposed LDML + // 310 - V - time-zone id, matches LDML // 310 - p - prefix for padding - // 310 - X - matches proposed LDML, almost matches JavaSDF for 1, exact match 2&3, extended 4&5 - // 310 - x - matches proposed LDML - // Java - u - clashes with LDML, go with LDML (year-proleptic) here + // 310 - X - matches LDML, almost matches SDF for 1, exact match 2&3, extended 4&5 + // 310 - x - matches LDML + // 310 - w, W, and Y are localized forms matching LDML // LDML - U - cycle year name, not supported by 310 yet // LDML - l - deprecated // LDML - j - not relevant // LDML - g - modified-julian-day // LDML - v,V - extended time-zone names - // LDML - q/c/L - standalone quarter/day-of-week/month } //----------------------------------------------------------------------- @@ -1632,10 +1834,12 @@ public final class DateTimeFormatterBuilder { //----------------------------------------------------------------------- /** - * Completes this builder by creating the DateTimeFormatter using the default locale. + * Completes this builder by creating the {@code DateTimeFormatter} + * using the default locale. *

    - * This will create a formatter with the {@link Locale#getDefault(Locale.Category) default FORMAT locale}. + * This will create a formatter with the {@linkplain Locale#getDefault(Locale.Category) default FORMAT locale}. * Numbers will be printed and parsed using the standard non-localized set of symbols. + * The resolver style will be {@link ResolverStyle#SMART SMART}. *

    * Calling this method will end any open optional sections by repeatedly * calling {@link #optionalEnd()} before creating the formatter. @@ -1650,10 +1854,12 @@ public final class DateTimeFormatterBuilder { } /** - * Completes this builder by creating the DateTimeFormatter using the specified locale. + * Completes this builder by creating the {@code DateTimeFormatter} + * using the specified locale. *

    * This will create a formatter with the specified locale. * Numbers will be printed and parsed using the standard non-localized set of symbols. + * The resolver style will be {@link ResolverStyle#SMART SMART}. *

    * Calling this method will end any open optional sections by repeatedly * calling {@link #optionalEnd()} before creating the formatter. @@ -1665,12 +1871,35 @@ public final class DateTimeFormatterBuilder { * @return the created formatter, not null */ public DateTimeFormatter toFormatter(Locale locale) { + return toFormatter(locale, ResolverStyle.SMART, null); + } + + /** + * Completes this builder by creating the formatter. + * This uses the default locale. + * + * @param resolverStyle the resolver style to use, not null + * @return the created formatter, not null + */ + DateTimeFormatter toFormatter(ResolverStyle resolverStyle, Chronology chrono) { + return toFormatter(Locale.getDefault(Locale.Category.FORMAT), resolverStyle, chrono); + } + + /** + * Completes this builder by creating the formatter. + * + * @param locale the locale to use for formatting, not null + * @param chrono the chronology to use, may be null + * @return the created formatter, not null + */ + private DateTimeFormatter toFormatter(Locale locale, ResolverStyle resolverStyle, Chronology chrono) { Objects.requireNonNull(locale, "locale"); while (active.parent != null) { optionalEnd(); } CompositePrinterParser pp = new CompositePrinterParser(printerParsers, false); - return new DateTimeFormatter(pp, locale, DateTimeFormatSymbols.STANDARD, null, null); + return new DateTimeFormatter(pp, locale, DateTimeFormatSymbols.STANDARD, + resolverStyle, null, chrono, null); } //----------------------------------------------------------------------- @@ -1940,6 +2169,31 @@ public final class DateTimeFormatterBuilder { } } + //----------------------------------------------------------------------- + /** + * Defaults a value into the parse if not currently present. + */ + static class DefaultValueParser implements DateTimePrinterParser { + private final TemporalField field; + private final long value; + + DefaultValueParser(TemporalField field, long value) { + this.field = field; + this.value = value; + } + + public boolean format(DateTimePrintContext context, StringBuilder buf) { + return true; + } + + public int parse(DateTimeParseContext context, CharSequence text, int position) { + if (context.getParsed(field) == null) { + context.setParsedField(field, value, position, position); + } + return position; + } + } + //----------------------------------------------------------------------- /** * Prints or parses a character literal. @@ -2104,13 +2358,7 @@ public final class DateTimeFormatterBuilder { @Override public boolean format(DateTimePrintContext context, StringBuilder buf) { - Chronology chrono = context.getTemporal().query(Queries.chronology()); - Long valueLong; - if (chrono == JapaneseChronology.INSTANCE && field == ChronoField.YEAR) { - valueLong = context.getValue(ChronoField.YEAR_OF_ERA); - } else { - valueLong = context.getValue(field); - } + Long valueLong = context.getValue(field); if (valueLong == null) { return false; } @@ -2281,14 +2529,7 @@ public final class DateTimeFormatterBuilder { * @return the new position */ int setValue(DateTimeParseContext context, long value, int errorPos, int successPos) { - TemporalField f = field; - if (field == ChronoField.YEAR) { - Chronology chrono = context.getEffectiveChronology(); - if (chrono == JapaneseChronology.INSTANCE) { - f = ChronoField.YEAR_OF_ERA; - } - } - return context.setParsedField(f, value, errorPos, successPos); + return context.setParsedField(field, value, errorPos, successPos); } @Override @@ -2570,7 +2811,7 @@ public final class DateTimeFormatterBuilder { return false; } String text; - Chronology chrono = context.getTemporal().query(Queries.chronology()); + Chronology chrono = context.getTemporal().query(TemporalQuery.chronology()); if (chrono == null || chrono == IsoChronology.INSTANCE) { text = provider.getText(field, value, textStyle, context.getLocale()); } else { @@ -2885,6 +3126,167 @@ public final class DateTimeFormatterBuilder { } } + //----------------------------------------------------------------------- + /** + * Prints or parses an offset ID. + */ + static final class LocalizedOffsetIdPrinterParser implements DateTimePrinterParser { + private final TextStyle style; + + /** + * Constructor. + * + * @param style the style, not null + */ + LocalizedOffsetIdPrinterParser(TextStyle style) { + this.style = style; + } + + private static StringBuilder appendHMS(StringBuilder buf, int t) { + return buf.append((char)(t / 10 + '0')) + .append((char)(t % 10 + '0')); + } + + @Override + public boolean format(DateTimePrintContext context, StringBuilder buf) { + Long offsetSecs = context.getValue(OFFSET_SECONDS); + if (offsetSecs == null) { + return false; + } + String gmtText = "GMT"; // TODO: get localized version of 'GMT' + if (gmtText != null) { + buf.append(gmtText); + } + int totalSecs = Math.toIntExact(offsetSecs); + if (totalSecs != 0) { + int absHours = Math.abs((totalSecs / 3600) % 100); // anything larger than 99 silently dropped + int absMinutes = Math.abs((totalSecs / 60) % 60); + int absSeconds = Math.abs(totalSecs % 60); + buf.append(totalSecs < 0 ? "-" : "+"); + if (style == TextStyle.FULL) { + appendHMS(buf, absHours); + buf.append(':'); + appendHMS(buf, absMinutes); + if (absSeconds != 0) { + buf.append(':'); + appendHMS(buf, absSeconds); + } + } else { + if (absHours >= 10) { + buf.append((char)(absHours / 10 + '0')); + } + buf.append((char)(absHours % 10 + '0')); + if (absMinutes != 0 || absSeconds != 0) { + buf.append(':'); + appendHMS(buf, absMinutes); + if (absSeconds != 0) { + buf.append(':'); + appendHMS(buf, absSeconds); + } + } + } + } + return true; + } + + int getDigit(CharSequence text, int position) { + char c = text.charAt(position); + if (c < '0' || c > '9') { + return -1; + } + return c - '0'; + } + + @Override + public int parse(DateTimeParseContext context, CharSequence text, int position) { + int pos = position; + int end = pos + text.length(); + String gmtText = "GMT"; // TODO: get localized version of 'GMT' + if (gmtText != null) { + if (!context.subSequenceEquals(text, pos, gmtText, 0, gmtText.length())) { + return ~position; + } + pos += gmtText.length(); + } + // parse normal plus/minus offset + int negative = 0; + if (pos == end) { + return context.setParsedField(OFFSET_SECONDS, 0, position, pos); + } + char sign = text.charAt(pos); // IOOBE if invalid position + if (sign == '+') { + negative = 1; + } else if (sign == '-') { + negative = -1; + } else { + return context.setParsedField(OFFSET_SECONDS, 0, position, pos); + } + pos++; + int h = 0; + int m = 0; + int s = 0; + if (style == TextStyle.FULL) { + int h1 = getDigit(text, pos++); + int h2 = getDigit(text, pos++); + if (h1 < 0 || h2 < 0 || text.charAt(pos++) != ':') { + return ~position; + } + h = h1 * 10 + h2; + int m1 = getDigit(text, pos++); + int m2 = getDigit(text, pos++); + if (m1 < 0 || m2 < 0) { + return ~position; + } + m = m1 * 10 + m2; + if (pos + 2 < end && text.charAt(pos) == ':') { + int s1 = getDigit(text, pos + 1); + int s2 = getDigit(text, pos + 2); + if (s1 >= 0 && s2 >= 0) { + s = s1 * 10 + s2; + pos += 3; + } + } + } else { + h = getDigit(text, pos++); + if (h < 0) { + return ~position; + } + if (pos < end) { + int h2 = getDigit(text, pos); + if (h2 >=0) { + h = h * 10 + h2; + pos++; + } + if (pos + 2 < end && text.charAt(pos) == ':') { + if (pos + 2 < end && text.charAt(pos) == ':') { + int m1 = getDigit(text, pos + 1); + int m2 = getDigit(text, pos + 2); + if (m1 >= 0 && m2 >= 0) { + m = m1 * 10 + m2; + pos += 3; + if (pos + 2 < end && text.charAt(pos) == ':') { + int s1 = getDigit(text, pos + 1); + int s2 = getDigit(text, pos + 2); + if (s1 >= 0 && s2 >= 0) { + s = s1 * 10 + s2; + pos += 3; + } + } + } + } + } + } + } + long offsetSecs = negative * (h * 3600L + m * 60L + s); + return context.setParsedField(OFFSET_SECONDS, offsetSecs, position, pos); + } + + @Override + public String toString() { + return "LocalizedOffset(" + style + ")"; + } + } + //----------------------------------------------------------------------- /** * Prints or parses a zone ID. @@ -2898,7 +3300,7 @@ public final class DateTimeFormatterBuilder { private Set preferredZones; ZoneTextPrinterParser(TextStyle textStyle, Set preferredZones) { - super(Queries.zone(), "ZoneText(" + textStyle + ")"); + super(TemporalQuery.zone(), "ZoneText(" + textStyle + ")"); this.textStyle = Objects.requireNonNull(textStyle, "textStyle"); if (preferredZones != null && preferredZones.size() != 0) { this.preferredZones = new HashSet<>(); @@ -2929,12 +3331,12 @@ public final class DateTimeFormatterBuilder { } names = Arrays.copyOfRange(names, 0, 7); names[5] = - TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG,locale); + TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.LONG, locale); if (names[5] == null) { names[5] = names[0]; // use the id } names[6] = - TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT,locale); + TimeZoneNameUtility.retrieveGenericDisplayName(id, TimeZone.SHORT, locale); if (names[6] == null) { names[6] = names[0]; } @@ -2946,16 +3348,16 @@ public final class DateTimeFormatterBuilder { } switch (type) { case STD: - return names[textStyle.ordinal() + 1]; + return names[textStyle.zoneNameStyleIndex() + 1]; case DST: - return names[textStyle.ordinal() + 3]; + return names[textStyle.zoneNameStyleIndex() + 3]; } - return names[textStyle.ordinal() + 5]; + return names[textStyle.zoneNameStyleIndex() + 5]; } @Override public boolean format(DateTimePrintContext context, StringBuilder buf) { - ZoneId zone = context.getValue(Queries.zoneId()); + ZoneId zone = context.getValue(TemporalQuery.zoneId()); if (zone == null) { return false; } @@ -3507,14 +3909,14 @@ public final class DateTimeFormatterBuilder { @Override public boolean format(DateTimePrintContext context, StringBuilder buf) { - Chronology chrono = context.getValue(Queries.chronology()); + Chronology chrono = context.getValue(TemporalQuery.chronology()); if (chrono == null) { return false; } if (textStyle == null) { buf.append(chrono.getId()); } else { - buf.append(chrono.getId()); // TODO: Use symbols + buf.append(getChronologyName(chrono, context.getLocale())); } return true; } @@ -3529,11 +3931,16 @@ public final class DateTimeFormatterBuilder { Chronology bestMatch = null; int matchLen = -1; for (Chronology chrono : chronos) { - String id = chrono.getId(); - int idLen = id.length(); - if (idLen > matchLen && context.subSequenceEquals(text, position, id, 0, idLen)) { + String name; + if (textStyle == null) { + name = chrono.getId(); + } else { + name = getChronologyName(chrono, context.getLocale()); + } + int nameLen = name.length(); + if (nameLen > matchLen && context.subSequenceEquals(text, position, name, 0, nameLen)) { bestMatch = chrono; - matchLen = idLen; + matchLen = nameLen; } } if (bestMatch == null) { @@ -3542,6 +3949,22 @@ public final class DateTimeFormatterBuilder { context.setParsed(bestMatch); return position + matchLen; } + + /** + * Returns the chronology name of the given chrono in the given locale + * if available, or the chronology Id otherwise. The regular ResourceBundle + * search path is used for looking up the chronology name. + * + * @param chrono the chronology, not null + * @param locale the locale, not null + * @return the chronology name of chrono in locale, or the id if no name is available + * @throws NullPointerException if chrono or locale is null + */ + private String getChronologyName(Chronology chrono, Locale locale) { + String key = "calendarname." + chrono.getCalendarType(); + String name = DateTimeTextProvider.getLocalizedResource(key, locale); + return name != null ? name : chrono.getId(); + } } //----------------------------------------------------------------------- @@ -3549,6 +3972,9 @@ public final class DateTimeFormatterBuilder { * Prints or parses a localized pattern. */ static final class LocalizedPrinterParser implements DateTimePrinterParser { + /** Cache of formatters. */ + private static final ConcurrentMap FORMATTER_CACHE = new ConcurrentHashMap<>(16, 0.75f, 2); + private final FormatStyle dateStyle; private final FormatStyle timeStyle; @@ -3578,6 +4004,9 @@ public final class DateTimeFormatterBuilder { /** * Gets the formatter to use. + *

    + * The formatter will be the most appropriate to use for the date and time style in the locale. + * For example, some locales will use the month name while others will use the number. * * @param locale the locale to use, not null * @param chrono the chronology to use, not null @@ -3585,8 +4014,32 @@ public final class DateTimeFormatterBuilder { * @throws IllegalArgumentException if the formatter cannot be found */ private DateTimeFormatter formatter(Locale locale, Chronology chrono) { - return DateTimeFormatStyleProvider.getInstance() - .getFormatter(dateStyle, timeStyle, chrono, locale); + String key = chrono.getId() + '|' + locale.toString() + '|' + dateStyle + timeStyle; + DateTimeFormatter formatter = FORMATTER_CACHE.get(key); + if (formatter == null) { + LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased().getLocaleResources(locale); + String pattern = lr.getJavaTimeDateTimePattern( + convertStyle(timeStyle), convertStyle(dateStyle), chrono.getCalendarType()); + formatter = new DateTimeFormatterBuilder().appendPattern(pattern).toFormatter(locale); + DateTimeFormatter old = FORMATTER_CACHE.putIfAbsent(key, formatter); + if (old != null) { + formatter = old; + } + } + return formatter; + } + + /** + * Converts the given FormatStyle to the java.text.DateFormat style. + * + * @param style the FormatStyle style + * @return the int style, or -1 if style is null, indicating unrequired + */ + private int convertStyle(FormatStyle style) { + if (style == null) { + return -1; + } + return style.ordinal(); // indices happen to align } @Override @@ -3596,7 +4049,6 @@ public final class DateTimeFormatterBuilder { } } - //----------------------------------------------------------------------- /** * Prints or parses a localized pattern from a localized field. @@ -3641,14 +4093,23 @@ public final class DateTimeFormatterBuilder { WeekFields weekDef = WeekFields.of(locale); TemporalField field = null; switch (chr) { + case 'Y': + field = weekDef.weekBasedYear(); + if (count == 2) { + return new ReducedPrinterParser(field, 2, 2000); + } else { + return new NumberPrinterParser(field, count, 19, + (count < 4) ? SignStyle.NORMAL : SignStyle.EXCEEDS_PAD, -1); + } case 'e': + case 'c': field = weekDef.dayOfWeek(); break; case 'w': - field = weekDef.weekOfMonth(); + field = weekDef.weekOfWeekBasedYear(); break; case 'W': - field = weekDef.weekOfYear(); + field = weekDef.weekOfMonth(); break; default: throw new IllegalStateException("unreachable"); @@ -3658,11 +4119,41 @@ public final class DateTimeFormatterBuilder { @Override public String toString() { - return String.format("WeekBased(%c%d)", chr, count); + StringBuilder sb = new StringBuilder(30); + sb.append("Localized("); + if (chr == 'Y') { + if (count == 1) { + sb.append("WeekBasedYear"); + } else if (count == 2) { + sb.append("ReducedValue(WeekBasedYear,2,2000)"); + } else { + sb.append("WeekBasedYear,").append(count).append(",") + .append(19).append(",") + .append((count < 4) ? SignStyle.NORMAL : SignStyle.EXCEEDS_PAD); + } + } else { + switch (chr) { + case 'c': + case 'e': + sb.append("DayOfWeek"); + break; + case 'w': + sb.append("WeekOfWeekBasedYear"); + break; + case 'W': + sb.append("WeekOfMonth"); + break; + default: + break; + } + sb.append(","); + sb.append(count); + } + sb.append(")"); + return sb.toString(); } } - //------------------------------------------------------------------------- /** * Length comparator. @@ -3673,5 +4164,4 @@ public final class DateTimeFormatterBuilder { return str1.length() == str2.length() ? str1.compareTo(str2) : str1.length() - str2.length(); } }; - } diff --git a/jdk/src/share/classes/java/time/format/DateTimeParseContext.java b/jdk/src/share/classes/java/time/format/DateTimeParseContext.java index 62f80dba377..f2e3ff3a300 100644 --- a/jdk/src/share/classes/java/time/format/DateTimeParseContext.java +++ b/jdk/src/share/classes/java/time/format/DateTimeParseContext.java @@ -61,19 +61,12 @@ */ package java.time.format; -import java.time.DateTimeException; import java.time.ZoneId; import java.time.chrono.Chronology; import java.time.chrono.IsoChronology; -import java.time.temporal.ChronoField; -import java.time.temporal.Queries; -import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; -import java.time.temporal.TemporalQuery; import java.util.ArrayList; -import java.util.HashMap; import java.util.Locale; -import java.util.Map; import java.util.Objects; /** @@ -83,8 +76,8 @@ import java.util.Objects; * It has the ability to store and retrieve the parsed values and manage optional segments. * It also provides key information to the parsing methods. *

    - * Once parsing is complete, the {@link #toBuilder()} is typically used - * to obtain a builder that can combine the separate parsed fields into meaningful values. + * Once parsing is complete, the {@link #toParsed()} is used to obtain the data. + * It contains a method to resolve the separate parsed fields into meaningful values. * *

    Specification for implementors

    * This class is a mutable context intended for use from a single thread. @@ -93,7 +86,7 @@ import java.util.Objects; * * @since 1.8 */ -final class DateTimeParseContext implements TemporalAccessor { +final class DateTimeParseContext { /** * The formatter, not null. @@ -306,6 +299,17 @@ final class DateTimeParseContext implements TemporalAccessor { return parsed.get(parsed.size() - 1); } + /** + * Gets the result of the parse. + * + * @return the result of the parse, not null + */ + Parsed toParsed() { + Parsed parsed = currentParsed(); + parsed.effectiveChrono = getEffectiveChronology(); + return parsed; + } + //----------------------------------------------------------------------- /** * Gets the first value that was parsed for the specified field. @@ -366,111 +370,6 @@ final class DateTimeParseContext implements TemporalAccessor { currentParsed().zone = zone; } - //----------------------------------------------------------------------- - /** - * Returns a {@code DateTimeBuilder} that can be used to interpret - * the results of the parse. - *

    - * This method is typically used once parsing is complete to obtain the parsed data. - * Parsing will typically result in separate fields, such as year, month and day. - * The returned builder can be used to combine the parsed data into meaningful - * objects such as {@code LocalDate}, potentially applying complex processing - * to handle invalid parsed data. - * - * @return a new builder with the results of the parse, not null - */ - DateTimeBuilder toBuilder() { - Parsed parsed = currentParsed(); - DateTimeBuilder builder = new DateTimeBuilder(); - for (Map.Entry fv : parsed.fieldValues.entrySet()) { - builder.addFieldValue(fv.getKey(), fv.getValue()); - } - builder.addObject(getEffectiveChronology()); - if (parsed.zone != null) { - builder.addObject(parsed.zone); - } - return builder; - } - - /** - * Resolves the fields in this context. - * - * @return this, for method chaining - * @throws DateTimeException if resolving one field results in a value for - * another field that is in conflict - */ - DateTimeParseContext resolveFields() { - Parsed data = currentParsed(); - outer: - while (true) { - for (Map.Entry entry : data.fieldValues.entrySet()) { - TemporalField targetField = entry.getKey(); - Map changes = targetField.resolve(this, entry.getValue()); - if (changes != null) { - resolveMakeChanges(data, targetField, changes); - data.fieldValues.remove(targetField); // helps avoid infinite loops - continue outer; // have to restart to avoid concurrent modification - } - } - break; - } - return this; - } - - private void resolveMakeChanges(Parsed data, TemporalField targetField, Map changes) { - for (Map.Entry change : changes.entrySet()) { - TemporalField changeField = change.getKey(); - Long changeValue = change.getValue(); - Objects.requireNonNull(changeField, "changeField"); - if (changeValue != null) { - Long old = currentParsed().fieldValues.put(changeField, changeValue); - if (old != null && old.longValue() != changeValue.longValue()) { - throw new DateTimeException("Conflict found: " + changeField + " " + old + - " differs from " + changeField + " " + changeValue + - " while resolving " + targetField); - } - } else { - data.fieldValues.remove(changeField); - } - } - } - - //----------------------------------------------------------------------- - // TemporalAccessor methods - // should only to be used once parsing is complete - @Override - public boolean isSupported(TemporalField field) { - if (currentParsed().fieldValues.containsKey(field)) { - return true; - } - return (field instanceof ChronoField == false) && field.isSupportedBy(this); - } - - @Override - public long getLong(TemporalField field) { - Long value = currentParsed().fieldValues.get(field); - if (value != null) { - return value; - } - if (field instanceof ChronoField) { - throw new DateTimeException("Unsupported field: " + field.getName()); - } - return field.getFrom(this); - } - - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.chronology()) { - return (R) currentParsed().chrono; - } else if (query == Queries.zoneId()) { - return (R) currentParsed().zone; - } else if (query == Queries.precision()) { - return null; - } - return query.queryFrom(this); - } - //----------------------------------------------------------------------- /** * Returns a string version of the context for debugging. @@ -482,27 +381,4 @@ final class DateTimeParseContext implements TemporalAccessor { return currentParsed().toString(); } - //----------------------------------------------------------------------- - /** - * Temporary store of parsed data. - */ - private static final class Parsed { - Chronology chrono = null; - ZoneId zone = null; - final Map fieldValues = new HashMap<>(); - private Parsed() { - } - protected Parsed copy() { - Parsed cloned = new Parsed(); - cloned.chrono = this.chrono; - cloned.zone = this.zone; - cloned.fieldValues.putAll(this.fieldValues); - return cloned; - } - @Override - public String toString() { - return fieldValues.toString() + "," + chrono + "," + zone; - } - } - } diff --git a/jdk/src/share/classes/java/time/format/DateTimePrintContext.java b/jdk/src/share/classes/java/time/format/DateTimePrintContext.java index 060d8dd8890..8124fc85c98 100644 --- a/jdk/src/share/classes/java/time/format/DateTimePrintContext.java +++ b/jdk/src/share/classes/java/time/format/DateTimePrintContext.java @@ -63,14 +63,16 @@ package java.time.format; import static java.time.temporal.ChronoField.EPOCH_DAY; import static java.time.temporal.ChronoField.INSTANT_SECONDS; +import static java.time.temporal.ChronoField.OFFSET_SECONDS; import java.time.DateTimeException; import java.time.Instant; import java.time.ZoneId; -import java.time.chrono.Chronology; -import java.time.temporal.ChronoField; +import java.time.ZoneOffset; import java.time.chrono.ChronoLocalDate; -import java.time.temporal.Queries; +import java.time.chrono.Chronology; +import java.time.chrono.IsoChronology; +import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -118,20 +120,20 @@ final class DateTimePrintContext { } private static TemporalAccessor adjust(final TemporalAccessor temporal, DateTimeFormatter formatter) { - // normal case first + // normal case first (early return is an optimization) Chronology overrideChrono = formatter.getChronology(); ZoneId overrideZone = formatter.getZone(); if (overrideChrono == null && overrideZone == null) { return temporal; } - // ensure minimal change - Chronology temporalChrono = Chronology.from(temporal); // default to ISO, handles Instant - ZoneId temporalZone = temporal.query(Queries.zone()); // zone then offset, handles OffsetDateTime - if (temporal.isSupported(EPOCH_DAY) == false || Objects.equals(overrideChrono, temporalChrono)) { + // ensure minimal change (early return is an optimization) + Chronology temporalChrono = temporal.query(TemporalQuery.chronology()); + ZoneId temporalZone = temporal.query(TemporalQuery.zoneId()); + if (Objects.equals(overrideChrono, temporalChrono)) { overrideChrono = null; } - if (temporal.isSupported(INSTANT_SECONDS) == false || Objects.equals(overrideZone, temporalZone)) { + if (Objects.equals(overrideZone, temporalZone)) { overrideZone = null; } if (overrideChrono == null && overrideZone == null) { @@ -139,53 +141,83 @@ final class DateTimePrintContext { } // make adjustment - if (overrideChrono != null && overrideZone != null) { - return overrideChrono.zonedDateTime(Instant.from(temporal), overrideZone); - } else if (overrideZone != null) { - return temporalChrono.zonedDateTime(Instant.from(temporal), overrideZone); - } else { // overrideChrono != null - // need class here to handle non-standard cases - final ChronoLocalDate date = overrideChrono.date(temporal); - return new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - return temporal.isSupported(field); - } - @Override - public ValueRange range(TemporalField field) { - if (field instanceof ChronoField) { - if (((ChronoField) field).isDateField()) { - return date.range(field); - } else { - return temporal.range(field); - } - } - return field.rangeRefinedBy(this); - } - @Override - public long getLong(TemporalField field) { - if (field instanceof ChronoField) { - if (((ChronoField) field).isDateField()) { - return date.getLong(field); - } else { - return temporal.getLong(field); - } - } - return field.getFrom(this); - } - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.chronology()) { - return (R) date.getChronology(); - } - if (query == Queries.zoneId() || query == Queries.precision()) { - return temporal.query(query); - } - return query.queryFrom(this); - } - }; + final Chronology effectiveChrono = (overrideChrono != null ? overrideChrono : temporalChrono); + if (overrideZone != null) { + // if have zone and instant, calculation is simple, defaulting chrono if necessary + if (temporal.isSupported(INSTANT_SECONDS)) { + Chronology chrono = (effectiveChrono != null ? effectiveChrono : IsoChronology.INSTANCE); + return chrono.zonedDateTime(Instant.from(temporal), overrideZone); + } + // block changing zone on OffsetTime, and similar problem cases + if (overrideZone.normalized() instanceof ZoneOffset && temporal.isSupported(OFFSET_SECONDS) && + temporal.get(OFFSET_SECONDS) != overrideZone.getRules().getOffset(Instant.EPOCH).getTotalSeconds()) { + throw new DateTimeException("Unable to apply override zone '" + overrideZone + + "' because the temporal object being formatted has a different offset but" + + " does not represent an instant: " + temporal); + } } + final ZoneId effectiveZone = (overrideZone != null ? overrideZone : temporalZone); + final ChronoLocalDate effectiveDate; + if (overrideChrono != null) { + if (temporal.isSupported(EPOCH_DAY)) { + effectiveDate = effectiveChrono.date(temporal); + } else { + // check for date fields other than epoch-day, ignoring case of converting null to ISO + if (!(overrideChrono == IsoChronology.INSTANCE && temporalChrono == null)) { + for (ChronoField f : ChronoField.values()) { + if (f.isDateBased() && temporal.isSupported(f)) { + throw new DateTimeException("Unable to apply override chronology '" + overrideChrono + + "' because the temporal object being formatted contains date fields but" + + " does not represent a whole date: " + temporal); + } + } + } + effectiveDate = null; + } + } else { + effectiveDate = null; + } + + // combine available data + // this is a non-standard temporal that is almost a pure delegate + // this better handles map-like underlying temporal instances + return new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + if (effectiveDate != null && field.isDateBased()) { + return effectiveDate.isSupported(field); + } + return temporal.isSupported(field); + } + @Override + public ValueRange range(TemporalField field) { + if (effectiveDate != null && field.isDateBased()) { + return effectiveDate.range(field); + } + return temporal.range(field); + } + @Override + public long getLong(TemporalField field) { + if (effectiveDate != null && field.isDateBased()) { + return effectiveDate.getLong(field); + } + return temporal.getLong(field); + } + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.chronology()) { + return (R) effectiveChrono; + } + if (query == TemporalQuery.zoneId()) { + return (R) effectiveZone; + } + if (query == TemporalQuery.precision()) { + return temporal.query(query); + } + return query.queryFrom(this); + } + }; } //----------------------------------------------------------------------- diff --git a/jdk/src/share/classes/java/time/format/DateTimeTextProvider.java b/jdk/src/share/classes/java/time/format/DateTimeTextProvider.java index 5127f0c80b5..7262c5b3341 100644 --- a/jdk/src/share/classes/java/time/format/DateTimeTextProvider.java +++ b/jdk/src/share/classes/java/time/format/DateTimeTextProvider.java @@ -70,6 +70,7 @@ import java.time.chrono.Chronology; import java.time.chrono.IsoChronology; import java.time.chrono.JapaneseChronology; import java.time.temporal.ChronoField; +import java.time.temporal.IsoFields; import java.time.temporal.TemporalField; import java.util.AbstractMap.SimpleImmutableEntry; import java.util.ArrayList; @@ -82,10 +83,13 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; +import java.util.ResourceBundle; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import sun.util.locale.provider.CalendarDataUtility; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; /** * A provider to obtain the textual form of a date-time field. @@ -141,15 +145,6 @@ class DateTimeTextProvider { return null; } - private static int toStyle(TextStyle style) { - if (style == TextStyle.FULL) { - return Calendar.LONG_FORMAT; - } else if (style == TextStyle.SHORT) { - return Calendar.SHORT_FORMAT; - } - return Calendar.NARROW_STANDALONE; - } - /** * Gets the text for the specified chrono, field, locale and style * for the purpose of formatting. @@ -158,7 +153,7 @@ class DateTimeTextProvider { * The null return value should be used if there is no applicable text, or * if the text would be a numeric representation of the value. * - * @param chrono the Chronology to get text for, not null + * @param chrono the Chronology to get text for, not null * @param field the field to get text for, not null * @param value the field value to get text for, not null * @param style the style to get text for, not null @@ -200,8 +195,8 @@ class DateTimeTextProvider { } else { return null; } - return CalendarDataUtility.retrieveCldrFieldValueName( - chrono.getCalendarType(), fieldIndex, fieldValue, toStyle(style), locale); + return CalendarDataUtility.retrieveJavaTimeFieldValueName( + chrono.getCalendarType(), fieldIndex, fieldValue, style.toCalendarStyle(), locale); } /** @@ -238,7 +233,7 @@ class DateTimeTextProvider { * if the text would be a numeric representation of the value. * Text can only be parsed if all the values for that field-style-locale combination are unique. * - * @param chrono the Chronology to get text for, not null + * @param chrono the Chronology to get text for, not null * @param field the field to get text for, not null * @param style the style to get text for, null for all parsable text * @param locale the locale to get text for, not null @@ -270,17 +265,17 @@ class DateTimeTextProvider { return null; } - Map map = CalendarDataUtility.retrieveCldrFieldValueNames( - chrono.getCalendarType(), fieldIndex, toStyle(style), locale); + int calendarStyle = (style == null) ? Calendar.ALL_STYLES : style.toCalendarStyle(); + Map map = CalendarDataUtility.retrieveJavaTimeFieldValueNames( + chrono.getCalendarType(), fieldIndex, calendarStyle, locale); if (map == null) { return null; } - List> list = new ArrayList<>(map.size()); switch (fieldIndex) { case Calendar.ERA: - for (String key : map.keySet()) { - int era = map.get(key); + for (Map.Entry entry : map.entrySet()) { + int era = entry.getValue(); if (chrono == JapaneseChronology.INSTANCE) { if (era == 0) { era = -999; @@ -288,22 +283,22 @@ class DateTimeTextProvider { era -= 2; } } - list.add(createEntry(key, (long) era)); + list.add(createEntry(entry.getKey(), (long)era)); } break; case Calendar.MONTH: - for (String key : map.keySet()) { - list.add(createEntry(key, (long)(map.get(key) + 1))); + for (Map.Entry entry : map.entrySet()) { + list.add(createEntry(entry.getKey(), (long)(entry.getValue() + 1))); } break; case Calendar.DAY_OF_WEEK: - for (String key : map.keySet()) { - list.add(createEntry(key, (long)toWeekDay(map.get(key)))); + for (Map.Entry entry : map.entrySet()) { + list.add(createEntry(entry.getKey(), (long)toWeekDay(entry.getValue()))); } break; default: - for (String key : map.keySet()) { - list.add(createEntry(key, (long)map.get(key))); + for (Map.Entry entry : map.entrySet()) { + list.add(createEntry(entry.getKey(), (long)entry.getValue())); } break; } @@ -333,11 +328,47 @@ class DateTimeTextProvider { Map> styleMap = new HashMap<>(); if (field == ERA) { for (TextStyle textStyle : TextStyle.values()) { + if (textStyle.isStandalone()) { + // Stand-alone isn't applicable to era names. + continue; + } + Map displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( + "gregory", Calendar.ERA, textStyle.toCalendarStyle(), locale); + if (displayNames != null) { + Map map = new HashMap<>(); + for (Entry entry : displayNames.entrySet()) { + map.put((long) entry.getValue(), entry.getKey()); + } + if (!map.isEmpty()) { + styleMap.put(textStyle, map); + } + } + } + return new LocaleStore(styleMap); + } + + if (field == MONTH_OF_YEAR) { + for (TextStyle textStyle : TextStyle.values()) { + Map displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( + "gregory", Calendar.MONTH, textStyle.toCalendarStyle(), locale); Map map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.ERA, toStyle(textStyle), locale).entrySet()) { - map.put((long) entry.getValue(), entry.getKey()); + if (displayNames != null) { + for (Entry entry : displayNames.entrySet()) { + map.put((long) (entry.getValue() + 1), entry.getKey()); + } + + } else { + // Narrow names may have duplicated names, such as "J" for January, Jun, July. + // Get names one by one in that case. + for (int month = Calendar.JANUARY; month <= Calendar.DECEMBER; month++) { + String name; + name = CalendarDataUtility.retrieveJavaTimeFieldValueName( + "gregory", Calendar.MONTH, month, textStyle.toCalendarStyle(), locale); + if (name == null) { + break; + } + map.put((long) (month + 1), name); + } } if (!map.isEmpty()) { styleMap.put(textStyle, map); @@ -346,72 +377,77 @@ class DateTimeTextProvider { return new LocaleStore(styleMap); } - if (field == MONTH_OF_YEAR) { - Map map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.MONTH, Calendar.LONG_FORMAT, locale).entrySet()) { - map.put((long) (entry.getValue() + 1), entry.getKey()); - } - styleMap.put(TextStyle.FULL, map); + if (field == DAY_OF_WEEK) { + for (TextStyle textStyle : TextStyle.values()) { + Map displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( + "gregory", Calendar.DAY_OF_WEEK, textStyle.toCalendarStyle(), locale); + Map map = new HashMap<>(); + if (displayNames != null) { + for (Entry entry : displayNames.entrySet()) { + map.put((long)toWeekDay(entry.getValue()), entry.getKey()); + } - map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.MONTH, Calendar.SHORT_FORMAT, locale).entrySet()) { - map.put((long) (entry.getValue() + 1), entry.getKey()); - } - styleMap.put(TextStyle.SHORT, map); - - map = new HashMap<>(); - for (int month = Calendar.JANUARY; month <= Calendar.DECEMBER; month++) { - String name; - name = CalendarDataUtility.retrieveCldrFieldValueName( - "gregory", Calendar.MONTH, month, Calendar.NARROW_STANDALONE, locale); - if (name != null) { - map.put((long)(month + 1), name); + } else { + // Narrow names may have duplicated names, such as "S" for Sunday and Saturday. + // Get names one by one in that case. + for (int wday = Calendar.SUNDAY; wday <= Calendar.SATURDAY; wday++) { + String name; + name = CalendarDataUtility.retrieveJavaTimeFieldValueName( + "gregory", Calendar.DAY_OF_WEEK, wday, textStyle.toCalendarStyle(), locale); + if (name == null) { + break; + } + map.put((long)toWeekDay(wday), name); + } + } + if (!map.isEmpty()) { + styleMap.put(textStyle, map); } } - if (!map.isEmpty()) { - styleMap.put(TextStyle.NARROW, map); - } - return new LocaleStore(styleMap); - } - - if (field == DAY_OF_WEEK) { - Map map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.DAY_OF_WEEK, Calendar.LONG_FORMAT, locale).entrySet()) { - map.put((long)toWeekDay(entry.getValue()), entry.getKey()); - } - styleMap.put(TextStyle.FULL, map); - map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.DAY_OF_WEEK, Calendar.SHORT_FORMAT, locale).entrySet()) { - map.put((long) toWeekDay(entry.getValue()), entry.getKey()); - } - styleMap.put(TextStyle.SHORT, map); - map = new HashMap<>(); - for (int wday = Calendar.SUNDAY; wday <= Calendar.SATURDAY; wday++) { - map.put((long) toWeekDay(wday), - CalendarDataUtility.retrieveCldrFieldValueName( - "gregory", Calendar.DAY_OF_WEEK, wday, Calendar.NARROW_FORMAT, locale)); - } - styleMap.put(TextStyle.NARROW, map); return new LocaleStore(styleMap); } if (field == AMPM_OF_DAY) { - Map map = new HashMap<>(); - for (Entry entry : - CalendarDataUtility.retrieveCldrFieldValueNames( - "gregory", Calendar.AM_PM, Calendar.LONG_FORMAT, locale).entrySet()) { - map.put((long) entry.getValue(), entry.getKey()); + for (TextStyle textStyle : TextStyle.values()) { + if (textStyle.isStandalone()) { + // Stand-alone isn't applicable to AM/PM. + continue; + } + Map displayNames = CalendarDataUtility.retrieveJavaTimeFieldValueNames( + "gregory", Calendar.AM_PM, textStyle.toCalendarStyle(), locale); + if (displayNames != null) { + Map map = new HashMap<>(); + for (Entry entry : displayNames.entrySet()) { + map.put((long) entry.getValue(), entry.getKey()); + } + if (!map.isEmpty()) { + styleMap.put(textStyle, map); + } + } + } + return new LocaleStore(styleMap); + } + + if (field == IsoFields.QUARTER_OF_YEAR) { + // The order of keys must correspond to the TextStyle.values() order. + final String[] keys = { + "QuarterNames", + "standalone.QuarterNames", + "QuarterAbbreviations", + "standalone.QuarterAbbreviations", + "QuarterNarrows", + "standalone.QuarterNarrows", + }; + for (int i = 0; i < keys.length; i++) { + String[] names = getLocalizedResource(keys[i], locale); + if (names != null) { + Map map = new HashMap<>(); + for (int q = 0; q < names.length; q++) { + map.put((long) (q + 1), names[q]); + } + styleMap.put(TextStyle.values()[i], map); + } } - styleMap.put(TextStyle.FULL, map); - styleMap.put(TextStyle.SHORT, map); // re-use, as we don't have different data return new LocaleStore(styleMap); } @@ -429,6 +465,23 @@ class DateTimeTextProvider { return new SimpleImmutableEntry<>(text, field); } + /** + * Returns the localized resource of the given key and locale, or null + * if no localized resource is available. + * + * @param key the key of the localized resource, not null + * @param locale the locale, not null + * @return the localized resource, or null if not available + * @throws NullPointerException if key or locale is null + */ + @SuppressWarnings("unchecked") + static T getLocalizedResource(String key, Locale locale) { + LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() + .getLocaleResources(locale); + ResourceBundle rb = lr.getJavaTimeFormatData(); + return rb.containsKey(key) ? (T) rb.getObject(key) : null; + } + /** * Stores the text for a single locale. *

    @@ -457,9 +510,9 @@ class DateTimeTextProvider { this.valueTextMap = valueTextMap; Map>> map = new HashMap<>(); List> allList = new ArrayList<>(); - for (TextStyle style : valueTextMap.keySet()) { + for (Map.Entry> vtmEntry : valueTextMap.entrySet()) { Map> reverse = new HashMap<>(); - for (Map.Entry entry : valueTextMap.get(style).entrySet()) { + for (Map.Entry entry : vtmEntry.getValue().entrySet()) { if (reverse.put(entry.getValue(), createEntry(entry.getValue(), entry.getKey())) != null) { // TODO: BUG: this has no effect continue; // not parsable, try next style @@ -467,7 +520,7 @@ class DateTimeTextProvider { } List> list = new ArrayList<>(reverse.values()); Collections.sort(list, COMPARATOR); - map.put(style, list); + map.put(vtmEntry.getKey(), list); allList.addAll(list); map.put(null, allList); } diff --git a/jdk/src/share/classes/java/time/format/Parsed.java b/jdk/src/share/classes/java/time/format/Parsed.java new file mode 100644 index 00000000000..a35fab1b9d8 --- /dev/null +++ b/jdk/src/share/classes/java/time/format/Parsed.java @@ -0,0 +1,482 @@ +/* + * 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. 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2008-2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package java.time.format; + +import static java.time.temporal.ChronoField.AMPM_OF_DAY; +import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_AMPM; +import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_DAY; +import static java.time.temporal.ChronoField.HOUR_OF_AMPM; +import static java.time.temporal.ChronoField.HOUR_OF_DAY; +import static java.time.temporal.ChronoField.MICRO_OF_DAY; +import static java.time.temporal.ChronoField.MICRO_OF_SECOND; +import static java.time.temporal.ChronoField.MILLI_OF_DAY; +import static java.time.temporal.ChronoField.MILLI_OF_SECOND; +import static java.time.temporal.ChronoField.MINUTE_OF_DAY; +import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; +import static java.time.temporal.ChronoField.NANO_OF_DAY; +import static java.time.temporal.ChronoField.NANO_OF_SECOND; +import static java.time.temporal.ChronoField.SECOND_OF_DAY; +import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; + +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Set; + +/** + * A store of parsed data. + *

    + * This class is used during parsing to collect the data. Part of the parsing process + * involves handling optional blocks and multiple copies of the data get created to + * support the necessary backtracking. + *

    + * Once parsing is completed, this class can be used as the resultant {@code TemporalAccessor}. + * In most cases, it is only exposed once the fields have been resolved. + * + *

    Specification for implementors

    + * This class is a mutable context intended for use from a single thread. + * Usage of the class is thread-safe within standard parsing as a new instance of this class + * is automatically created for each parse and parsing is single-threaded + * + * @since 1.8 + */ +final class Parsed implements TemporalAccessor { + // some fields are accessed using package scope from DateTimeParseContext + + /** + * The parsed fields. + */ + final Map fieldValues = new HashMap<>(); + /** + * The parsed zone. + */ + ZoneId zone; + /** + * The parsed chronology. + */ + Chronology chrono; + /** + * The effective chronology. + */ + Chronology effectiveChrono; + /** + * The resolver style to use. + */ + private ResolverStyle resolverStyle; + /** + * The resolved date. + */ + private ChronoLocalDate date; + /** + * The resolved time. + */ + private LocalTime time; + + /** + * Creates an instance. + */ + Parsed() { + } + + /** + * Creates a copy. + */ + Parsed copy() { + // only copy fields used in parsing stage + Parsed cloned = new Parsed(); + cloned.fieldValues.putAll(this.fieldValues); + cloned.zone = this.zone; + cloned.chrono = this.chrono; + return cloned; + } + + //----------------------------------------------------------------------- + @Override + public boolean isSupported(TemporalField field) { + if (fieldValues.containsKey(field) || + (date != null && date.isSupported(field)) || + (time != null && time.isSupported(field))) { + return true; + } + return field != null && (field instanceof ChronoField == false) && field.isSupportedBy(this); + } + + @Override + public long getLong(TemporalField field) { + Objects.requireNonNull(field, "field"); + Long value = fieldValues.get(field); + if (value != null) { + return value; + } + if (date != null && date.isSupported(field)) { + return date.getLong(field); + } + if (time != null && time.isSupported(field)) { + return time.getLong(field); + } + if (field instanceof ChronoField) { + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); + } + return field.getFrom(this); + } + + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.zoneId()) { + return (R) zone; + } else if (query == TemporalQuery.chronology()) { + return (R) chrono; + } else if (query == TemporalQuery.localDate()) { + return (R) (date != null ? LocalDate.from(date) : null); + } else if (query == TemporalQuery.localTime()) { + return (R) time; + } else if (query == TemporalQuery.zone() || query == TemporalQuery.offset()) { + return query.queryFrom(this); + } else if (query == TemporalQuery.precision()) { + return null; // not a complete date/time + } + // inline TemporalAccessor.super.query(query) as an optimization + // non-JDK classes are not permitted to make this optimization + return query.queryFrom(this); + } + + //----------------------------------------------------------------------- + /** + * Resolves the fields in this context. + * + * @param resolverStyle the resolver style, not null + * @param resolverFields the fields to use for resolving, null for all fields + * @return this, for method chaining + * @throws DateTimeException if resolving one field results in a value for + * another field that is in conflict + */ + TemporalAccessor resolve(ResolverStyle resolverStyle, Set resolverFields) { + if (resolverFields != null) { + fieldValues.keySet().retainAll(resolverFields); + } + this.resolverStyle = resolverStyle; + chrono = effectiveChrono; + resolveFields(); + resolveTimeLenient(); + crossCheck(); + return this; + } + + //----------------------------------------------------------------------- + private void resolveFields() { + // resolve ChronoField + resolveDateFields(); + resolveTimeFields(); + + // if any other fields, handle them + // any lenient date resolution should return epoch-day + if (fieldValues.size() > 0) { + boolean changed = false; + outer: + while (true) { + for (Map.Entry entry : fieldValues.entrySet()) { + TemporalField targetField = entry.getKey(); + Map changes = targetField.resolve(this, entry.getValue(), resolverStyle); + if (changes != null) { + changed = true; + resolveFieldsMakeChanges(targetField, changes); + fieldValues.remove(targetField); // helps avoid infinite loops + continue outer; // have to restart to avoid concurrent modification + } + } + break; + } + // if something changed then have to redo ChronoField resolve + if (changed) { + resolveDateFields(); + resolveTimeFields(); + } + } + } + + private void resolveFieldsMakeChanges(TemporalField targetField, Map changes) { + for (Map.Entry change : changes.entrySet()) { + TemporalField changeField = change.getKey(); + Long changeValue = change.getValue(); + Objects.requireNonNull(changeField, "changeField"); + if (changeValue != null) { + updateCheckConflict(targetField, changeField, changeValue); + } else { + fieldValues.remove(changeField); + } + } + } + + private void updateCheckConflict(TemporalField targetField, TemporalField changeField, Long changeValue) { + Long old = fieldValues.put(changeField, changeValue); + if (old != null && old.longValue() != changeValue.longValue()) { + throw new DateTimeException("Conflict found: " + changeField + " " + old + + " differs from " + changeField + " " + changeValue + + " while resolving " + targetField); + } + } + + //----------------------------------------------------------------------- + private void resolveDateFields() { + updateCheckConflict(chrono.resolveDate(fieldValues, resolverStyle)); + } + + private void updateCheckConflict(ChronoLocalDate cld) { + if (date != null) { + if (cld != null && date.equals(cld) == false) { + throw new DateTimeException("Conflict found: Fields resolved to two different dates: " + date + " " + cld); + } + } else { + date = cld; + } + } + + //----------------------------------------------------------------------- + private void resolveTimeFields() { + // simplify fields + if (fieldValues.containsKey(CLOCK_HOUR_OF_DAY)) { + long ch = fieldValues.remove(CLOCK_HOUR_OF_DAY); + updateCheckConflict(CLOCK_HOUR_OF_DAY, HOUR_OF_DAY, ch == 24 ? 0 : ch); + } + if (fieldValues.containsKey(CLOCK_HOUR_OF_AMPM)) { + long ch = fieldValues.remove(CLOCK_HOUR_OF_AMPM); + updateCheckConflict(CLOCK_HOUR_OF_AMPM, HOUR_OF_AMPM, ch == 12 ? 0 : ch); + } + if (fieldValues.containsKey(AMPM_OF_DAY) && fieldValues.containsKey(HOUR_OF_AMPM)) { + long ap = fieldValues.remove(AMPM_OF_DAY); + long hap = fieldValues.remove(HOUR_OF_AMPM); + updateCheckConflict(AMPM_OF_DAY, HOUR_OF_DAY, ap * 12 + hap); + } + if (fieldValues.containsKey(MICRO_OF_DAY)) { + long cod = fieldValues.remove(MICRO_OF_DAY); + updateCheckConflict(MICRO_OF_DAY, SECOND_OF_DAY, cod / 1_000_000L); + updateCheckConflict(MICRO_OF_DAY, MICRO_OF_SECOND, cod % 1_000_000L); + } + if (fieldValues.containsKey(MILLI_OF_DAY)) { + long lod = fieldValues.remove(MILLI_OF_DAY); + updateCheckConflict(MILLI_OF_DAY, SECOND_OF_DAY, lod / 1_000); + updateCheckConflict(MILLI_OF_DAY, MILLI_OF_SECOND, lod % 1_000); + } + if (fieldValues.containsKey(SECOND_OF_DAY)) { + long sod = fieldValues.remove(SECOND_OF_DAY); + updateCheckConflict(SECOND_OF_DAY, HOUR_OF_DAY, sod / 3600); + updateCheckConflict(SECOND_OF_DAY, MINUTE_OF_HOUR, (sod / 60) % 60); + updateCheckConflict(SECOND_OF_DAY, SECOND_OF_MINUTE, sod % 60); + } + if (fieldValues.containsKey(MINUTE_OF_DAY)) { + long mod = fieldValues.remove(MINUTE_OF_DAY); + updateCheckConflict(MINUTE_OF_DAY, HOUR_OF_DAY, mod / 60); + updateCheckConflict(MINUTE_OF_DAY, MINUTE_OF_HOUR, mod % 60); + } + + // combine partial second fields strictly, leaving lenient expansion to later + if (fieldValues.containsKey(NANO_OF_SECOND)) { + long nos = fieldValues.get(NANO_OF_SECOND); + if (fieldValues.containsKey(MICRO_OF_SECOND)) { + long cos = fieldValues.remove(MICRO_OF_SECOND); + nos = cos * 1000 + (nos % 1000); + updateCheckConflict(MICRO_OF_SECOND, NANO_OF_SECOND, nos); + } + if (fieldValues.containsKey(MILLI_OF_SECOND)) { + long los = fieldValues.remove(MILLI_OF_SECOND); + updateCheckConflict(MILLI_OF_SECOND, NANO_OF_SECOND, los * 1_000_000L + (nos % 1_000_000L)); + } + } + + // convert to time if possible + if (fieldValues.containsKey(NANO_OF_DAY)) { + long nod = fieldValues.remove(NANO_OF_DAY); + updateCheckConflict(LocalTime.ofNanoOfDay(nod)); + } + if (fieldValues.containsKey(HOUR_OF_DAY) && fieldValues.containsKey(MINUTE_OF_HOUR) && + fieldValues.containsKey(SECOND_OF_MINUTE) && fieldValues.containsKey(NANO_OF_SECOND)) { + int hodVal = HOUR_OF_DAY.checkValidIntValue(fieldValues.remove(HOUR_OF_DAY)); + int mohVal = MINUTE_OF_HOUR.checkValidIntValue(fieldValues.remove(MINUTE_OF_HOUR)); + int somVal = SECOND_OF_MINUTE.checkValidIntValue(fieldValues.remove(SECOND_OF_MINUTE)); + int nosVal = NANO_OF_SECOND.checkValidIntValue(fieldValues.remove(NANO_OF_SECOND)); + updateCheckConflict(LocalTime.of(hodVal, mohVal, somVal, nosVal)); + } + } + + private void resolveTimeLenient() { + // leniently create a time from incomplete information + // done after everything else as it creates information from nothing + // which would break updateCheckConflict(field) + + if (time == null) { + // can only get here if NANO_OF_SECOND not present + if (fieldValues.containsKey(MILLI_OF_SECOND)) { + long los = fieldValues.remove(MILLI_OF_SECOND); + if (fieldValues.containsKey(MICRO_OF_SECOND)) { + // merge milli-of-second and micro-of-second for better error message + long cos = los * 1_000 + (fieldValues.get(MICRO_OF_SECOND) % 1_000); + updateCheckConflict(MILLI_OF_SECOND, MICRO_OF_SECOND, cos); + fieldValues.remove(MICRO_OF_SECOND); + fieldValues.put(NANO_OF_SECOND, cos * 1_000L); + } else { + // convert milli-of-second to nano-of-second + fieldValues.put(NANO_OF_SECOND, los * 1_000_000L); + } + } else if (fieldValues.containsKey(MICRO_OF_SECOND)) { + // convert micro-of-second to nano-of-second + long cos = fieldValues.remove(MICRO_OF_SECOND); + fieldValues.put(NANO_OF_SECOND, cos * 1_000L); + } + } + + // merge hour/minute/second/nano leniently + Long hod = fieldValues.get(HOUR_OF_DAY); + if (hod != null) { + int hodVal = HOUR_OF_DAY.checkValidIntValue(hod); + Long moh = fieldValues.get(MINUTE_OF_HOUR); + Long som = fieldValues.get(SECOND_OF_MINUTE); + Long nos = fieldValues.get(NANO_OF_SECOND); + + // check for invalid combinations that cannot be defaulted + if (time == null) { + if ((moh == null && (som != null || nos != null)) || + (moh != null && som == null && nos != null)) { + return; + } + } + + // default as necessary and build time + int mohVal = (moh != null ? MINUTE_OF_HOUR.checkValidIntValue(moh) : (time != null ? time.getMinute() : 0)); + int somVal = (som != null ? SECOND_OF_MINUTE.checkValidIntValue(som) : (time != null ? time.getSecond() : 0)); + int nosVal = (nos != null ? NANO_OF_SECOND.checkValidIntValue(nos) : (time != null ? time.getNano() : 0)); + updateCheckConflict(LocalTime.of(hodVal, mohVal, somVal, nosVal)); + fieldValues.remove(HOUR_OF_DAY); + fieldValues.remove(MINUTE_OF_HOUR); + fieldValues.remove(SECOND_OF_MINUTE); + fieldValues.remove(NANO_OF_SECOND); + } + } + + private void updateCheckConflict(LocalTime lt) { + if (time != null) { + if (lt != null && time.equals(lt) == false) { + throw new DateTimeException("Conflict found: Fields resolved to two different times: " + time + " " + lt); + } + } else { + time = lt; + } + } + + //----------------------------------------------------------------------- + private void crossCheck() { + // only cross-check date, time and date-time + // avoid object creation if possible + if (date != null) { + crossCheck(date); + } + if (time != null) { + crossCheck(time); + if (date != null && fieldValues.size() > 0) { + crossCheck(date.atTime(time)); + } + } + } + + private void crossCheck(TemporalAccessor target) { + for (Iterator> it = fieldValues.entrySet().iterator(); it.hasNext(); ) { + Entry entry = it.next(); + TemporalField field = entry.getKey(); + long val1; + try { + val1 = target.getLong(field); + } catch (RuntimeException ex) { + continue; + } + long val2 = entry.getValue(); + if (val1 != val2) { + throw new DateTimeException("Conflict found: Field " + field + " " + val1 + + " differs from " + field + " " + val2 + " derived from " + target); + } + it.remove(); + } + } + + //----------------------------------------------------------------------- + @Override + public String toString() { + String str = fieldValues.toString() + "," + chrono + "," + zone; + if (date != null || time != null) { + str += " resolved to " + date + "," + time; + } + return str; + } + +} diff --git a/jdk/src/share/classes/java/time/format/ResolverStyle.java b/jdk/src/share/classes/java/time/format/ResolverStyle.java new file mode 100644 index 00000000000..b53b827ab8d --- /dev/null +++ b/jdk/src/share/classes/java/time/format/ResolverStyle.java @@ -0,0 +1,116 @@ +/* + * 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. 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2008-2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package java.time.format; + +/** + * Enumeration of different ways to resolve dates and times. + *

    + * Parsing a text string occurs in two phases. + * Phase 1 is a basic text parse according to the fields added to the builder. + * Phase 2 resolves the parsed field-value pairs into date and/or time objects. + * This style is used to control how phase 2, resolving, happens. + * + *

    Specification for implementors

    + * This is an immutable and thread-safe enum. + * + * @since 1.8 + */ +public enum ResolverStyle { + + /** + * Style to resolve dates and times strictly. + *

    + * Using strict resolution will ensure that all parsed values are within + * the outer range of valid values for the field. Individual fields may + * be further processed for strictness. + *

    + * For example, resolving year-month and day-of-month in the ISO calendar + * system using strict mode will ensure that the day-of-month is valid + * for the year-month, rejecting invalid values. + */ + STRICT, + /** + * Style to resolve dates and times in a smart, or intelligent, manner. + *

    + * Using smart resolution will perform the sensible default for each + * field, which may be the same as strict, the same as lenient, or a third + * behavior. Individual fields will interpret this differently. + *

    + * For example, resolving year-month and day-of-month in the ISO calendar + * system using smart mode will ensure that the day-of-month is valid + * for the year-month, rejecting invalid values, with the exception that + * February 29th in a year other than a leap year will be converted to + * February 28th. + */ + SMART, + /** + * Style to resolve dates and times leniently. + *

    + * Using lenient resolution will resolve the values in an appropriate + * lenient manner. Individual fields will interpret this differently. + *

    + * For example, lenient mode allows the month in the ISO calendar system + * to be outside the range 1 to 12. + */ + LENIENT; + +} diff --git a/jdk/src/share/classes/java/time/format/TextStyle.java b/jdk/src/share/classes/java/time/format/TextStyle.java index 3f8c0875afe..dbc2c27f0d0 100644 --- a/jdk/src/share/classes/java/time/format/TextStyle.java +++ b/jdk/src/share/classes/java/time/format/TextStyle.java @@ -61,33 +61,115 @@ */ package java.time.format; +import java.util.Calendar; + /** - * Enumeration of the style of text output to use. + * Enumeration of the style of text formatting and parsing. *

    - * This defines the "size" of the text to be output. + * Text styles define three sizes for the formatted text - 'full', 'short' and 'narrow'. + * Each of these three sizes is available in both 'standard' and 'stand-alone' variations. + *

    + * The difference between the three sizes is obvious in most languages. + * For example, in English the 'full' month is 'January', the 'short' month is 'Jan' + * and the 'narrow' month is 'J'. Note that the narrow size is often not unique. + * For example, 'January', 'June' and 'July' all have the 'narrow' text 'J'. + *

    + * The difference between the 'standard' and 'stand-alone' forms is trickier to describe + * as there is no difference in English. However, in other languages there is a difference + * in the word used when the text is used alone, as opposed to in a complete date. + * For example, the word used for a month when used alone in a date picker is different + * to the word used for month in association with a day and year in a date. * *

    Specification for implementors

    * This is immutable and thread-safe enum. - * - * @since 1.8 */ public enum TextStyle { // ordered from large to small + // ordered so that bit 0 of the ordinal indicates stand-alone. /** * Full text, typically the full description. * For example, day-of-week Monday might output "Monday". */ - FULL, + FULL(Calendar.LONG_FORMAT, 0), + /** + * Full text for stand-alone use, typically the full description. + * For example, day-of-week Monday might output "Monday". + */ + FULL_STANDALONE(Calendar.LONG_STANDALONE, 0), /** * Short text, typically an abbreviation. * For example, day-of-week Monday might output "Mon". */ - SHORT, + SHORT(Calendar.SHORT_FORMAT, 1), + /** + * Short text for stand-alone use, typically an abbreviation. + * For example, day-of-week Monday might output "Mon". + */ + SHORT_STANDALONE(Calendar.SHORT_STANDALONE, 1), /** * Narrow text, typically a single letter. * For example, day-of-week Monday might output "M". */ - NARROW; + NARROW(Calendar.NARROW_FORMAT, 1), + /** + * Narrow text for stand-alone use, typically a single letter. + * For example, day-of-week Monday might output "M". + */ + NARROW_STANDALONE(Calendar.NARROW_STANDALONE, 1); + private final int calendarStyle; + private final int zoneNameStyleIndex; + + private TextStyle(int calendarStyle, int zoneNameStyleIndex) { + this.calendarStyle = calendarStyle; + this.zoneNameStyleIndex = zoneNameStyleIndex; + } + + /** + * Returns true if the Style is a stand-alone style. + * @return true if the style is a stand-alone style. + */ + public boolean isStandalone() { + return (ordinal() & 1) == 1; + } + + /** + * Returns the stand-alone style with the same size. + * @return the stand-alone style with the same size + */ + public TextStyle asStandalone() { + return TextStyle.values()[ordinal() | 1]; + } + + /** + * Returns the normal style with the same size. + * + * @return the normal style with the same size + */ + public TextStyle asNormal() { + return TextStyle.values()[ordinal() & ~1]; + } + + /** + * Returns the {@code Calendar} style corresponding to this {@code TextStyle}. + * + * @return the corresponding {@code Calendar} style + */ + int toCalendarStyle() { + return calendarStyle; + } + + /** + * Returns the relative index value to an element of the {@link + * java.text.DateFormatSymbols#getZoneStrings() DateFormatSymbols.getZoneStrings()} + * value, 0 for long names and 1 for short names (abbreviations). Note that these values + * do not correspond to the {@link java.util.TimeZone#LONG} and {@link + * java.util.TimeZone#SHORT} values. + * + * @return the relative index value to time zone names array + */ + int zoneNameStyleIndex() { + return zoneNameStyleIndex; + } } diff --git a/jdk/src/share/classes/java/time/temporal/ChronoField.java b/jdk/src/share/classes/java/time/temporal/ChronoField.java index 2a421157a5e..0fdeb2273d5 100644 --- a/jdk/src/share/classes/java/time/temporal/ChronoField.java +++ b/jdk/src/share/classes/java/time/temporal/ChronoField.java @@ -76,6 +76,11 @@ import java.time.Year; import java.time.ZoneOffset; import java.time.chrono.ChronoLocalDate; import java.time.chrono.Chronology; +import java.util.Locale; +import java.util.Objects; +import java.util.ResourceBundle; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; /** * A standard set of fields. @@ -187,7 +192,7 @@ public enum ChronoField implements TemporalField { * This counts the second within the minute, from 0 to 59. * This field has the same meaning for all calendar systems. */ - SECOND_OF_MINUTE("SecondOfMinute", SECONDS, MINUTES, ValueRange.of(0, 59)), + SECOND_OF_MINUTE("SecondOfMinute", SECONDS, MINUTES, ValueRange.of(0, 59), "second"), /** * The second-of-day. *

    @@ -201,7 +206,7 @@ public enum ChronoField implements TemporalField { * This counts the minute within the hour, from 0 to 59. * This field has the same meaning for all calendar systems. */ - MINUTE_OF_HOUR("MinuteOfHour", MINUTES, HOURS, ValueRange.of(0, 59)), + MINUTE_OF_HOUR("MinuteOfHour", MINUTES, HOURS, ValueRange.of(0, 59), "minute"), /** * The minute-of-day. *

    @@ -232,7 +237,7 @@ public enum ChronoField implements TemporalField { * This is the hour that would be observed on a standard 24-hour digital clock. * This field has the same meaning for all calendar systems. */ - HOUR_OF_DAY("HourOfDay", HOURS, DAYS, ValueRange.of(0, 23)), + HOUR_OF_DAY("HourOfDay", HOURS, DAYS, ValueRange.of(0, 23), "hour"), /** * The clock-hour-of-day. *

    @@ -247,7 +252,7 @@ public enum ChronoField implements TemporalField { * This counts the AM/PM within the day, from 0 (AM) to 1 (PM). * This field has the same meaning for all calendar systems. */ - AMPM_OF_DAY("AmPmOfDay", HALF_DAYS, DAYS, ValueRange.of(0, 1)), + AMPM_OF_DAY("AmPmOfDay", HALF_DAYS, DAYS, ValueRange.of(0, 1), "dayperiod"), /** * The day-of-week, such as Tuesday. *

    @@ -263,7 +268,7 @@ public enum ChronoField implements TemporalField { * if they have a similar concept of named or numbered days within a period similar * to a week. It is recommended that the numbering starts from 1. */ - DAY_OF_WEEK("DayOfWeek", DAYS, WEEKS, ValueRange.of(1, 7)), + DAY_OF_WEEK("DayOfWeek", DAYS, WEEKS, ValueRange.of(1, 7), "weekday"), /** * The aligned day-of-week within a month. *

    @@ -312,7 +317,7 @@ public enum ChronoField implements TemporalField { * day-of-month values for users of the calendar system. * Normally, this is a count of days from 1 to the length of the month. */ - DAY_OF_MONTH("DayOfMonth", DAYS, MONTHS, ValueRange.of(1, 28, 31)), + DAY_OF_MONTH("DayOfMonth", DAYS, MONTHS, ValueRange.of(1, 28, 31), "day"), /** * The day-of-year. *

    @@ -377,17 +382,27 @@ public enum ChronoField implements TemporalField { * month-of-year values for users of the calendar system. * Normally, this is a count of months starting from 1. */ - MONTH_OF_YEAR("MonthOfYear", MONTHS, YEARS, ValueRange.of(1, 12)), + MONTH_OF_YEAR("MonthOfYear", MONTHS, YEARS, ValueRange.of(1, 12), "month"), /** - * The epoch-month based on the Java epoch of 1970-01-01. + * The proleptic-month based, counting months sequentially from year 0. *

    - * This field is the sequential count of months where January 1970 (ISO) is zero. + * This field is the sequential count of months where the first month + * in proleptic-year zero has the value zero. + * Later months have increasingly larger values. + * Earlier months have increasingly small values. + * There are no gaps or breaks in the sequence of months. * Note that this uses the local time-line, ignoring offset and time-zone. *

    - * Non-ISO calendar systems should also implement this field to represent a sequential - * count of months. It is recommended to define zero as the month of 1970-01-01 (ISO). + * In the default ISO calendar system, June 2012 would have the value + * {@code (2012 * 12 + 6 - 1)}. This field is primarily for internal use. + *

    + * Non-ISO calendar systems must implement this field as per the definition above. + * It is just a simple zero-based count of elapsed months from the start of proleptic-year 0. + * All calendar systems with a full proleptic-year definition will have a year zero. + * If the calendar system has a minimum year that excludes year zero, then one must + * be extrapolated in order for this method to be defined. */ - EPOCH_MONTH("EpochMonth", MONTHS, FOREVER, ValueRange.of((Year.MIN_VALUE - 1970L) * 12, (Year.MAX_VALUE - 1970L) * 12L - 1L)), + PROLEPTIC_MONTH("ProlepticMonth", MONTHS, FOREVER, ValueRange.of(Year.MIN_VALUE * 12L, Year.MAX_VALUE * 12L + 11)), /** * The year within the era. *

    @@ -446,7 +461,7 @@ public enum ChronoField implements TemporalField { * defined with any appropriate value, although defining it to be the same as ISO may be * the best option. */ - YEAR("Year", YEARS, FOREVER, ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE)), + YEAR("Year", YEARS, FOREVER, ValueRange.of(Year.MIN_VALUE, Year.MAX_VALUE), "year"), /** * The era. *

    @@ -463,7 +478,7 @@ public enum ChronoField implements TemporalField { * Earlier eras must have sequentially smaller values. * Later eras must have sequentially larger values, */ - ERA("Era", ERAS, FOREVER, ValueRange.of(0, 1)), + ERA("Era", ERAS, FOREVER, ValueRange.of(0, 1), "era"), /** * The instant epoch-seconds. *

    @@ -499,12 +514,23 @@ public enum ChronoField implements TemporalField { private final TemporalUnit baseUnit; private final TemporalUnit rangeUnit; private final ValueRange range; + private final String displayNameKey; private ChronoField(String name, TemporalUnit baseUnit, TemporalUnit rangeUnit, ValueRange range) { this.name = name; this.baseUnit = baseUnit; this.rangeUnit = rangeUnit; this.range = range; + this.displayNameKey = null; + } + + private ChronoField(String name, TemporalUnit baseUnit, TemporalUnit rangeUnit, + ValueRange range, String displayNameKey) { + this.name = name; + this.baseUnit = baseUnit; + this.rangeUnit = rangeUnit; + this.range = range; + this.displayNameKey = displayNameKey; } //----------------------------------------------------------------------- @@ -513,6 +539,20 @@ public enum ChronoField implements TemporalField { return name; } + @Override + public String getDisplayName(Locale locale) { + Objects.requireNonNull(locale, "locale"); + if (displayNameKey == null) { + return getName(); + } + + LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() + .getLocaleResources(locale); + ResourceBundle rb = lr.getJavaTimeFormatData(); + String key = "field." + displayNameKey; + return rb.containsKey(key) ? rb.getString(key) : getName(); + } + @Override public TemporalUnit getBaseUnit() { return baseUnit; @@ -548,19 +588,25 @@ public enum ChronoField implements TemporalField { //----------------------------------------------------------------------- /** * Checks if this field represents a component of a date. + *

    + * Fields from day-of-week to era are date-based. * * @return true if it is a component of a date */ - public boolean isDateField() { + @Override + public boolean isDateBased() { return ordinal() >= DAY_OF_WEEK.ordinal() && ordinal() <= ERA.ordinal(); } /** * Checks if this field represents a component of a time. + *

    + * Fields from nano-of-second to am-pm-of-day are time-based. * * @return true if it is a component of a time */ - public boolean isTimeField() { + @Override + public boolean isTimeBased() { return ordinal() < DAY_OF_WEEK.ordinal(); } diff --git a/jdk/src/share/classes/java/time/temporal/ChronoUnit.java b/jdk/src/share/classes/java/time/temporal/ChronoUnit.java index 0551858ffe8..03c5310312d 100644 --- a/jdk/src/share/classes/java/time/temporal/ChronoUnit.java +++ b/jdk/src/share/classes/java/time/temporal/ChronoUnit.java @@ -178,7 +178,7 @@ public enum ChronoUnit implements TemporalUnit { * Unit that represents the concept of an era. * The ISO calendar system doesn't have eras thus it is impossible to add * an era to a date or date-time. - * The estimated duration of the era is artificially defined as {@code 1,000,00,000 Years}. + * The estimated duration of the era is artificially defined as {@code 1,000,000,000 Years}. *

    * When used with other calendar systems there are no restrictions on the unit. */ diff --git a/jdk/src/share/classes/java/time/temporal/IsoFields.java b/jdk/src/share/classes/java/time/temporal/IsoFields.java index 5e03c1c12e1..851685a3132 100644 --- a/jdk/src/share/classes/java/time/temporal/IsoFields.java +++ b/jdk/src/share/classes/java/time/temporal/IsoFields.java @@ -69,13 +69,19 @@ import static java.time.temporal.ChronoUnit.MONTHS; import static java.time.temporal.ChronoUnit.WEEKS; import static java.time.temporal.ChronoUnit.YEARS; -import java.time.DateTimeException; import java.time.Duration; import java.time.LocalDate; import java.time.chrono.Chronology; import java.time.chrono.IsoChronology; +import java.time.format.ResolverStyle; import java.util.HashMap; +import java.util.Locale; import java.util.Map; +import java.util.Objects; +import java.util.ResourceBundle; + +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; /** * Fields and units specific to the ISO-8601 calendar system, @@ -162,6 +168,27 @@ public final class IsoFields { * value from 1 to 92. If the quarter has less than 92 days, then day 92, and * potentially day 91, is in the following quarter. *

    + * In the resolving phase of parsing, a date can be created from a year, + * quarter-of-year and day-of-quarter. + *

    + * In {@linkplain ResolverStyle#STRICT strict mode}, all three fields are + * validated against their range of valid values. The day-of-quarter field + * is validated from 1 to 90, 91 or 92 depending on the year and quarter. + *

    + * In {@linkplain ResolverStyle#SMART smart mode}, all three fields are + * validated against their range of valid values. The day-of-quarter field is + * validated between 1 and 92, ignoring the actual range based on the year and quarter. + * If the day-of-quarter exceeds the actual range by one day, then the resulting date + * is one day later. If the day-of-quarter exceeds the actual range by two days, + * then the resulting date is two days later. + *

    + * In {@linkplain ResolverStyle#LENIENT lenient mode}, only the year is validated + * against the range of valid values. The resulting date is calculated equivalent to + * the following three stage approach. First, create a date on the first of January + * in the requested year. Then take the quarter-of-year, subtract one, and add the + * amount in quarters to the date. Finally, take the day-of-quarter, subtract one, + * and add the amount in days to the date. + *

    * This unit is an immutable and thread-safe singleton. */ public static final TemporalField DAY_OF_QUARTER = Field.DAY_OF_QUARTER; @@ -171,7 +198,11 @@ public final class IsoFields { * This field allows the quarter-of-year value to be queried and set. * The quarter-of-year has values from 1 to 4. *

    - * The day-of-quarter can only be calculated if the month-of-year is available. + * The quarter-of-year can only be calculated if the month-of-year is available. + *

    + * In the resolving phase of parsing, a date can be created from a year, + * quarter-of-year and day-of-quarter. + * See {@link #DAY_OF_QUARTER} for details. *

    * This unit is an immutable and thread-safe singleton. */ @@ -180,6 +211,28 @@ public final class IsoFields { * The field that represents the week-of-week-based-year. *

    * This field allows the week of the week-based-year value to be queried and set. + * The week-of-week-based-year has values from 1 to 52, or 53 if the + * week-based-year has 53 weeks. + *

    + * In the resolving phase of parsing, a date can be created from a + * week-based-year, week-of-week-based-year and day-of-week. + *

    + * In {@linkplain ResolverStyle#STRICT strict mode}, all three fields are + * validated against their range of valid values. The week-of-week-based-year + * field is validated from 1 to 52 or 53 depending on the week-based-year. + *

    + * In {@linkplain ResolverStyle#SMART smart mode}, all three fields are + * validated against their range of valid values. The week-of-week-based-year + * field is validated between 1 and 53, ignoring the week-based-year. + * If the week-of-week-based-year is 53, but the week-based-year only has + * 52 weeks, then the resulting date is in week 1 of the following week-based-year. + *

    + * In {@linkplain ResolverStyle#LENIENT lenient mode}, only the week-based-year + * is validated against the range of valid values. If the day-of-week is outside + * the range 1 to 7, then the resulting date is adjusted by a suitable number of + * weeks to reduce the day-of-week to the range 1 to 7. If the week-of-week-based-year + * value is outside the range 1 to 52, then any excess weeks are added or subtracted + * from the resulting date. *

    * This unit is an immutable and thread-safe singleton. */ @@ -189,6 +242,12 @@ public final class IsoFields { *

    * This field allows the week-based-year value to be queried and set. *

    + * The field has a range that matches {@link LocalDate#MAX} and {@link LocalDate#MIN}. + *

    + * In the resolving phase of parsing, a date can be created from a + * week-based-year, week-of-week-based-year and day-of-week. + * See {@link #WEEK_OF_WEEK_BASED_YEAR} for details. + *

    * This unit is an immutable and thread-safe singleton. */ public static final TemporalField WEEK_BASED_YEAR = Field.WEEK_BASED_YEAR; @@ -253,7 +312,7 @@ public final class IsoFields { @Override public ValueRange rangeRefinedBy(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: DayOfQuarter"); + throw new UnsupportedTemporalTypeException("Unsupported field: DayOfQuarter"); } long qoy = temporal.getLong(QUARTER_OF_YEAR); if (qoy == 1) { @@ -269,7 +328,7 @@ public final class IsoFields { @Override public long getFrom(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: DayOfQuarter"); + throw new UnsupportedTemporalTypeException("Unsupported field: DayOfQuarter"); } int doy = temporal.get(DAY_OF_YEAR); int moy = temporal.get(MONTH_OF_YEAR); @@ -285,16 +344,29 @@ public final class IsoFields { return (R) temporal.with(DAY_OF_YEAR, temporal.getLong(DAY_OF_YEAR) + (newValue - curValue)); } @Override - public Map resolve(TemporalAccessor temporal, long value) { - if ((temporal.isSupported(YEAR) && temporal.isSupported(DAY_OF_QUARTER)) == false) { + public Map resolve(TemporalAccessor temporal, long doq, ResolverStyle resolverStyle) { + if ((temporal.isSupported(YEAR) && temporal.isSupported(QUARTER_OF_YEAR)) == false) { return null; } - int y = temporal.get(YEAR); - int qoy = temporal.get(QUARTER_OF_YEAR); - range().checkValidValue(value, this); // leniently check from 1 to 92 TODO: check - LocalDate date = LocalDate.of(y, ((qoy - 1) * 3) + 1, 1).plusDays(value - 1); + int y = temporal.get(YEAR); // validated + LocalDate date; + if (resolverStyle == ResolverStyle.LENIENT) { + long qoy = temporal.getLong(QUARTER_OF_YEAR); // unvalidated + date = LocalDate.of(y, 1, 1).plusMonths(Math.multiplyExact(Math.subtractExact(qoy, 1), 3)); + } else { + int qoy = temporal.get(QUARTER_OF_YEAR); // validated + date = LocalDate.of(y, ((qoy - 1) * 3) + 1, 1); + if (doq < 1 || doq > 90) { + if (resolverStyle == ResolverStyle.STRICT) { + rangeRefinedBy(date).checkValidValue(doq, this); // only allow exact range + } else { // SMART + range().checkValidValue(doq, this); // allow 1-92 rolling into next quarter + } + } + } + long epochDay = Math.addExact(date.toEpochDay(), Math.subtractExact(doq, 1)); Map result = new HashMap<>(4, 1.0f); - result.put(EPOCH_DAY, date.toEpochDay()); + result.put(EPOCH_DAY, epochDay); result.put(YEAR, null); result.put(QUARTER_OF_YEAR, null); return result; @@ -324,7 +396,7 @@ public final class IsoFields { @Override public long getFrom(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: QuarterOfYear"); + throw new UnsupportedTemporalTypeException("Unsupported field: QuarterOfYear"); } long moy = temporal.getLong(MONTH_OF_YEAR); return ((moy + 2) / 3); @@ -343,6 +415,16 @@ public final class IsoFields { public String getName() { return "WeekOfWeekBasedYear"; } + + @Override + public String getDisplayName(Locale locale) { + Objects.requireNonNull(locale, "locale"); + LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() + .getLocaleResources(locale); + ResourceBundle rb = lr.getJavaTimeFormatData(); + return rb.containsKey("field.week") ? rb.getString("field.week") : getName(); + } + @Override public TemporalUnit getBaseUnit() { return WEEKS; @@ -362,14 +444,14 @@ public final class IsoFields { @Override public ValueRange rangeRefinedBy(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: WeekOfWeekBasedYear"); + throw new UnsupportedTemporalTypeException("Unsupported field: WeekOfWeekBasedYear"); } return getWeekRange(LocalDate.from(temporal)); } @Override public long getFrom(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: WeekOfWeekBasedYear"); + throw new UnsupportedTemporalTypeException("Unsupported field: WeekOfWeekBasedYear"); } return getWeek(LocalDate.from(temporal)); } @@ -381,14 +463,33 @@ public final class IsoFields { return (R) temporal.plus(Math.subtractExact(newValue, getFrom(temporal)), WEEKS); } @Override - public Map resolve(TemporalAccessor temporal, long value) { + public Map resolve(TemporalAccessor temporal, long wowby, ResolverStyle resolverStyle) { if ((temporal.isSupported(WEEK_BASED_YEAR) && temporal.isSupported(DAY_OF_WEEK)) == false) { return null; } - int wby = temporal.get(WEEK_BASED_YEAR); - int dow = temporal.get(DAY_OF_WEEK); - range().checkValidValue(value, this); // lenient range - LocalDate date = LocalDate.of(wby, 1, 4).plusWeeks(value - 1).with(DAY_OF_WEEK, dow); + int wby = temporal.get(WEEK_BASED_YEAR); // validated + LocalDate date = LocalDate.of(wby, 1, 4); + if (resolverStyle == ResolverStyle.LENIENT) { + long dow = temporal.getLong(DAY_OF_WEEK); // unvalidated + if (dow > 7) { + date = date.plusWeeks((dow - 1) / 7); + dow = ((dow - 1) % 7) + 1; + } else if (dow < 1) { + date = date.plusWeeks(Math.subtractExact(dow, 7) / 7); + dow = ((dow + 6) % 7) + 1; + } + date = date.plusWeeks(Math.subtractExact(wowby, 1)).with(DAY_OF_WEEK, dow); + } else { + int dow = temporal.get(DAY_OF_WEEK); // validated + if (wowby < 1 || wowby > 52) { + if (resolverStyle == ResolverStyle.STRICT) { + getWeekRange(date).checkValidValue(wowby, this); // only allow exact range + } else { // SMART + range().checkValidValue(wowby, this); // allow 1-53 rolling into next year + } + } + date = date.plusWeeks(wowby - 1).with(DAY_OF_WEEK, dow); + } Map result = new HashMap<>(2, 1.0f); result.put(EPOCH_DAY, date.toEpochDay()); result.put(WEEK_BASED_YEAR, null); @@ -420,7 +521,7 @@ public final class IsoFields { @Override public long getFrom(TemporalAccessor temporal) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: WeekBasedYear"); + throw new UnsupportedTemporalTypeException("Unsupported field: WeekBasedYear"); } return getWeekBasedYear(LocalDate.from(temporal)); } @@ -428,7 +529,7 @@ public final class IsoFields { @Override public R adjustInto(R temporal, long newValue) { if (isSupportedBy(temporal) == false) { - throw new DateTimeException("Unsupported field: WeekBasedYear"); + throw new UnsupportedTemporalTypeException("Unsupported field: WeekBasedYear"); } int newVal = range().checkValidIntValue(newValue, WEEK_BASED_YEAR); // strict check LocalDate date = LocalDate.from(temporal); @@ -438,6 +539,11 @@ public final class IsoFields { } }; + @Override + public boolean isDateBased() { + return true; + } + @Override public ValueRange rangeRefinedBy(TemporalAccessor temporal) { return range(); diff --git a/jdk/src/share/classes/java/time/temporal/JulianFields.java b/jdk/src/share/classes/java/time/temporal/JulianFields.java index d0a9d871fc3..72956cec79a 100644 --- a/jdk/src/share/classes/java/time/temporal/JulianFields.java +++ b/jdk/src/share/classes/java/time/temporal/JulianFields.java @@ -66,6 +66,7 @@ import static java.time.temporal.ChronoUnit.DAYS; import static java.time.temporal.ChronoUnit.FOREVER; import java.time.DateTimeException; +import java.time.format.ResolverStyle; import java.util.Collections; import java.util.Map; @@ -106,7 +107,12 @@ public final class JulianFields { * When 'JULIAN_DAY.adjustInto()' is applied to a date-time, the time of day portion remains unaltered. * 'JULIAN_DAY.adjustInto()' and 'JULIAN_DAY.getFrom()' only apply to {@code Temporal} objects that * can be converted into {@link ChronoField#EPOCH_DAY}. - * A {@link DateTimeException} is thrown for any other type of object. + * An {@link UnsupportedTemporalTypeException} is thrown for any other type of object. + *

    + * In the resolving phase of parsing, a date can be created from a Julian Day field. + * In {@linkplain ResolverStyle#STRICT strict mode} and {@linkplain ResolverStyle#SMART smart mode} + * the Julian Day value is validated against the range of valid values. + * In {@linkplain ResolverStyle#LENIENT lenient mode} no validation occurs. *

    *

    Astronomical and Scientific Notes

    * The standard astronomical definition uses a fraction to indicate the time-of-day, @@ -147,10 +153,15 @@ public final class JulianFields { * When 'MODIFIED_JULIAN_DAY.adjustInto()' is applied to a date-time, the time of day portion remains unaltered. * 'MODIFIED_JULIAN_DAY.adjustInto()' and 'MODIFIED_JULIAN_DAY.getFrom()' only apply to {@code Temporal} objects * that can be converted into {@link ChronoField#EPOCH_DAY}. - * A {@link DateTimeException} is thrown for any other type of object. + * An {@link UnsupportedTemporalTypeException} is thrown for any other type of object. *

    * This implementation is an integer version of MJD with the decimal part rounded to floor. *

    + * In the resolving phase of parsing, a date can be created from a Modified Julian Day field. + * In {@linkplain ResolverStyle#STRICT strict mode} and {@linkplain ResolverStyle#SMART smart mode} + * the Modified Julian Day value is validated against the range of valid values. + * In {@linkplain ResolverStyle#LENIENT lenient mode} no validation occurs. + *

    *

    Astronomical and Scientific Notes

    *
          *  | ISO date          | Modified Julian Day |      Decimal MJD |
    @@ -180,7 +191,12 @@ public final class JulianFields {
          * When 'RATA_DIE.adjustInto()' is applied to a date-time, the time of day portion remains unaltered.
          * 'RATA_DIE.adjustInto()' and 'RATA_DIE.getFrom()' only apply to {@code Temporal} objects
          * that can be converted into {@link ChronoField#EPOCH_DAY}.
    -     * A {@link DateTimeException} is thrown for any other type of object.
    +     * An {@link UnsupportedTemporalTypeException} is thrown for any other type of object.
    +     * 

    + * In the resolving phase of parsing, a date can be created from a Rata Die field. + * In {@linkplain ResolverStyle#STRICT strict mode} and {@linkplain ResolverStyle#SMART smart mode} + * the Rata Die value is validated against the range of valid values. + * In {@linkplain ResolverStyle#LENIENT lenient mode} no validation occurs. */ public static final TemporalField RATA_DIE = Field.RATA_DIE; @@ -231,6 +247,11 @@ public final class JulianFields { return rangeUnit; } + @Override + public boolean isDateBased() { + return true; + } + @Override public ValueRange range() { return range; @@ -266,8 +287,15 @@ public final class JulianFields { //----------------------------------------------------------------------- @Override - public Map resolve(TemporalAccessor temporal, long value) { - return Collections.singletonMap(EPOCH_DAY, Math.subtractExact(value, offset)); + public Map resolve(TemporalAccessor temporal, long value, ResolverStyle resolverStyle) { + long epochDay; + if (resolverStyle == ResolverStyle.LENIENT) { + epochDay = Math.subtractExact(value, offset); + } else { + range().checkValidValue(value, this); + epochDay = value - offset; + } + return Collections.singletonMap(EPOCH_DAY, epochDay); } //----------------------------------------------------------------------- diff --git a/jdk/src/share/classes/java/time/temporal/Queries.java b/jdk/src/share/classes/java/time/temporal/Queries.java deleted file mode 100644 index a4c0a420fe2..00000000000 --- a/jdk/src/share/classes/java/time/temporal/Queries.java +++ /dev/null @@ -1,356 +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. 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. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package java.time.temporal; - -import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.NANO_OF_DAY; -import static java.time.temporal.ChronoField.OFFSET_SECONDS; - -import java.time.LocalDate; -import java.time.LocalTime; -import java.time.OffsetDateTime; -import java.time.ZoneId; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.chrono.Chronology; - -/** - * Common implementations of {@code TemporalQuery}. - *

    - * This class provides common implementations of {@link TemporalQuery}. - * These queries are primarily used as optimizations, allowing the internals - * of other objects to be extracted effectively. Note that application code - * can also use the {@code from(TemporalAccessor)} method on most temporal - * objects as a method reference matching the query interface, such as - * {@code LocalDate::from} and {@code ZoneId::from}. - *

    - * There are two equivalent ways of using a {@code TemporalQuery}. - * The first is to invoke the method on the interface directly. - * The second is to use {@link TemporalAccessor#query(TemporalQuery)}: - *

    - *   // these two lines are equivalent, but the second approach is recommended
    - *   dateTime = query.queryFrom(dateTime);
    - *   dateTime = dateTime.query(query);
    - * 
    - * It is recommended to use the second approach, {@code query(TemporalQuery)}, - * as it is a lot clearer to read in code. - * - *

    Specification for implementors

    - * This is a thread-safe utility class. - * All returned adjusters are immutable and thread-safe. - * - * @since 1.8 - */ -public final class Queries { - // note that it is vital that each method supplies a constant, not a - // calculated value, as they will be checked for using == - // it is also vital that each constant is different (due to the == checking) - // as such, alterations to use lambdas must be done with extreme care - - /** - * Private constructor since this is a utility class. - */ - private Queries() { - } - - //----------------------------------------------------------------------- - // special constants should be used to extract information from a TemporalAccessor - // that cannot be derived in other ways - // Javadoc added here, so as to pretend they are more normal than they really are - - /** - * A strict query for the {@code ZoneId}. - *

    - * This queries a {@code TemporalAccessor} for the zone. - * The zone is only returned if the date-time conceptually contains a {@code ZoneId}. - * It will not be returned if the date-time only conceptually has an {@code ZoneOffset}. - * Thus a {@link ZonedDateTime} will return the result of {@code getZone()}, - * but an {@link OffsetDateTime} will return null. - *

    - * In most cases, applications should use {@link #ZONE} as this query is too strict. - *

    - * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    - * {@code LocalDate} returns null
    - * {@code LocalTime} returns null
    - * {@code LocalDateTime} returns null
    - * {@code ZonedDateTime} returns the associated zone
    - * {@code OffsetTime} returns null
    - * {@code OffsetDateTime} returns null
    - * {@code ChronoLocalDate} returns null
    - * {@code ChronoLocalDateTime} returns null
    - * {@code ChronoZonedDateTime} returns the associated zone
    - * {@code Era} returns null
    - * {@code DayOfWeek} returns null
    - * {@code Month} returns null
    - * {@code Year} returns null
    - * {@code YearMonth} returns null
    - * {@code MonthDay} returns null
    - * {@code ZoneOffset} returns null
    - * {@code Instant} returns null
    - * - * @return a query that can obtain the zone ID of a temporal, not null - */ - public static final TemporalQuery zoneId() { - return ZONE_ID; - } - static final TemporalQuery ZONE_ID = (temporal) -> { - return temporal.query(ZONE_ID); - }; - - /** - * A query for the {@code Chronology}. - *

    - * This queries a {@code TemporalAccessor} for the chronology. - * If the target {@code TemporalAccessor} represents a date, or part of a date, - * then it should return the chronology that the date is expressed in. - * As a result of this definition, objects only representing time, such as - * {@code LocalTime}, will return null. - *

    - * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    - * {@code LocalDate} returns {@code IsoChronology.INSTANCE}
    - * {@code LocalTime} returns null (does not represent a date)
    - * {@code LocalDateTime} returns {@code IsoChronology.INSTANCE}
    - * {@code ZonedDateTime} returns {@code IsoChronology.INSTANCE}
    - * {@code OffsetTime} returns null (does not represent a date)
    - * {@code OffsetDateTime} returns {@code IsoChronology.INSTANCE}
    - * {@code ChronoLocalDate} returns the associated chronology
    - * {@code ChronoLocalDateTime} returns the associated chronology
    - * {@code ChronoZonedDateTime} returns the associated chronology
    - * {@code Era} returns the associated chronology
    - * {@code DayOfWeek} returns null (shared across chronologies)
    - * {@code Month} returns {@code IsoChronology.INSTANCE}
    - * {@code Year} returns {@code IsoChronology.INSTANCE}
    - * {@code YearMonth} returns {@code IsoChronology.INSTANCE}
    - * {@code MonthDay} returns null {@code IsoChronology.INSTANCE}
    - * {@code ZoneOffset} returns null (does not represent a date)
    - * {@code Instant} returns null (does not represent a date)
    - *

    - * The method {@link Chronology#from(TemporalAccessor)} can be used as a - * {@code TemporalQuery} via a method reference, {@code Chronology::from}. - * That method is equivalent to this query, except that it throws an - * exception if a chronology cannot be obtained. - * - * @return a query that can obtain the chronology of a temporal, not null - */ - public static final TemporalQuery chronology() { - return CHRONO; - } - static final TemporalQuery CHRONO = (temporal) -> { - return temporal.query(CHRONO); - }; - - /** - * A query for the smallest supported unit. - *

    - * This queries a {@code TemporalAccessor} for the time precision. - * If the target {@code TemporalAccessor} represents a consistent or complete date-time, - * date or time then this must return the smallest precision actually supported. - * Note that fields such as {@code NANO_OF_DAY} and {@code NANO_OF_SECOND} - * are defined to always return ignoring the precision, thus this is the only - * way to find the actual smallest supported unit. - * For example, were {@code GregorianCalendar} to implement {@code TemporalAccessor} - * it would return a precision of {@code MILLIS}. - *

    - * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    - * {@code LocalDate} returns {@code DAYS}
    - * {@code LocalTime} returns {@code NANOS}
    - * {@code LocalDateTime} returns {@code NANOS}
    - * {@code ZonedDateTime} returns {@code NANOS}
    - * {@code OffsetTime} returns {@code NANOS}
    - * {@code OffsetDateTime} returns {@code NANOS}
    - * {@code ChronoLocalDate} returns {@code DAYS}
    - * {@code ChronoLocalDateTime} returns {@code NANOS}
    - * {@code ChronoZonedDateTime} returns {@code NANOS}
    - * {@code Era} returns {@code ERAS}
    - * {@code DayOfWeek} returns {@code DAYS}
    - * {@code Month} returns {@code MONTHS}
    - * {@code Year} returns {@code YEARS}
    - * {@code YearMonth} returns {@code MONTHS}
    - * {@code MonthDay} returns null (does not represent a complete date or time)
    - * {@code ZoneOffset} returns null (does not represent a date or time)
    - * {@code Instant} returns {@code NANOS}
    - * - * @return a query that can obtain the precision of a temporal, not null - */ - public static final TemporalQuery precision() { - return PRECISION; - } - static final TemporalQuery PRECISION = (temporal) -> { - return temporal.query(PRECISION); - }; - - //----------------------------------------------------------------------- - // non-special constants are standard queries that derive information from other information - /** - * A lenient query for the {@code ZoneId}, falling back to the {@code ZoneOffset}. - *

    - * This queries a {@code TemporalAccessor} for the zone. - * It first tries to obtain the zone, using {@link #zoneId()}. - * If that is not found it tries to obtain the {@link #offset()}. - * Thus a {@link ZonedDateTime} will return the result of {@code getZone()}, - * while an {@link OffsetDateTime} will return the result of {@code getOffset()}. - *

    - * In most cases, applications should use this query rather than {@code #zoneId()}. - *

    - * The method {@link ZoneId#from(TemporalAccessor)} can be used as a - * {@code TemporalQuery} via a method reference, {@code ZoneId::from}. - * That method is equivalent to this query, except that it throws an - * exception if a zone cannot be obtained. - * - * @return a query that can obtain the zone ID or offset of a temporal, not null - */ - public static final TemporalQuery zone() { - return ZONE; - } - static final TemporalQuery ZONE = (temporal) -> { - ZoneId zone = temporal.query(ZONE_ID); - return (zone != null ? zone : temporal.query(OFFSET)); - }; - - /** - * A query for {@code ZoneOffset} returning null if not found. - *

    - * This returns a {@code TemporalQuery} that can be used to query a temporal - * object for the offset. The query will return null if the temporal - * object cannot supply an offset. - *

    - * The query implementation examines the {@link ChronoField#OFFSET_SECONDS OFFSET_SECONDS} - * field and uses it to create a {@code ZoneOffset}. - *

    - * The method {@link ZoneOffset#from(TemporalAccessor)} can be used as a - * {@code TemporalQuery} via a method reference, {@code ZoneOffset::from}. - * This query and {@code ZoneOffset::from} will return the same result if the - * temporal object contains an offset. If the temporal object does not contain - * an offset, then the method reference will throw an exception, whereas this - * query will return null. - * - * @return a query that can obtain the offset of a temporal, not null - */ - public static final TemporalQuery offset() { - return OFFSET; - } - static final TemporalQuery OFFSET = (temporal) -> { - if (temporal.isSupported(OFFSET_SECONDS)) { - return ZoneOffset.ofTotalSeconds(temporal.get(OFFSET_SECONDS)); - } - return null; - }; - - /** - * A query for {@code LocalDate} returning null if not found. - *

    - * This returns a {@code TemporalQuery} that can be used to query a temporal - * object for the local date. The query will return null if the temporal - * object cannot supply a local date. - *

    - * The query implementation examines the {@link ChronoField#EPOCH_DAY EPOCH_DAY} - * field and uses it to create a {@code LocalDate}. - *

    - * The method {@link ZoneOffset#from(TemporalAccessor)} can be used as a - * {@code TemporalQuery} via a method reference, {@code LocalDate::from}. - * This query and {@code LocalDate::from} will return the same result if the - * temporal object contains a date. If the temporal object does not contain - * a date, then the method reference will throw an exception, whereas this - * query will return null. - * - * @return a query that can obtain the date of a temporal, not null - */ - public static final TemporalQuery localDate() { - return LOCAL_DATE; - } - static final TemporalQuery LOCAL_DATE = (temporal) -> { - if (temporal.isSupported(EPOCH_DAY)) { - return LocalDate.ofEpochDay(temporal.getLong(EPOCH_DAY)); - } - return null; - }; - - /** - * A query for {@code LocalTime} returning null if not found. - *

    - * This returns a {@code TemporalQuery} that can be used to query a temporal - * object for the local time. The query will return null if the temporal - * object cannot supply a local time. - *

    - * The query implementation examines the {@link ChronoField#NANO_OF_DAY NANO_OF_DAY} - * field and uses it to create a {@code LocalTime}. - *

    - * The method {@link ZoneOffset#from(TemporalAccessor)} can be used as a - * {@code TemporalQuery} via a method reference, {@code LocalTime::from}. - * This query and {@code LocalTime::from} will return the same result if the - * temporal object contains a time. If the temporal object does not contain - * a time, then the method reference will throw an exception, whereas this - * query will return null. - * - * @return a query that can obtain the time of a temporal, not null - */ - public static final TemporalQuery localTime() { - return LOCAL_TIME; - } - static final TemporalQuery LOCAL_TIME = (temporal) -> { - if (temporal.isSupported(NANO_OF_DAY)) { - return LocalTime.ofNanoOfDay(temporal.getLong(NANO_OF_DAY)); - } - return null; - }; - -} diff --git a/jdk/src/share/classes/java/time/temporal/Temporal.java b/jdk/src/share/classes/java/time/temporal/Temporal.java index 3eeed90b096..7cbc49fa176 100644 --- a/jdk/src/share/classes/java/time/temporal/Temporal.java +++ b/jdk/src/share/classes/java/time/temporal/Temporal.java @@ -83,7 +83,7 @@ import java.time.ZoneId; * Two pieces of date/time information cannot be represented by numbers, * the {@linkplain java.time.chrono.Chronology chronology} and the {@linkplain ZoneId time-zone}. * These can be accessed via {@link #query(TemporalQuery) queries} using - * the static methods defined on {@link Queries}. + * the static methods defined on {@link TemporalQuery}. *

    * This interface is a framework-level interface that should not be widely * used in application code. Instead, applications should create and pass @@ -134,7 +134,7 @@ public interface Temporal extends TemporalAccessor { * This adjusts this date-time according to the rules of the specified adjuster. * A simple adjuster might simply set the one of the fields, such as the year field. * A more complex adjuster might set the date to the last day of the month. - * A selection of common adjustments is provided in {@link Adjusters}. + * A selection of common adjustments is provided in {@link TemporalAdjuster}. * These include finding the "last day of the month" and "next Wednesday". * The adjuster is responsible for handling special cases, such as the varying * lengths of month and leap years. @@ -161,7 +161,7 @@ public interface Temporal extends TemporalAccessor { * @throws DateTimeException if unable to make the adjustment * @throws ArithmeticException if numeric overflow occurs */ - public default Temporal with(TemporalAdjuster adjuster) { + default Temporal with(TemporalAdjuster adjuster) { return adjuster.adjustInto(this); } @@ -180,7 +180,7 @@ public interface Temporal extends TemporalAccessor { *

    Specification for implementors

    * Implementations must check and handle all fields defined in {@link ChronoField}. * If the field is supported, then the adjustment must be performed. - * If unsupported, then a {@code DateTimeException} must be thrown. + * If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} @@ -194,6 +194,7 @@ public interface Temporal extends TemporalAccessor { * @param newValue the new value of the field in the result * @return an object of the same type with the specified field set, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ Temporal with(TemporalField field, long newValue); @@ -210,7 +211,6 @@ public interface Temporal extends TemporalAccessor { *

          *  date = date.plus(period);                      // add a Period instance
          *  date = date.plus(duration);                    // add a Duration instance
    -     *  date = date.plus(MONTHS.between(start, end));  // static import of MONTHS field
          *  date = date.plus(workingDays(6));              // example user-written workingDays method
          * 
    *

    @@ -232,7 +232,7 @@ public interface Temporal extends TemporalAccessor { * @throws DateTimeException if the addition cannot be made * @throws ArithmeticException if numeric overflow occurs */ - public default Temporal plus(TemporalAmount amount) { + default Temporal plus(TemporalAmount amount) { return amount.addTo(this); } @@ -255,7 +255,7 @@ public interface Temporal extends TemporalAccessor { *

    Specification for implementors

    * Implementations must check and handle all units defined in {@link ChronoUnit}. * If the unit is supported, then the addition must be performed. - * If unsupported, then a {@code DateTimeException} must be thrown. + * If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. *

    * If the unit is not a {@code ChronoUnit}, then the result of this method * is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} @@ -269,6 +269,7 @@ public interface Temporal extends TemporalAccessor { * @param unit the unit of the period to add, not null * @return an object of the same type with the specified period added, not null * @throws DateTimeException if the unit cannot be added + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ Temporal plus(long amountToAdd, TemporalUnit unit); @@ -285,7 +286,6 @@ public interface Temporal extends TemporalAccessor { *

          *  date = date.minus(period);                      // subtract a Period instance
          *  date = date.minus(duration);                    // subtract a Duration instance
    -     *  date = date.minus(MONTHS.between(start, end));  // static import of MONTHS field
          *  date = date.minus(workingDays(6));              // example user-written workingDays method
          * 
    *

    @@ -307,7 +307,7 @@ public interface Temporal extends TemporalAccessor { * @throws DateTimeException if the subtraction cannot be made * @throws ArithmeticException if numeric overflow occurs */ - public default Temporal minus(TemporalAmount amount) { + default Temporal minus(TemporalAmount amount) { return amount.subtractFrom(this); } @@ -344,9 +344,10 @@ public interface Temporal extends TemporalAccessor { * @param unit the unit of the period to subtract, not null * @return an object of the same type with the specified period subtracted, not null * @throws DateTimeException if the unit cannot be subtracted + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ - public default Temporal minus(long amountToSubtract, TemporalUnit unit) { + default Temporal minus(long amountToSubtract, TemporalUnit unit) { return (amountToSubtract == Long.MIN_VALUE ? plus(Long.MAX_VALUE, unit).plus(1, unit) : plus(-amountToSubtract, unit)); } @@ -388,7 +389,7 @@ public interface Temporal extends TemporalAccessor { * Implementations must begin by checking to ensure that the input temporal * object is of the same observable type as the implementation. * They must then perform the calculation for all instances of {@link ChronoUnit}. - * A {@code DateTimeException} must be thrown for {@code ChronoUnit} + * An {@code UnsupportedTemporalTypeException} must be thrown for {@code ChronoUnit} * instances that are unsupported. *

    * If the unit is not a {@code ChronoUnit}, then the result of this method @@ -401,7 +402,7 @@ public interface Temporal extends TemporalAccessor { * // check input temporal is the same type as this class * if (unit instanceof ChronoUnit) { * // if unit is supported, then calculate and return result - * // else throw DateTimeException for unsupported units + * // else throw UnsupportedTemporalTypeException for unsupported units * } * return unit.between(this, endTemporal); *

    @@ -414,6 +415,7 @@ public interface Temporal extends TemporalAccessor { * the unit; positive if the specified object is later than this one, negative if * it is earlier than this one * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported * @throws ArithmeticException if numeric overflow occurs */ long periodUntil(Temporal endTemporal, TemporalUnit unit); diff --git a/jdk/src/share/classes/java/time/temporal/TemporalAccessor.java b/jdk/src/share/classes/java/time/temporal/TemporalAccessor.java index cd09573c7d8..3f4a571e477 100644 --- a/jdk/src/share/classes/java/time/temporal/TemporalAccessor.java +++ b/jdk/src/share/classes/java/time/temporal/TemporalAccessor.java @@ -63,6 +63,7 @@ package java.time.temporal; import java.time.DateTimeException; import java.time.ZoneId; +import java.util.Objects; /** * Framework-level interface defining read-only access to a temporal object, @@ -80,8 +81,8 @@ import java.time.ZoneId; *

    * Two pieces of date/time information cannot be represented by numbers, * the {@linkplain java.time.chrono.Chronology chronology} and the {@linkplain ZoneId time-zone}. - * These can be accessed via {@link #query(TemporalQuery) queries} using - * the static methods defined on {@link Queries}. + * These can be accessed via {@linkplain #query(TemporalQuery) queries} using + * the static methods defined on {@link TemporalQuery}. *

    * A sub-interface, {@link Temporal}, extends this definition to one that also * supports adjustment and manipulation on more complete temporal objects. @@ -139,7 +140,7 @@ public interface TemporalAccessor { *

    Specification for implementors

    * Implementations must check and handle all fields defined in {@link ChronoField}. * If the field is supported, then the range of the field must be returned. - * If unsupported, then a {@code DateTimeException} must be thrown. + * If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessorl)} @@ -153,7 +154,7 @@ public interface TemporalAccessor { * if (isSupported(field)) { * return field.range(); * } - * throw new DateTimeException("Unsupported field: " + field.getName()); + * throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); * } * return field.rangeRefinedBy(this); * @@ -161,14 +162,16 @@ public interface TemporalAccessor { * @param field the field to query the range for, not null * @return the range of valid values for the field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported */ - public default ValueRange range(TemporalField field) { + default ValueRange range(TemporalField field) { if (field instanceof ChronoField) { if (isSupported(field)) { return field.range(); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } + Objects.requireNonNull(field, "field"); return field.rangeRefinedBy(this); } @@ -184,28 +187,40 @@ public interface TemporalAccessor { * Implementations must check and handle all fields defined in {@link ChronoField}. * If the field is supported and has an {@code int} range, then the value of * the field must be returned. - * If unsupported, then a {@code DateTimeException} must be thrown. + * If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} * passing {@code this} as the argument. *

    - * Implementations must not alter either this object. + * Implementations must not alter this object. *

    * The default implementation must behave equivalent to this code: *

    -     *  return range(field).checkValidIntValue(getLong(field), field);
    +     *  if (range(field).isIntValue()) {
    +     *    return range(field).checkValidIntValue(getLong(field), field);
    +     *  }
    +     *  throw new UnsupportedTemporalTypeException("Invalid field " + field + " + for get() method, use getLong() instead");
          * 
    * * @param field the field to get, not null * @return the value for the field, within the valid range of values - * @throws DateTimeException if a value for the field cannot be obtained - * @throws DateTimeException if the range of valid values for the field exceeds an {@code int} - * @throws DateTimeException if the value is outside the range of valid values for the field + * @throws DateTimeException if a value for the field cannot be obtained or + * the value is outside the range of valid values for the field + * @throws UnsupportedTemporalTypeException if the field is not supported or + * the range of values exceeds an {@code int} * @throws ArithmeticException if numeric overflow occurs */ - public default int get(TemporalField field) { - return range(field).checkValidIntValue(getLong(field), field); + default int get(TemporalField field) { + ValueRange range = range(field); + if (range.isIntValue() == false) { + throw new UnsupportedTemporalTypeException("Invalid field " + field + " + for get() method, use getLong() instead"); + } + long value = getLong(field); + if (range.isValidValue(value) == false) { + throw new DateTimeException("Invalid value for " + field + " (valid values " + range + "): " + value); + } + return (int) value; } /** @@ -219,7 +234,7 @@ public interface TemporalAccessor { *

    Specification for implementors

    * Implementations must check and handle all fields defined in {@link ChronoField}. * If the field is supported, then the value of the field must be returned. - * If unsupported, then a {@code DateTimeException} must be thrown. + * If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. *

    * If the field is not a {@code ChronoField}, then the result of this method * is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} @@ -230,6 +245,7 @@ public interface TemporalAccessor { * @param field the field to get, not null * @return the value for the field * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported * @throws ArithmeticException if numeric overflow occurs */ long getLong(TemporalField field); @@ -247,13 +263,13 @@ public interface TemporalAccessor { *

    * The most common query implementations are method references, such as * {@code LocalDate::from} and {@code ZoneId::from}. - * Further implementations are on {@link Queries}. - * Queries may also be defined by applications. + * Additional implementations are provided as static methods on {@link TemporalQuery}. * *

    Specification for implementors

    * The default implementation must behave equivalent to this code: *
    -     *  if (query == Queries.zoneId() || query == Queries.chronology() || query == Queries.precision()) {
    +     *  if (query == TemporalQuery.zoneId() ||
    +     *        query == TemporalQuery.chronology() || query == TemporalQuery.precision()) {
          *    return null;
          *  }
          *  return query.queryFrom(this);
    @@ -270,7 +286,7 @@ public interface TemporalAccessor {
          * For example, an application-defined {@code HourMin} class storing the hour
          * and minute must override this method as follows:
          * 
    -     *  if (query == Queries.precision()) {
    +     *  if (query == TemporalQuery.precision()) {
          *    return MINUTES;
          *  }
          *  return TemporalAccessor.super.query(query);
    @@ -282,8 +298,8 @@ public interface TemporalAccessor {
          * @throws DateTimeException if unable to query
          * @throws ArithmeticException if numeric overflow occurs
          */
    -    public default  R query(TemporalQuery query) {
    -        if (query == Queries.zoneId() || query == Queries.chronology() || query == Queries.precision()) {
    +    default  R query(TemporalQuery query) {
    +        if (query == TemporalQuery.zoneId() || query == TemporalQuery.chronology() || query == TemporalQuery.precision()) {
                 return null;
             }
             return query.queryFrom(this);
    diff --git a/jdk/src/share/classes/java/time/temporal/TemporalAdjuster.java b/jdk/src/share/classes/java/time/temporal/TemporalAdjuster.java
    index 2b808b6795b..0cd44a363d2 100644
    --- a/jdk/src/share/classes/java/time/temporal/TemporalAdjuster.java
    +++ b/jdk/src/share/classes/java/time/temporal/TemporalAdjuster.java
    @@ -62,6 +62,9 @@
     package java.time.temporal;
     
     import java.time.DateTimeException;
    +import java.time.DayOfWeek;
    +import java.time.LocalDate;
    +import java.util.function.UnaryOperator;
     
     /**
      * Strategy for adjusting a temporal object.
    @@ -83,13 +86,22 @@ import java.time.DateTimeException;
      * It is recommended to use the second approach, {@code with(TemporalAdjuster)},
      * as it is a lot clearer to read in code.
      * 

    - * See {@link Adjusters} for a standard set of adjusters, including finding the - * last day of the month. - * Adjusters may also be defined by applications. + * This class also contains a standard set of adjusters, available as static methods. + * These include: + *

      + *
    • finding the first or last day of the month + *
    • finding the first day of next month + *
    • finding the first or last day of the year + *
    • finding the first day of next year + *
    • finding the first or last day-of-week within a month, such as "first Wednesday in June" + *
    • finding the next or previous day-of-week, such as "next Thursday" + *
    * *

    Specification for implementors

    * This interface places no restrictions on the mutability of implementations, * however immutability is strongly recommended. + *

    + * All the implementations supplied by the static methods on this interface are immutable. * * @since 1.8 */ @@ -128,7 +140,7 @@ public interface TemporalAdjuster { *

    * The input temporal object may be in a calendar system other than ISO. * Implementations may choose to document compatibility with other calendar systems, - * or reject non-ISO temporal objects by {@link Queries#chronology() querying the chronology}. + * or reject non-ISO temporal objects by {@link TemporalQuery#chronology() querying the chronology}. *

    * This method may be called from multiple threads in parallel. * It must be thread-safe when invoked. @@ -140,4 +152,311 @@ public interface TemporalAdjuster { */ Temporal adjustInto(Temporal temporal); + //----------------------------------------------------------------------- + /** + * Obtains a {@code TemporalAdjuster} that wraps a date adjuster. + *

    + * The {@code TemporalAdjuster} is based on the low level {@code Temporal} interface. + * This method allows an adjustment from {@code LocalDate} to {@code LocalDate} + * to be wrapped to match the temporal-based interface. + * This is provided for convenience to make user-written adjusters simpler. + *

    + * In general, user-written adjusters should be static constants: + *

    +     *  static TemporalAdjuster TWO_DAYS_LATER = TemporalAdjuster.ofDateAdjuster(
    +     *    date -> date.plusDays(2));
    +     * 
    + * + * @param dateBasedAdjuster the date-based adjuster, not null + * @return the temporal adjuster wrapping on the date adjuster, not null + */ + static TemporalAdjuster ofDateAdjuster(UnaryOperator dateBasedAdjuster) { + return TemporalAdjusters.ofDateAdjuster(dateBasedAdjuster); + } + + //----------------------------------------------------------------------- + /** + * Returns the "first day of month" adjuster, which returns a new date set to + * the first day of the current month. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-01-01.
    + * The input 2011-02-15 will return 2011-02-01. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_MONTH, 1);
    +     * 
    + * + * @return the first day-of-month adjuster, not null + */ + static TemporalAdjuster firstDayOfMonth() { + return TemporalAdjusters.firstDayOfMonth(); + } + + /** + * Returns the "last day of month" adjuster, which returns a new date set to + * the last day of the current month. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-01-31.
    + * The input 2011-02-15 will return 2011-02-28.
    + * The input 2012-02-15 will return 2012-02-29 (leap year).
    + * The input 2011-04-15 will return 2011-04-30. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  long lastDay = temporal.range(DAY_OF_MONTH).getMaximum();
    +     *  temporal.with(DAY_OF_MONTH, lastDay);
    +     * 
    + * + * @return the last day-of-month adjuster, not null + */ + static TemporalAdjuster lastDayOfMonth() { + return TemporalAdjusters.lastDayOfMonth(); + } + + /** + * Returns the "first day of next month" adjuster, which returns a new date set to + * the first day of the next month. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-02-01.
    + * The input 2011-02-15 will return 2011-03-01. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_MONTH, 1).plus(1, MONTHS);
    +     * 
    + * + * @return the first day of next month adjuster, not null + */ + static TemporalAdjuster firstDayOfNextMonth() { + return TemporalAdjusters.firstDayOfNextMonth(); + } + + //----------------------------------------------------------------------- + /** + * Returns the "first day of year" adjuster, which returns a new date set to + * the first day of the current year. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-01-01.
    + * The input 2011-02-15 will return 2011-01-01.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_YEAR, 1);
    +     * 
    + * + * @return the first day-of-year adjuster, not null + */ + static TemporalAdjuster firstDayOfYear() { + return TemporalAdjusters.firstDayOfYear(); + } + + /** + * Returns the "last day of year" adjuster, which returns a new date set to + * the last day of the current year. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2011-12-31.
    + * The input 2011-02-15 will return 2011-12-31.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  long lastDay = temporal.range(DAY_OF_YEAR).getMaximum();
    +     *  temporal.with(DAY_OF_YEAR, lastDay);
    +     * 
    + * + * @return the last day-of-year adjuster, not null + */ + static TemporalAdjuster lastDayOfYear() { + return TemporalAdjusters.lastDayOfYear(); + } + + /** + * Returns the "first day of next year" adjuster, which returns a new date set to + * the first day of the next year. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 will return 2012-01-01. + *

    + * The behavior is suitable for use with most calendar systems. + * It is equivalent to: + *

    +     *  temporal.with(DAY_OF_YEAR, 1).plus(1, YEARS);
    +     * 
    + * + * @return the first day of next month adjuster, not null + */ + static TemporalAdjuster firstDayOfNextYear() { + return TemporalAdjusters.firstDayOfNextYear(); + } + + //----------------------------------------------------------------------- + /** + * Returns the first in month adjuster, which returns a new date + * in the same month with the first matching day-of-week. + * This is used for expressions like 'first Tuesday in March'. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-12-15 for (MONDAY) will return 2011-12-05.
    + * The input 2011-12-15 for (FRIDAY) will return 2011-12-02.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields + * and the {@code DAYS} unit, and assumes a seven day week. + * + * @param dayOfWeek the day-of-week, not null + * @return the first in month adjuster, not null + */ + static TemporalAdjuster firstInMonth(DayOfWeek dayOfWeek) { + return TemporalAdjuster.dayOfWeekInMonth(1, dayOfWeek); + } + + /** + * Returns the last in month adjuster, which returns a new date + * in the same month with the last matching day-of-week. + * This is used for expressions like 'last Tuesday in March'. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-12-15 for (MONDAY) will return 2011-12-26.
    + * The input 2011-12-15 for (FRIDAY) will return 2011-12-30.
    + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields + * and the {@code DAYS} unit, and assumes a seven day week. + * + * @param dayOfWeek the day-of-week, not null + * @return the first in month adjuster, not null + */ + static TemporalAdjuster lastInMonth(DayOfWeek dayOfWeek) { + return TemporalAdjuster.dayOfWeekInMonth(-1, dayOfWeek); + } + + /** + * Returns the day-of-week in month adjuster, which returns a new date + * in the same month with the ordinal day-of-week. + * This is used for expressions like the 'second Tuesday in March'. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-12-15 for (1,TUESDAY) will return 2011-12-06.
    + * The input 2011-12-15 for (2,TUESDAY) will return 2011-12-13.
    + * The input 2011-12-15 for (3,TUESDAY) will return 2011-12-20.
    + * The input 2011-12-15 for (4,TUESDAY) will return 2011-12-27.
    + * The input 2011-12-15 for (5,TUESDAY) will return 2012-01-03.
    + * The input 2011-12-15 for (-1,TUESDAY) will return 2011-12-27 (last in month).
    + * The input 2011-12-15 for (-4,TUESDAY) will return 2011-12-06 (3 weeks before last in month).
    + * The input 2011-12-15 for (-5,TUESDAY) will return 2011-11-29 (4 weeks before last in month).
    + * The input 2011-12-15 for (0,TUESDAY) will return 2011-11-29 (last in previous month).
    + *

    + * For a positive or zero ordinal, the algorithm is equivalent to finding the first + * day-of-week that matches within the month and then adding a number of weeks to it. + * For a negative ordinal, the algorithm is equivalent to finding the last + * day-of-week that matches within the month and then subtracting a number of weeks to it. + * The ordinal number of weeks is not validated and is interpreted leniently + * according to this algorithm. This definition means that an ordinal of zero finds + * the last matching day-of-week in the previous month. + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields + * and the {@code DAYS} unit, and assumes a seven day week. + * + * @param ordinal the week within the month, unbounded but typically from -5 to 5 + * @param dayOfWeek the day-of-week, not null + * @return the day-of-week in month adjuster, not null + */ + static TemporalAdjuster dayOfWeekInMonth(final int ordinal, DayOfWeek dayOfWeek) { + return TemporalAdjusters.dayOfWeekInMonth(ordinal, dayOfWeek); + } + + //----------------------------------------------------------------------- + /** + * Returns the next day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week after the date being adjusted. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-17 (two days later).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-19 (four days later).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-22 (seven days later). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to move the date to, not null + * @return the next day-of-week adjuster, not null + */ + static TemporalAdjuster next(DayOfWeek dayOfWeek) { + return TemporalAdjusters.next(dayOfWeek); + } + + /** + * Returns the next-or-same day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week after the date being adjusted + * unless it is already on that day in which case the same object is returned. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-17 (two days later).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-19 (four days later).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-15 (same as input). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to check for or move the date to, not null + * @return the next-or-same day-of-week adjuster, not null + */ + static TemporalAdjuster nextOrSame(DayOfWeek dayOfWeek) { + return TemporalAdjusters.nextOrSame(dayOfWeek); + } + + /** + * Returns the previous day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week before the date being adjusted. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-10 (five days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-12 (three days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-08 (seven days earlier). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to move the date to, not null + * @return the previous day-of-week adjuster, not null + */ + static TemporalAdjuster previous(DayOfWeek dayOfWeek) { + return TemporalAdjusters.previous(dayOfWeek); + } + + /** + * Returns the previous-or-same day-of-week adjuster, which adjusts the date to the + * first occurrence of the specified day-of-week before the date being adjusted + * unless it is already on that day in which case the same object is returned. + *

    + * The ISO calendar system behaves as follows:
    + * The input 2011-01-15 (a Saturday) for parameter (MONDAY) will return 2011-01-10 (five days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (WEDNESDAY) will return 2011-01-12 (three days earlier).
    + * The input 2011-01-15 (a Saturday) for parameter (SATURDAY) will return 2011-01-15 (same as input). + *

    + * The behavior is suitable for use with most calendar systems. + * It uses the {@code DAY_OF_WEEK} field and the {@code DAYS} unit, + * and assumes a seven day week. + * + * @param dayOfWeek the day-of-week to check for or move the date to, not null + * @return the previous-or-same day-of-week adjuster, not null + */ + static TemporalAdjuster previousOrSame(DayOfWeek dayOfWeek) { + return TemporalAdjusters.previousOrSame(dayOfWeek); + } + } diff --git a/jdk/src/share/classes/java/time/temporal/Adjusters.java b/jdk/src/share/classes/java/time/temporal/TemporalAdjusters.java similarity index 70% rename from jdk/src/share/classes/java/time/temporal/Adjusters.java rename to jdk/src/share/classes/java/time/temporal/TemporalAdjusters.java index 45ccfd1a9f5..293485363a4 100644 --- a/jdk/src/share/classes/java/time/temporal/Adjusters.java +++ b/jdk/src/share/classes/java/time/temporal/TemporalAdjusters.java @@ -29,7 +29,7 @@ * However, the following notice accompanied the original version of this * file: * - * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos + * Copyright (c) 2012-2013, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. * @@ -69,45 +69,46 @@ import static java.time.temporal.ChronoUnit.MONTHS; import static java.time.temporal.ChronoUnit.YEARS; import java.time.DayOfWeek; +import java.time.LocalDate; import java.util.Objects; +import java.util.function.UnaryOperator; /** - * Common implementations of {@code TemporalAdjuster}. - *

    - * This class provides common implementations of {@link TemporalAdjuster}. - * They are especially useful to document the intent of business logic and - * often link well to requirements. - * For example, these two pieces of code do the same thing, but the second - * one is clearer (assuming that there is a static import of this class): - *

    - *  // direct manipulation
    - *  date.withDayOfMonth(1).plusMonths(1).minusDays(1);
    - *  // use of an adjuster from this class
    - *  date.with(lastDayOfMonth());
    - * 
    - * There are two equivalent ways of using a {@code TemporalAdjuster}. - * The first is to invoke the method on the interface directly. - * The second is to use {@link Temporal#with(TemporalAdjuster)}: - *
    - *   // these two lines are equivalent, but the second approach is recommended
    - *   dateTime = adjuster.adjustInto(dateTime);
    - *   dateTime = dateTime.with(adjuster);
    - * 
    - * It is recommended to use the second approach, {@code with(TemporalAdjuster)}, - * as it is a lot clearer to read in code. - * - *

    Specification for implementors

    - * This is a thread-safe utility class. - * All returned adjusters are immutable and thread-safe. + * Implementations of the static methods in {@code TemporalAdjuster} * * @since 1.8 */ -public final class Adjusters { +final class TemporalAdjusters { + // work around compiler bug not allowing lambdas in static methods + private TemporalAdjusters() { + } + + //----------------------------------------------------------------------- /** - * Private constructor since this is a utility class. + * Obtains a {@code TemporalAdjuster} that wraps a date adjuster. + *

    + * The {@code TemporalAdjuster} is based on the low level {@code Temporal} interface. + * This method allows an adjustment from {@code LocalDate} to {@code LocalDate} + * to be wrapped to match the temporal-based interface. + * This is provided for convenience to make user-written adjusters simpler. + *

    + * In general, user-written adjusters should be static constants: + *

    +     *  public static TemporalAdjuster TWO_DAYS_LATER = TemporalAdjuster.ofDateAdjuster(
    +     *    date -> date.plusDays(2));
    +     * 
    + * + * @param dateBasedAdjuster the date-based adjuster, not null + * @return the temporal adjuster wrapping on the date adjuster, not null */ - private Adjusters() { + static TemporalAdjuster ofDateAdjuster(UnaryOperator dateBasedAdjuster) { + Objects.requireNonNull(dateBasedAdjuster, "dateBasedAdjuster"); + return (temporal) -> { + LocalDate input = LocalDate.from(temporal); + LocalDate output = dateBasedAdjuster.apply(input); + return temporal.with(output); + }; } //----------------------------------------------------------------------- @@ -127,8 +128,8 @@ public final class Adjusters { * * @return the first day-of-month adjuster, not null */ - public static TemporalAdjuster firstDayOfMonth() { - return Impl.FIRST_DAY_OF_MONTH; + static TemporalAdjuster firstDayOfMonth() { + return (temporal) -> temporal.with(DAY_OF_MONTH, 1); } /** @@ -150,8 +151,8 @@ public final class Adjusters { * * @return the last day-of-month adjuster, not null */ - public static TemporalAdjuster lastDayOfMonth() { - return Impl.LAST_DAY_OF_MONTH; + static TemporalAdjuster lastDayOfMonth() { + return (temporal) -> temporal.with(DAY_OF_MONTH, temporal.range(DAY_OF_MONTH).getMaximum()); } /** @@ -170,8 +171,8 @@ public final class Adjusters { * * @return the first day of next month adjuster, not null */ - public static TemporalAdjuster firstDayOfNextMonth() { - return Impl.FIRST_DAY_OF_NEXT_MONTH; + static TemporalAdjuster firstDayOfNextMonth() { + return (temporal) -> temporal.with(DAY_OF_MONTH, 1).plus(1, MONTHS); } //----------------------------------------------------------------------- @@ -191,8 +192,8 @@ public final class Adjusters { * * @return the first day-of-year adjuster, not null */ - public static TemporalAdjuster firstDayOfYear() { - return Impl.FIRST_DAY_OF_YEAR; + static TemporalAdjuster firstDayOfYear() { + return (temporal) -> temporal.with(DAY_OF_YEAR, 1); } /** @@ -212,8 +213,8 @@ public final class Adjusters { * * @return the last day-of-year adjuster, not null */ - public static TemporalAdjuster lastDayOfYear() { - return Impl.LAST_DAY_OF_YEAR; + static TemporalAdjuster lastDayOfYear() { + return (temporal) -> temporal.with(DAY_OF_YEAR, temporal.range(DAY_OF_YEAR).getMaximum()); } /** @@ -231,44 +232,8 @@ public final class Adjusters { * * @return the first day of next month adjuster, not null */ - public static TemporalAdjuster firstDayOfNextYear() { - return Impl.FIRST_DAY_OF_NEXT_YEAR; - } - - //----------------------------------------------------------------------- - /** - * Enum implementing the adjusters. - */ - private static class Impl implements TemporalAdjuster { - /** First day of month adjuster. */ - private static final Impl FIRST_DAY_OF_MONTH = new Impl(0); - /** Last day of month adjuster. */ - private static final Impl LAST_DAY_OF_MONTH = new Impl(1); - /** First day of next month adjuster. */ - private static final Impl FIRST_DAY_OF_NEXT_MONTH = new Impl(2); - /** First day of year adjuster. */ - private static final Impl FIRST_DAY_OF_YEAR = new Impl(3); - /** Last day of year adjuster. */ - private static final Impl LAST_DAY_OF_YEAR = new Impl(4); - /** First day of next month adjuster. */ - private static final Impl FIRST_DAY_OF_NEXT_YEAR = new Impl(5); - /** The ordinal. */ - private final int ordinal; - private Impl(int ordinal) { - this.ordinal = ordinal; - } - @Override - public Temporal adjustInto(Temporal temporal) { - switch (ordinal) { - case 0: return temporal.with(DAY_OF_MONTH, 1); - case 1: return temporal.with(DAY_OF_MONTH, temporal.range(DAY_OF_MONTH).getMaximum()); - case 2: return temporal.with(DAY_OF_MONTH, 1).plus(1, MONTHS); - case 3: return temporal.with(DAY_OF_YEAR, 1); - case 4: return temporal.with(DAY_OF_YEAR, temporal.range(DAY_OF_YEAR).getMaximum()); - case 5: return temporal.with(DAY_OF_YEAR, 1).plus(1, YEARS); - } - throw new IllegalStateException("Unreachable"); - } + static TemporalAdjuster firstDayOfNextYear() { + return (temporal) -> temporal.with(DAY_OF_YEAR, 1).plus(1, YEARS); } //----------------------------------------------------------------------- @@ -288,9 +253,8 @@ public final class Adjusters { * @param dayOfWeek the day-of-week, not null * @return the first in month adjuster, not null */ - public static TemporalAdjuster firstInMonth(DayOfWeek dayOfWeek) { - Objects.requireNonNull(dayOfWeek, "dayOfWeek"); - return new DayOfWeekInMonth(1, dayOfWeek); + static TemporalAdjuster firstInMonth(DayOfWeek dayOfWeek) { + return TemporalAdjusters.dayOfWeekInMonth(1, dayOfWeek); } /** @@ -309,9 +273,8 @@ public final class Adjusters { * @param dayOfWeek the day-of-week, not null * @return the first in month adjuster, not null */ - public static TemporalAdjuster lastInMonth(DayOfWeek dayOfWeek) { - Objects.requireNonNull(dayOfWeek, "dayOfWeek"); - return new DayOfWeekInMonth(-1, dayOfWeek); + static TemporalAdjuster lastInMonth(DayOfWeek dayOfWeek) { + return TemporalAdjusters.dayOfWeekInMonth(-1, dayOfWeek); } /** @@ -342,46 +305,30 @@ public final class Adjusters { * It uses the {@code DAY_OF_WEEK} and {@code DAY_OF_MONTH} fields * and the {@code DAYS} unit, and assumes a seven day week. * - * @param ordinal the week within the month, unbound but typically from -5 to 5 + * @param ordinal the week within the month, unbounded but typically from -5 to 5 * @param dayOfWeek the day-of-week, not null * @return the day-of-week in month adjuster, not null - * @throws IllegalArgumentException if the ordinal is invalid */ - public static TemporalAdjuster dayOfWeekInMonth(int ordinal, DayOfWeek dayOfWeek) { + static TemporalAdjuster dayOfWeekInMonth(int ordinal, DayOfWeek dayOfWeek) { Objects.requireNonNull(dayOfWeek, "dayOfWeek"); - return new DayOfWeekInMonth(ordinal, dayOfWeek); - } - - /** - * Class implementing day-of-week in month adjuster. - */ - private static final class DayOfWeekInMonth implements TemporalAdjuster { - /** The ordinal. */ - private final int ordinal; - /** The day-of-week value, from 1 to 7. */ - private final int dowValue; - - private DayOfWeekInMonth(int ordinal, DayOfWeek dow) { - super(); - this.ordinal = ordinal; - this.dowValue = dow.getValue(); - } - @Override - public Temporal adjustInto(Temporal temporal) { - if (ordinal >= 0) { + int dowValue = dayOfWeek.getValue(); + if (ordinal >= 0) { + return (temporal) -> { Temporal temp = temporal.with(DAY_OF_MONTH, 1); int curDow = temp.get(DAY_OF_WEEK); int dowDiff = (dowValue - curDow + 7) % 7; dowDiff += (ordinal - 1L) * 7L; // safe from overflow return temp.plus(dowDiff, DAYS); - } else { + }; + } else { + return (temporal) -> { Temporal temp = temporal.with(DAY_OF_MONTH, temporal.range(DAY_OF_MONTH).getMaximum()); int curDow = temp.get(DAY_OF_WEEK); int daysDiff = dowValue - curDow; daysDiff = (daysDiff == 0 ? 0 : (daysDiff > 0 ? daysDiff - 7 : daysDiff)); daysDiff -= (-ordinal - 1L) * 7L; // safe from overflow return temp.plus(daysDiff, DAYS); - } + }; } } @@ -402,8 +349,13 @@ public final class Adjusters { * @param dayOfWeek the day-of-week to move the date to, not null * @return the next day-of-week adjuster, not null */ - public static TemporalAdjuster next(DayOfWeek dayOfWeek) { - return new RelativeDayOfWeek(2, dayOfWeek); + static TemporalAdjuster next(DayOfWeek dayOfWeek) { + int dowValue = dayOfWeek.getValue(); + return (temporal) -> { + int calDow = temporal.get(DAY_OF_WEEK); + int daysDiff = calDow - dowValue; + return temporal.plus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); + }; } /** @@ -423,8 +375,16 @@ public final class Adjusters { * @param dayOfWeek the day-of-week to check for or move the date to, not null * @return the next-or-same day-of-week adjuster, not null */ - public static TemporalAdjuster nextOrSame(DayOfWeek dayOfWeek) { - return new RelativeDayOfWeek(0, dayOfWeek); + static TemporalAdjuster nextOrSame(DayOfWeek dayOfWeek) { + int dowValue = dayOfWeek.getValue(); + return (temporal) -> { + int calDow = temporal.get(DAY_OF_WEEK); + if (calDow == dowValue) { + return temporal; + } + int daysDiff = calDow - dowValue; + return temporal.plus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); + }; } /** @@ -443,8 +403,13 @@ public final class Adjusters { * @param dayOfWeek the day-of-week to move the date to, not null * @return the previous day-of-week adjuster, not null */ - public static TemporalAdjuster previous(DayOfWeek dayOfWeek) { - return new RelativeDayOfWeek(3, dayOfWeek); + static TemporalAdjuster previous(DayOfWeek dayOfWeek) { + int dowValue = dayOfWeek.getValue(); + return (temporal) -> { + int calDow = temporal.get(DAY_OF_WEEK); + int daysDiff = dowValue - calDow; + return temporal.minus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); + }; } /** @@ -464,39 +429,16 @@ public final class Adjusters { * @param dayOfWeek the day-of-week to check for or move the date to, not null * @return the previous-or-same day-of-week adjuster, not null */ - public static TemporalAdjuster previousOrSame(DayOfWeek dayOfWeek) { - return new RelativeDayOfWeek(1, dayOfWeek); - } - - /** - * Implementation of next, previous or current day-of-week. - */ - private static final class RelativeDayOfWeek implements TemporalAdjuster { - /** Whether the current date is a valid answer. */ - private final int relative; - /** The day-of-week value, from 1 to 7. */ - private final int dowValue; - - private RelativeDayOfWeek(int relative, DayOfWeek dayOfWeek) { - Objects.requireNonNull(dayOfWeek, "dayOfWeek"); - this.relative = relative; - this.dowValue = dayOfWeek.getValue(); - } - - @Override - public Temporal adjustInto(Temporal temporal) { + static TemporalAdjuster previousOrSame(DayOfWeek dayOfWeek) { + int dowValue = dayOfWeek.getValue(); + return (temporal) -> { int calDow = temporal.get(DAY_OF_WEEK); - if (relative < 2 && calDow == dowValue) { + if (calDow == dowValue) { return temporal; } - if ((relative & 1) == 0) { - int daysDiff = calDow - dowValue; - return temporal.plus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); - } else { - int daysDiff = dowValue - calDow; - return temporal.minus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); - } - } + int daysDiff = dowValue - calDow; + return temporal.minus(daysDiff >= 0 ? 7 - daysDiff : -daysDiff, DAYS); + }; } } diff --git a/jdk/src/share/classes/java/time/temporal/TemporalAmount.java b/jdk/src/share/classes/java/time/temporal/TemporalAmount.java index 6fa4e47a36f..a264ebaa604 100644 --- a/jdk/src/share/classes/java/time/temporal/TemporalAmount.java +++ b/jdk/src/share/classes/java/time/temporal/TemporalAmount.java @@ -75,7 +75,7 @@ import java.util.List; * to any specific point on the time-line. *

    * The amount can be thought of as a {@code Map} of {@link TemporalUnit} to - * {@code long}, exposed via {@link #getUnits()}and {@link #get(TemporalUnit)}. + * {@code long}, exposed via {@link #getUnits()} and {@link #get(TemporalUnit)}. * A simple case might have a single unit-value pair, such as "6 hours". * A more complex case may have multiple unit-value pairs, such as * "7 years, 3 months and 5 days". @@ -111,9 +111,10 @@ public interface TemporalAmount { * * @param unit the {@code TemporalUnit} for which to return the value * @return the long value of the unit - * @throws DateTimeException if the {@code unit} is not supported + * @throws DateTimeException if a value for the unit cannot be obtained + * @throws UnsupportedTemporalTypeException if the {@code unit} is not supported */ - public long get(TemporalUnit unit); + long get(TemporalUnit unit); /** * Returns the list of units uniquely defining the value of this TemporalAmount. @@ -130,7 +131,7 @@ public interface TemporalAmount { * * @return the List of {@code TemporalUnits}; not null */ - public List getUnits(); + List getUnits(); /** * Adds to the specified temporal object. @@ -162,7 +163,7 @@ public interface TemporalAmount { *

    * The input temporal object may be in a calendar system other than ISO. * Implementations may choose to document compatibility with other calendar systems, - * or reject non-ISO temporal objects by {@link Queries#chronology() querying the chronology}. + * or reject non-ISO temporal objects by {@link TemporalQuery#chronology() querying the chronology}. *

    * This method may be called from multiple threads in parallel. * It must be thread-safe when invoked. @@ -172,7 +173,7 @@ public interface TemporalAmount { * @throws DateTimeException if unable to add * @throws ArithmeticException if numeric overflow occurs */ - public Temporal addTo(Temporal temporal); + Temporal addTo(Temporal temporal); /** * Subtracts this object from the specified temporal object. @@ -204,7 +205,7 @@ public interface TemporalAmount { *

    * The input temporal object may be in a calendar system other than ISO. * Implementations may choose to document compatibility with other calendar systems, - * or reject non-ISO temporal objects by {@link Queries#chronology() querying the chronology}. + * or reject non-ISO temporal objects by {@link TemporalQuery#chronology() querying the chronology}. *

    * This method may be called from multiple threads in parallel. * It must be thread-safe when invoked. @@ -214,5 +215,5 @@ public interface TemporalAmount { * @throws DateTimeException if unable to subtract * @throws ArithmeticException if numeric overflow occurs */ - public Temporal subtractFrom(Temporal temporal); + Temporal subtractFrom(Temporal temporal); } diff --git a/jdk/src/share/classes/java/time/temporal/TemporalField.java b/jdk/src/share/classes/java/time/temporal/TemporalField.java index c456f56e866..81992b4fb2f 100644 --- a/jdk/src/share/classes/java/time/temporal/TemporalField.java +++ b/jdk/src/share/classes/java/time/temporal/TemporalField.java @@ -62,8 +62,10 @@ package java.time.temporal; import java.time.DateTimeException; -import java.util.Comparator; +import java.time.format.ResolverStyle; +import java.util.Locale; import java.util.Map; +import java.util.Objects; /** * A field of date-time, such as month-of-year or hour-of-minute. @@ -88,7 +90,7 @@ import java.util.Map; * * @since 1.8 */ -public interface TemporalField extends Comparator { +public interface TemporalField { /** * Gets a descriptive name for the field. @@ -101,6 +103,21 @@ public interface TemporalField extends Comparator { */ String getName(); + /** + * Gets the display name for the field in the requested locale. + *

    + * If there is no display name for the locale the value of {@code getName} + * is returned. + * + * @param locale the locale to use, not null + * @return the display name for the locale or the value of {@code getName}, + * not null + */ + default String getDisplayName(Locale locale) { + Objects.requireNonNull(locale, "local"); + return getName(); + } + /** * Gets the unit that the field is measured in. *

    @@ -126,28 +143,6 @@ public interface TemporalField extends Comparator { */ TemporalUnit getRangeUnit(); - //----------------------------------------------------------------------- - /** - * Compares the value of this field in two temporal objects. - *

    - * All fields implement {@link Comparator} on {@link TemporalAccessor}. - * This allows a list of date-times to be compared using the value of a field. - * For example, you could sort a list of arbitrary temporal objects by the value of - * the month-of-year field - {@code Collections.sort(list, MONTH_OF_YEAR)} - *

    - * The default implementation must behave equivalent to this code: - *

    -     *  return Long.compare(temporal1.getLong(this), temporal2.getLong(this));
    -     * 
    - * - * @param temporal1 the first temporal object to compare, not null - * @param temporal2 the second temporal object to compare, not null - * @throws DateTimeException if unable to obtain the value for this field - */ - public default int compare(TemporalAccessor temporal1, TemporalAccessor temporal2) { - return Long.compare(temporal1.getLong(this), temporal2.getLong(this)); - } - /** * Gets the range of valid values for the field. *

    @@ -163,6 +158,35 @@ public interface TemporalField extends Comparator { */ ValueRange range(); + //----------------------------------------------------------------------- + /** + * Checks if this field represents a component of a date. + *

    + * A field is date-based if it can be derived from + * {@link ChronoField#EPOCH_DAY EPOCH_DAY}. + *

    + * The default implementation must return false. + * + * @return true if this field is a component of a date + */ + default boolean isDateBased() { + return false; + } + + /** + * Checks if this field represents a component of a time. + *

    + * A field is time-based if it can be derived from + * {@link ChronoField#NANO_OF_DAY NANO_OF_DAY}. + *

    + * The default implementation must return false. + * + * @return true if this field is a component of a time + */ + default boolean isTimeBased() { + return false; + } + //----------------------------------------------------------------------- /** * Checks if this field is supported by the temporal object. @@ -213,11 +237,12 @@ public interface TemporalField extends Comparator { *

    * Implementations should perform any queries or calculations using the fields * available in {@link ChronoField}. - * If the field is not supported a {@code DateTimeException} must be thrown. + * If the field is not supported an {@code UnsupportedTemporalTypeException} must be thrown. * * @param temporal the temporal object used to refine the result, not null * @return the range of valid values for this field, not null * @throws DateTimeException if the range for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported by the temporal */ ValueRange rangeRefinedBy(TemporalAccessor temporal); @@ -240,11 +265,12 @@ public interface TemporalField extends Comparator { *

    * Implementations should perform any queries or calculations using the fields * available in {@link ChronoField}. - * If the field is not supported a {@code DateTimeException} must be thrown. + * If the field is not supported an {@code UnsupportedTemporalTypeException} must be thrown. * * @param temporal the temporal object to query, not null * @return the value of this field, not null * @throws DateTimeException if a value for the field cannot be obtained + * @throws UnsupportedTemporalTypeException if the field is not supported by the temporal * @throws ArithmeticException if numeric overflow occurs */ long getFrom(TemporalAccessor temporal); @@ -276,7 +302,7 @@ public interface TemporalField extends Comparator { *

    * Implementations should perform any queries or calculations using the fields * available in {@link ChronoField}. - * If the field is not supported a {@code DateTimeException} must be thrown. + * If the field is not supported an {@code UnsupportedTemporalTypeException} must be thrown. *

    * Implementations must not alter the specified temporal object. * Instead, an adjusted copy of the original must be returned. @@ -287,6 +313,7 @@ public interface TemporalField extends Comparator { * @param newValue the new value of the field * @return the adjusted temporal object, not null * @throws DateTimeException if the field cannot be set + * @throws UnsupportedTemporalTypeException if the field is not supported by the temporal * @throws ArithmeticException if numeric overflow occurs */ R adjustInto(R temporal, long newValue); @@ -314,17 +341,22 @@ public interface TemporalField extends Comparator { * If the result is non-null, this field will be removed from the temporal. * This field should not be added to the result map. *

    + * The {@link ResolverStyle} should be used by implementations to determine + * how to perform the resolve. + *

    * The default implementation must return null. * * @param temporal the temporal to resolve, not null * @param value the value of this field + * @param resolverStyle the requested type of resolve, not null * @return a map of fields to update in the temporal, with a mapping to null * indicating a deletion. The whole map must be null if no resolving occurred * @throws DateTimeException if resolving results in an error. This must not be thrown * by querying a field on the temporal without first checking if it is supported * @throws ArithmeticException if numeric overflow occurs */ - public default Map resolve(TemporalAccessor temporal, long value) { + default Map resolve( + TemporalAccessor temporal, long value, ResolverStyle resolverStyle) { return null; } diff --git a/jdk/src/share/classes/java/time/temporal/TemporalQueries.java b/jdk/src/share/classes/java/time/temporal/TemporalQueries.java new file mode 100644 index 00000000000..f7c95add925 --- /dev/null +++ b/jdk/src/share/classes/java/time/temporal/TemporalQueries.java @@ -0,0 +1,157 @@ +/* + * 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. 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package java.time.temporal; + +import static java.time.temporal.ChronoField.EPOCH_DAY; +import static java.time.temporal.ChronoField.NANO_OF_DAY; +import static java.time.temporal.ChronoField.OFFSET_SECONDS; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.chrono.Chronology; + +/** + * Common implementations of {@code TemporalQuery}. + *

    + * This class provides common implementations of {@link TemporalQuery}. + * These are defined here as they must be constants, and the definition + * of lambdas does not guarantee that. By assigning them once here, + * they become 'normal' Java constants. + * + * @since 1.8 + */ +final class TemporalQueries { + // note that it is vital that each method supplies a constant, not a + // calculated value, as they will be checked for using == + // it is also vital that each constant is different (due to the == checking) + // as such, alterations to this code must be done with care + + /** + * Private constructor since this is a utility class. + */ + private TemporalQueries() { + } + + //----------------------------------------------------------------------- + /** + * A strict query for the {@code ZoneId}. + */ + static final TemporalQuery ZONE_ID = (temporal) -> { + return temporal.query(ZONE_ID); + }; + + /** + * A query for the {@code Chronology}. + */ + static final TemporalQuery CHRONO = (temporal) -> { + return temporal.query(CHRONO); + }; + + /** + * A query for the smallest supported unit. + */ + static final TemporalQuery PRECISION = (temporal) -> { + return temporal.query(PRECISION); + }; + + //----------------------------------------------------------------------- + /** + * A lenient query for the {@code ZoneId}, falling back to the {@code ZoneOffset}. + */ + static final TemporalQuery ZONE = (temporal) -> { + ZoneId zone = temporal.query(ZONE_ID); + return (zone != null ? zone : temporal.query(OFFSET)); + }; + + /** + * A query for {@code ZoneOffset} returning null if not found. + */ + static final TemporalQuery OFFSET = (temporal) -> { + if (temporal.isSupported(OFFSET_SECONDS)) { + return ZoneOffset.ofTotalSeconds(temporal.get(OFFSET_SECONDS)); + } + return null; + }; + + /** + * A query for {@code LocalDate} returning null if not found. + */ + static final TemporalQuery LOCAL_DATE = (temporal) -> { + if (temporal.isSupported(EPOCH_DAY)) { + return LocalDate.ofEpochDay(temporal.getLong(EPOCH_DAY)); + } + return null; + }; + + /** + * A query for {@code LocalTime} returning null if not found. + */ + static final TemporalQuery LOCAL_TIME = (temporal) -> { + if (temporal.isSupported(NANO_OF_DAY)) { + return LocalTime.ofNanoOfDay(temporal.getLong(NANO_OF_DAY)); + } + return null; + }; + +} diff --git a/jdk/src/share/classes/java/time/temporal/TemporalQuery.java b/jdk/src/share/classes/java/time/temporal/TemporalQuery.java index 40b3943e740..599377847aa 100644 --- a/jdk/src/share/classes/java/time/temporal/TemporalQuery.java +++ b/jdk/src/share/classes/java/time/temporal/TemporalQuery.java @@ -62,6 +62,11 @@ package java.time.temporal; import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.chrono.Chronology; /** * Strategy for querying a temporal object. @@ -89,8 +94,7 @@ import java.time.DateTimeException; *

    * The most common implementations are method references, such as * {@code LocalDate::from} and {@code ZoneId::from}. - * Further implementations are on {@link Queries}. - * Queries may also be defined by applications. + * Additional common implementations are provided on this interface as static methods. * *

    Specification for implementors

    * This interface places no restrictions on the mutability of implementations, @@ -129,7 +133,7 @@ public interface TemporalQuery { *

    * The input temporal object may be in a calendar system other than ISO. * Implementations may choose to document compatibility with other calendar systems, - * or reject non-ISO temporal objects by {@link Queries#chronology() querying the chronology}. + * or reject non-ISO temporal objects by {@link TemporalQuery#chronology() querying the chronology}. *

    * This method may be called from multiple threads in parallel. * It must be thread-safe when invoked. @@ -141,4 +145,214 @@ public interface TemporalQuery { */ R queryFrom(TemporalAccessor temporal); + //----------------------------------------------------------------------- + // special constants should be used to extract information from a TemporalAccessor + // that cannot be derived in other ways + // Javadoc added here, so as to pretend they are more normal than they really are + + /** + * A strict query for the {@code ZoneId}. + *

    + * This queries a {@code TemporalAccessor} for the zone. + * The zone is only returned if the date-time conceptually contains a {@code ZoneId}. + * It will not be returned if the date-time only conceptually has an {@code ZoneOffset}. + * Thus a {@link java.time.ZonedDateTime} will return the result of {@code getZone()}, + * but an {@link java.time.OffsetDateTime} will return null. + *

    + * In most cases, applications should use {@link #zone()} as this query is too strict. + *

    + * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    + * {@code LocalDate} returns null
    + * {@code LocalTime} returns null
    + * {@code LocalDateTime} returns null
    + * {@code ZonedDateTime} returns the associated zone
    + * {@code OffsetTime} returns null
    + * {@code OffsetDateTime} returns null
    + * {@code ChronoLocalDate} returns null
    + * {@code ChronoLocalDateTime} returns null
    + * {@code ChronoZonedDateTime} returns the associated zone
    + * {@code Era} returns null
    + * {@code DayOfWeek} returns null
    + * {@code Month} returns null
    + * {@code Year} returns null
    + * {@code YearMonth} returns null
    + * {@code MonthDay} returns null
    + * {@code ZoneOffset} returns null
    + * {@code Instant} returns null
    + * + * @return a query that can obtain the zone ID of a temporal, not null + */ + static TemporalQuery zoneId() { + return TemporalQueries.ZONE_ID; + } + + /** + * A query for the {@code Chronology}. + *

    + * This queries a {@code TemporalAccessor} for the chronology. + * If the target {@code TemporalAccessor} represents a date, or part of a date, + * then it should return the chronology that the date is expressed in. + * As a result of this definition, objects only representing time, such as + * {@code LocalTime}, will return null. + *

    + * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    + * {@code LocalDate} returns {@code IsoChronology.INSTANCE}
    + * {@code LocalTime} returns null (does not represent a date)
    + * {@code LocalDateTime} returns {@code IsoChronology.INSTANCE}
    + * {@code ZonedDateTime} returns {@code IsoChronology.INSTANCE}
    + * {@code OffsetTime} returns null (does not represent a date)
    + * {@code OffsetDateTime} returns {@code IsoChronology.INSTANCE}
    + * {@code ChronoLocalDate} returns the associated chronology
    + * {@code ChronoLocalDateTime} returns the associated chronology
    + * {@code ChronoZonedDateTime} returns the associated chronology
    + * {@code Era} returns the associated chronology
    + * {@code DayOfWeek} returns null (shared across chronologies)
    + * {@code Month} returns {@code IsoChronology.INSTANCE}
    + * {@code Year} returns {@code IsoChronology.INSTANCE}
    + * {@code YearMonth} returns {@code IsoChronology.INSTANCE}
    + * {@code MonthDay} returns null {@code IsoChronology.INSTANCE}
    + * {@code ZoneOffset} returns null (does not represent a date)
    + * {@code Instant} returns null (does not represent a date)
    + *

    + * The method {@link java.time.chrono.Chronology#from(TemporalAccessor)} can be used as a + * {@code TemporalQuery} via a method reference, {@code Chronology::from}. + * That method is equivalent to this query, except that it throws an + * exception if a chronology cannot be obtained. + * + * @return a query that can obtain the chronology of a temporal, not null + */ + static TemporalQuery chronology() { + return TemporalQueries.CHRONO; + } + + /** + * A query for the smallest supported unit. + *

    + * This queries a {@code TemporalAccessor} for the time precision. + * If the target {@code TemporalAccessor} represents a consistent or complete date-time, + * date or time then this must return the smallest precision actually supported. + * Note that fields such as {@code NANO_OF_DAY} and {@code NANO_OF_SECOND} + * are defined to always return ignoring the precision, thus this is the only + * way to find the actual smallest supported unit. + * For example, were {@code GregorianCalendar} to implement {@code TemporalAccessor} + * it would return a precision of {@code MILLIS}. + *

    + * The result from JDK classes implementing {@code TemporalAccessor} is as follows:
    + * {@code LocalDate} returns {@code DAYS}
    + * {@code LocalTime} returns {@code NANOS}
    + * {@code LocalDateTime} returns {@code NANOS}
    + * {@code ZonedDateTime} returns {@code NANOS}
    + * {@code OffsetTime} returns {@code NANOS}
    + * {@code OffsetDateTime} returns {@code NANOS}
    + * {@code ChronoLocalDate} returns {@code DAYS}
    + * {@code ChronoLocalDateTime} returns {@code NANOS}
    + * {@code ChronoZonedDateTime} returns {@code NANOS}
    + * {@code Era} returns {@code ERAS}
    + * {@code DayOfWeek} returns {@code DAYS}
    + * {@code Month} returns {@code MONTHS}
    + * {@code Year} returns {@code YEARS}
    + * {@code YearMonth} returns {@code MONTHS}
    + * {@code MonthDay} returns null (does not represent a complete date or time)
    + * {@code ZoneOffset} returns null (does not represent a date or time)
    + * {@code Instant} returns {@code NANOS}
    + * + * @return a query that can obtain the precision of a temporal, not null + */ + static TemporalQuery precision() { + return TemporalQueries.PRECISION; + } + + //----------------------------------------------------------------------- + // non-special constants are standard queries that derive information from other information + /** + * A lenient query for the {@code ZoneId}, falling back to the {@code ZoneOffset}. + *

    + * This queries a {@code TemporalAccessor} for the zone. + * It first tries to obtain the zone, using {@link #zoneId()}. + * If that is not found it tries to obtain the {@link #offset()}. + * Thus a {@link java.time.ZonedDateTime} will return the result of {@code getZone()}, + * while an {@link java.time.OffsetDateTime} will return the result of {@code getOffset()}. + *

    + * In most cases, applications should use this query rather than {@code #zoneId()}. + *

    + * The method {@link ZoneId#from(TemporalAccessor)} can be used as a + * {@code TemporalQuery} via a method reference, {@code ZoneId::from}. + * That method is equivalent to this query, except that it throws an + * exception if a zone cannot be obtained. + * + * @return a query that can obtain the zone ID or offset of a temporal, not null + */ + static TemporalQuery zone() { + return TemporalQueries.ZONE; + } + + /** + * A query for {@code ZoneOffset} returning null if not found. + *

    + * This returns a {@code TemporalQuery} that can be used to query a temporal + * object for the offset. The query will return null if the temporal + * object cannot supply an offset. + *

    + * The query implementation examines the {@link ChronoField#OFFSET_SECONDS OFFSET_SECONDS} + * field and uses it to create a {@code ZoneOffset}. + *

    + * The method {@link java.time.ZoneOffset#from(TemporalAccessor)} can be used as a + * {@code TemporalQuery} via a method reference, {@code ZoneOffset::from}. + * This query and {@code ZoneOffset::from} will return the same result if the + * temporal object contains an offset. If the temporal object does not contain + * an offset, then the method reference will throw an exception, whereas this + * query will return null. + * + * @return a query that can obtain the offset of a temporal, not null + */ + static TemporalQuery offset() { + return TemporalQueries.OFFSET; + } + + /** + * A query for {@code LocalDate} returning null if not found. + *

    + * This returns a {@code TemporalQuery} that can be used to query a temporal + * object for the local date. The query will return null if the temporal + * object cannot supply a local date. + *

    + * The query implementation examines the {@link ChronoField#EPOCH_DAY EPOCH_DAY} + * field and uses it to create a {@code LocalDate}. + *

    + * The method {@link ZoneOffset#from(TemporalAccessor)} can be used as a + * {@code TemporalQuery} via a method reference, {@code LocalDate::from}. + * This query and {@code LocalDate::from} will return the same result if the + * temporal object contains a date. If the temporal object does not contain + * a date, then the method reference will throw an exception, whereas this + * query will return null. + * + * @return a query that can obtain the date of a temporal, not null + */ + static TemporalQuery localDate() { + return TemporalQueries.LOCAL_DATE; + } + + /** + * A query for {@code LocalTime} returning null if not found. + *

    + * This returns a {@code TemporalQuery} that can be used to query a temporal + * object for the local time. The query will return null if the temporal + * object cannot supply a local time. + *

    + * The query implementation examines the {@link ChronoField#NANO_OF_DAY NANO_OF_DAY} + * field and uses it to create a {@code LocalTime}. + *

    + * The method {@link ZoneOffset#from(TemporalAccessor)} can be used as a + * {@code TemporalQuery} via a method reference, {@code LocalTime::from}. + * This query and {@code LocalTime::from} will return the same result if the + * temporal object contains a time. If the temporal object does not contain + * a time, then the method reference will throw an exception, whereas this + * query will return null. + * + * @return a query that can obtain the time of a temporal, not null + */ + static TemporalQuery localTime() { + return TemporalQueries.LOCAL_TIME; + } + } diff --git a/jdk/src/share/classes/java/time/temporal/TemporalUnit.java b/jdk/src/share/classes/java/time/temporal/TemporalUnit.java index 2f117fc2f16..86e3ba86137 100644 --- a/jdk/src/share/classes/java/time/temporal/TemporalUnit.java +++ b/jdk/src/share/classes/java/time/temporal/TemporalUnit.java @@ -143,10 +143,12 @@ public interface TemporalUnit { * @param temporal the temporal object to check, not null * @return true if the unit is supported */ - public default boolean isSupportedBy(Temporal temporal) { + default boolean isSupportedBy(Temporal temporal) { try { temporal.plus(1, this); return true; + } catch (UnsupportedTemporalTypeException ex) { + return false; } catch (RuntimeException ex) { try { temporal.plus(-1, this); @@ -178,7 +180,7 @@ public interface TemporalUnit { *

    * Implementations should perform any queries or calculations using the units * available in {@link ChronoUnit} or the fields available in {@link ChronoField}. - * If the unit is not supported a {@code DateTimeException} must be thrown. + * If the unit is not supported an {@code UnsupportedTemporalTypeException} must be thrown. *

    * Implementations must not alter the specified temporal object. * Instead, an adjusted copy of the original must be returned. @@ -189,6 +191,7 @@ public interface TemporalUnit { * @param amount the amount of this unit to add, positive or negative * @return the adjusted temporal object, not null * @throws DateTimeException if the period cannot be added + * @throws UnsupportedTemporalTypeException if the unit is not supported by the temporal */ R addTo(R temporal, long amount); @@ -214,8 +217,8 @@ public interface TemporalUnit { * The second is to use {@link Temporal#periodUntil(Temporal, TemporalUnit)}: *

          *   // these two lines are equivalent
    -     *   temporal = thisUnit.between(start, end);
    -     *   temporal = start.periodUntil(end, thisUnit);
    +     *   between = thisUnit.between(start, end);
    +     *   between = start.periodUntil(end, thisUnit);
          * 
    * The choice should be made based on which makes the code more readable. *

    @@ -229,14 +232,15 @@ public interface TemporalUnit { *

    * Implementations should perform any queries or calculations using the units * available in {@link ChronoUnit} or the fields available in {@link ChronoField}. - * If the unit is not supported a {@code DateTimeException} must be thrown. + * If the unit is not supported an {@code UnsupportedTemporalTypeException} must be thrown. * Implementations must not alter the specified temporal objects. * * @param temporal1 the base temporal object, not null * @param temporal2 the other temporal object, not null - * @return the period between datetime1 and datetime2 in terms of this unit; - * positive if datetime2 is later than datetime1, negative if earlier + * @return the period between temporal1 and temporal2 in terms of this unit; + * positive if temporal2 is later than temporal1, negative if earlier * @throws DateTimeException if the period cannot be calculated + * @throws UnsupportedTemporalTypeException if the unit is not supported by the temporal * @throws ArithmeticException if numeric overflow occurs */ long between(Temporal temporal1, Temporal temporal2); diff --git a/jdk/src/share/classes/java/time/temporal/UnsupportedTemporalTypeException.java b/jdk/src/share/classes/java/time/temporal/UnsupportedTemporalTypeException.java new file mode 100644 index 00000000000..4b47b0afcf1 --- /dev/null +++ b/jdk/src/share/classes/java/time/temporal/UnsupportedTemporalTypeException.java @@ -0,0 +1,101 @@ +/* + * 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. 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package java.time.temporal; + +import java.time.DateTimeException; + +/** + * UnsupportedTemporalTypeException indicates that a ChronoField or ChronoUnit is + * not supported for a Temporal class. + * + *

    Specification for implementors

    + * This class is intended for use in a single thread. + * + * @since 1.8 + */ +public class UnsupportedTemporalTypeException extends DateTimeException { + + /** + * Serialization version. + */ + private static final long serialVersionUID = -6158898438688206006L; + + /** + * Constructs a new UnsupportedTemporalTypeException with the specified message. + * + * @param message the message to use for this exception, may be null + */ + public UnsupportedTemporalTypeException(String message) { + super(message); + } + + /** + * Constructs a new UnsupportedTemporalTypeException with the specified message and cause. + * + * @param message the message to use for this exception, may be null + * @param cause the cause of the exception, may be null + */ + public UnsupportedTemporalTypeException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/jdk/src/share/classes/java/time/temporal/ValueRange.java b/jdk/src/share/classes/java/time/temporal/ValueRange.java index cd47f256d4d..d6e3a525c70 100644 --- a/jdk/src/share/classes/java/time/temporal/ValueRange.java +++ b/jdk/src/share/classes/java/time/temporal/ValueRange.java @@ -305,11 +305,7 @@ public final class ValueRange implements Serializable { */ public long checkValidValue(long value, TemporalField field) { if (isValidValue(value) == false) { - if (field != null) { - throw new DateTimeException("Invalid value for " + field.getName() + " (valid values " + this + "): " + value); - } else { - throw new DateTimeException("Invalid value (valid values " + this + "): " + value); - } + throw new DateTimeException(genInvalidFieldMessage(field, value)); } return value; } @@ -328,11 +324,19 @@ public final class ValueRange implements Serializable { */ public int checkValidIntValue(long value, TemporalField field) { if (isValidIntValue(value) == false) { - throw new DateTimeException("Invalid int value for " + field.getName() + ": " + value); + throw new DateTimeException(genInvalidFieldMessage(field, value)); } return (int) value; } + private String genInvalidFieldMessage(TemporalField field, long value) { + if (field != null) { + return "Invalid value for " + field.getName() + " (valid values " + this + "): " + value; + } else { + return "Invalid value (valid values " + this + "): " + value; + } + } + //----------------------------------------------------------------------- /** * Checks if this range is equal to another range. diff --git a/jdk/src/share/classes/java/time/temporal/WeekFields.java b/jdk/src/share/classes/java/time/temporal/WeekFields.java index b9d7c15f30e..29a1e1bf8fb 100644 --- a/jdk/src/share/classes/java/time/temporal/WeekFields.java +++ b/jdk/src/share/classes/java/time/temporal/WeekFields.java @@ -68,6 +68,7 @@ import static java.time.temporal.ChronoField.EPOCH_DAY; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.FOREVER; import static java.time.temporal.ChronoUnit.MONTHS; import static java.time.temporal.ChronoUnit.WEEKS; import static java.time.temporal.ChronoUnit.YEARS; @@ -77,14 +78,18 @@ import java.io.Serializable; import java.time.DayOfWeek; import java.time.chrono.ChronoLocalDate; import java.time.chrono.Chronology; +import java.time.format.ResolverStyle; import java.util.Collections; import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.ResourceBundle; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import sun.util.locale.provider.CalendarDataUtility; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; /** * Localized definitions of the day-of-week, week-of-month and week-of-year fields. @@ -93,8 +98,9 @@ import sun.util.locale.provider.CalendarDataUtility; * other aspects of a week. This class represents the definition of the week, for the * purpose of providing {@link TemporalField} instances. *

    - * WeekFields provides three fields, - * {@link #dayOfWeek()}, {@link #weekOfMonth()}, and {@link #weekOfYear()} + * WeekFields provides five fields, + * {@link #dayOfWeek()}, {@link #weekOfMonth()}, {@link #weekOfYear()}, + * {@link #weekOfWeekBasedYear()}, and {@link #weekBasedYear()} * that provide access to the values from any {@linkplain Temporal temporal object}. *

    * The computations for day-of-week, week-of-month, and week-of-year are based @@ -110,7 +116,7 @@ import sun.util.locale.provider.CalendarDataUtility; *

  • The first day-of-week. * For example, the ISO-8601 standard considers Monday to be the first day-of-week. *
  • The minimal number of days in the first week. - * For example, the ISO-08601 standard counts the first week as needing at least 4 days. + * For example, the ISO-8601 standard counts the first week as needing at least 4 days. *

    * Together these two values allow a year or month to be divided into weeks. *

    @@ -134,14 +140,37 @@ import sun.util.locale.provider.CalendarDataUtility; * 2009-01-05Monday * Week 2 of January 2009Week 1 of January 2009 * - *

    + * *

    Week of Year

    * One field is used: week-of-year. * The calculation ensures that weeks never overlap a year boundary. * The year is divided into periods where each period starts on the defined first day-of-week. * The earliest period is referred to as week 0 if it has less than the minimal number of days * and week 1 if it has at least the minimal number of days. - *

    + * + *

    Week Based Year

    + * Two fields are used for week-based-year, one for the + * {@link #weekOfWeekBasedYear() week-of-week-based-year} and one for + * {@link #weekBasedYear() week-based-year}. In a week-based-year, each week + * belongs to only a single year. Week 1 of a year is the first week that + * starts on the first day-of-week and has at least the minimum number of days. + * The first and last weeks of a year may contain days from the + * previous calendar year or next calendar year respectively. + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    Examples of WeekFields for week-based-year
    DateDay-of-weekFirst day: Monday
    Minimal days: 4
    First day: Monday
    Minimal days: 5
    2008-12-31WednesdayWeek 1 of 2009Week 53 of 2008
    2009-01-01ThursdayWeek 1 of 2009Week 53 of 2008
    2009-01-04SundayWeek 1 of 2009Week 53 of 2008
    2009-01-05MondayWeek 2 of 2009Week 1 of 2009
    + *

    Specification for implementors

    * This class is immutable and thread-safe. * * @since 1.8 @@ -171,18 +200,40 @@ public final class WeekFields implements Serializable { * Note that the first week may start in the previous calendar year. * Note also that the first few days of a calendar year may be in the * week-based-year corresponding to the previous calendar year. + *

    + * This field is an immutable and thread-safe singleton. */ public static final WeekFields ISO = new WeekFields(DayOfWeek.MONDAY, 4); /** - * The common definition of a week that starts on Sunday. + * The common definition of a week that starts on Sunday and the first week + * has a minimum of 1 day. *

    * Defined as starting on Sunday and with a minimum of 1 day in the month. * This week definition is in use in the US and other European countries. - * + *

    + * This field is an immutable and thread-safe singleton. */ public static final WeekFields SUNDAY_START = WeekFields.of(DayOfWeek.SUNDAY, 1); + /** + * The unit that represents week-based-years for the purpose of addition and subtraction. + *

    + * This allows a number of week-based-years to be added to, or subtracted from, a date. + * The unit is equal to either 52 or 53 weeks. + * The estimated duration of a week-based-year is the same as that of a standard ISO + * year at {@code 365.2425 Days}. + *

    + * The rules for addition add the number of week-based-years to the existing value + * for the week-based-year field retaining the week-of-week-based-year + * and day-of-week, unless the week number it too large for the target year. + * In that case, the week is set to the last week of the year + * with the same day-of-week. + *

    + * This field is an immutable and thread-safe singleton. + */ + public static final TemporalUnit WEEK_BASED_YEARS = IsoFields.WEEK_BASED_YEARS; + /** * Serialization version. */ @@ -212,6 +263,24 @@ public final class WeekFields implements Serializable { */ private transient final TemporalField weekOfYear = ComputedDayOfField.ofWeekOfYearField(this); + /** + * The field that represents the week-of-week-based-year. + *

    + * This field allows the week of the week-based-year value to be queried and set. + *

    + * This unit is an immutable and thread-safe singleton. + */ + private transient final TemporalField weekOfWeekBasedYear = ComputedDayOfField.ofWeekOfWeekBasedYearField(this); + + /** + * The field that represents the week-based-year. + *

    + * This field allows the week-based-year value to be queried and set. + *

    + * This unit is an immutable and thread-safe singleton. + */ + private transient final TemporalField weekBasedYear = ComputedDayOfField.ofWeekBasedYearField(this); + /** * Obtains an instance of {@code WeekFields} appropriate for a locale. *

    @@ -341,7 +410,7 @@ public final class WeekFields implements Serializable { * Returns a field to access the week of month, * computed based on this WeekFields. *

    - * This represents concept of the count of weeks within the month where weeks + * This represents the concept of the count of weeks within the month where weeks * start on a fixed day-of-week, such as Monday. * This field is typically used with {@link WeekFields#dayOfWeek()}. *

    @@ -367,12 +436,12 @@ public final class WeekFields implements Serializable { * Returns a field to access the week of year, * computed based on this WeekFields. *

    - * This represents concept of the count of weeks within the year where weeks + * This represents the concept of the count of weeks within the year where weeks * start on a fixed day-of-week, such as Monday. * This field is typically used with {@link WeekFields#dayOfWeek()}. *

    * Week one(1) is the week starting on the {@link WeekFields#getFirstDayOfWeek} - * where there are at least {@link WeekFields#getMinimalDaysInFirstWeek()} days in the month. + * where there are at least {@link WeekFields#getMinimalDaysInFirstWeek()} days in the year. * Thus, week one may start up to {@code minDays} days before the start of the year. * If the first week starts after the start of the year then the period before is week zero (0). *

    @@ -390,7 +459,59 @@ public final class WeekFields implements Serializable { } /** - * Checks if these rules are equal to the specified rules. + * Returns a field to access the week of a week-based-year, + * computed based on this WeekFields. + *

    + * This represents the concept of the count of weeks within the year where weeks + * start on a fixed day-of-week, such as Monday and each week belongs to exactly one year. + * This field is typically used with {@link WeekFields#dayOfWeek()} and + * {@link WeekFields#weekBasedYear()}. + *

    + * Week one(1) is the week starting on the {@link WeekFields#getFirstDayOfWeek} + * where there are at least {@link WeekFields#getMinimalDaysInFirstWeek()} days in the year. + * If the first week starts after the start of the year then the period before + * is in the last week of the previous year. + *

    + * For example:
    + * - if the 1st day of the year is a Monday, week one starts on the 1st
    + * - if the 2nd day of the year is a Monday, week one starts on the 2nd and + * the 1st is in the last week of the previous year
    + * - if the 4th day of the year is a Monday, week one starts on the 4th and + * the 1st to 3rd is in the last week of the previous year
    + * - if the 5th day of the year is a Monday, week two starts on the 5th and + * the 1st to 4th is in week one
    + *

    + * This field can be used with any calendar system. + * @return a TemporalField to access the week of week-based-year, not null + */ + public TemporalField weekOfWeekBasedYear() { + return weekOfWeekBasedYear; + } + + /** + * Returns a field to access the year of a week-based-year, + * computed based on this WeekFields. + *

    + * This represents the concept of the year where weeks start on a fixed day-of-week, + * such as Monday and each week belongs to exactly one year. + * This field is typically used with {@link WeekFields#dayOfWeek()} and + * {@link WeekFields#weekOfWeekBasedYear()}. + *

    + * Week one(1) is the week starting on the {@link WeekFields#getFirstDayOfWeek} + * where there are at least {@link WeekFields#getMinimalDaysInFirstWeek()} days in the year. + * Thus, week one may start before the start of the year. + * If the first week starts after the start of the year then the period before + * is in the last week of the previous year. + *

    + * This field can be used with any calendar system. + * @return a TemporalField to access the year of week-based-year, not null + */ + public TemporalField weekBasedYear() { + return weekBasedYear; + } + + /** + * Checks if this WeekFields is equal to the specified object. *

    * The comparison is based on the entire state of the rules, which is * the first day-of-week and minimal days. @@ -469,6 +590,49 @@ public final class WeekFields implements Serializable { static ComputedDayOfField ofWeekOfYearField(WeekFields weekDef) { return new ComputedDayOfField("WeekOfYear", weekDef, WEEKS, YEARS, WEEK_OF_YEAR_RANGE); } + + /** + * Returns a field to access the week of week-based-year, + * computed based on a WeekFields. + * @see WeekFields#weekOfWeekBasedYear() + */ + static ComputedDayOfField ofWeekOfWeekBasedYearField(WeekFields weekDef) { + return new ComputedDayOfField("WeekOfWeekBasedYear", weekDef, WEEKS, IsoFields.WEEK_BASED_YEARS, WEEK_OF_YEAR_RANGE); + } + + /** + * Returns a field to access the week of week-based-year, + * computed based on a WeekFields. + * @see WeekFields#weekBasedYear() + */ + static ComputedDayOfField ofWeekBasedYearField(WeekFields weekDef) { + return new ComputedDayOfField("WeekBasedYear", weekDef, IsoFields.WEEK_BASED_YEARS, FOREVER, ChronoField.YEAR.range()); + } + + /** + * Return a new week-based-year date of the Chronology, year, week-of-year, + * and dow of week. + * @param chrono The chronology of the new date + * @param yowby the year of the week-based-year + * @param wowby the week of the week-based-year + * @param dow the day of the week + * @return a ChronoLocalDate for the requested year, week of year, and day of week + */ + private ChronoLocalDate ofWeekBasedYear(Chronology chrono, + int yowby, int wowby, int dow) { + ChronoLocalDate date = chrono.date(yowby, 1, 1); + int ldow = localizedDayOfWeek(date); + int offset = startOfWeekOffset(1, ldow); + + // Clamp the week of year to keep it in the same year + int yearLen = date.lengthOfYear(); + int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek()); + wowby = Math.min(wowby, newYearWeek - 1); + + int days = -offset + (dow - 1) + (wowby - 1) * 7; + return date.plus(days, DAYS); + } + private final String name; private final WeekFields weekDef; private final TemporalUnit baseUnit; @@ -489,44 +653,109 @@ public final class WeekFields implements Serializable { @Override public long getFrom(TemporalAccessor temporal) { - // Offset the ISO DOW by the start of this week - int sow = weekDef.getFirstDayOfWeek().getValue(); - int dow = localizedDayOfWeek(temporal, sow); - if (rangeUnit == WEEKS) { // day-of-week - return dow; + return localizedDayOfWeek(temporal); } else if (rangeUnit == MONTHS) { // week-of-month - return localizedWeekOfMonth(temporal, dow); + return localizedWeekOfMonth(temporal); } else if (rangeUnit == YEARS) { // week-of-year - return localizedWeekOfYear(temporal, dow); + return localizedWeekOfYear(temporal); + } else if (rangeUnit == WEEK_BASED_YEARS) { + return localizedWeekOfWeekBasedYear(temporal); + } else if (rangeUnit == FOREVER) { + return localizedWeekBasedYear(temporal); } else { - throw new IllegalStateException("unreachable"); + throw new IllegalStateException("unreachable, rangeUnit: " + rangeUnit + ", this: " + this); } } - private int localizedDayOfWeek(TemporalAccessor temporal, int sow) { + private int localizedDayOfWeek(TemporalAccessor temporal) { + int sow = weekDef.getFirstDayOfWeek().getValue(); int isoDow = temporal.get(DAY_OF_WEEK); return Math.floorMod(isoDow - sow, 7) + 1; } - private long localizedWeekOfMonth(TemporalAccessor temporal, int dow) { + private long localizedWeekOfMonth(TemporalAccessor temporal) { + int dow = localizedDayOfWeek(temporal); int dom = temporal.get(DAY_OF_MONTH); int offset = startOfWeekOffset(dom, dow); return computeWeek(offset, dom); } - private long localizedWeekOfYear(TemporalAccessor temporal, int dow) { + private long localizedWeekOfYear(TemporalAccessor temporal) { + int dow = localizedDayOfWeek(temporal); int doy = temporal.get(DAY_OF_YEAR); int offset = startOfWeekOffset(doy, dow); return computeWeek(offset, doy); } + /** + * Returns the year of week-based-year for the temporal. + * The year can be the previous year, the current year, or the next year. + * @param temporal a date of any chronology, not null + * @return the year of week-based-year for the date + */ + private int localizedWeekBasedYear(TemporalAccessor temporal) { + int dow = localizedDayOfWeek(temporal); + int year = temporal.get(YEAR); + int doy = temporal.get(DAY_OF_YEAR); + int offset = startOfWeekOffset(doy, dow); + int week = computeWeek(offset, doy); + if (week == 0) { + // Day is in end of week of previous year; return the previous year + return year - 1; + } else { + // If getting close to end of year, use higher precision logic + // Check if date of year is in partial week associated with next year + ValueRange dayRange = temporal.range(DAY_OF_YEAR); + int yearLen = (int)dayRange.getMaximum(); + int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek()); + if (week >= newYearWeek) { + return year + 1; + } + } + return year; + } + + /** + * Returns the week of week-based-year for the temporal. + * The week can be part of the previous year, the current year, + * or the next year depending on the week start and minimum number + * of days. + * @param temporal a date of any chronology + * @return the week of the year + * @see #localizedWeekBasedYear(java.time.temporal.TemporalAccessor) + */ + private int localizedWeekOfWeekBasedYear(TemporalAccessor temporal) { + int dow = localizedDayOfWeek(temporal); + int doy = temporal.get(DAY_OF_YEAR); + int offset = startOfWeekOffset(doy, dow); + int week = computeWeek(offset, doy); + if (week == 0) { + // Day is in end of week of previous year + // Recompute from the last day of the previous year + ChronoLocalDate date = Chronology.from(temporal).date(temporal); + date = date.minus(doy, DAYS); // Back down into previous year + return localizedWeekOfWeekBasedYear(date); + } else if (week > 50) { + // If getting close to end of year, use higher precision logic + // Check if date of year is in partial week associated with next year + ValueRange dayRange = temporal.range(DAY_OF_YEAR); + int yearLen = (int)dayRange.getMaximum(); + int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek()); + if (week >= newYearWeek) { + // Overlaps with week of following year; reduce to week in following year + week = week - newYearWeek + 1; + } + } + return week; + } + /** * Returns an offset to align week start with a day of month or day of year. * - * @param day the day; 1 through infinity - * @param dow the day of the week of that day; 1 through 7 - * @return an offset in days to align a day with the start of the first 'full' week + * @param day the day; 1 through infinity + * @param dow the day of the week of that day; 1 through 7 + * @return an offset in days to align a day with the start of the first 'full' week */ private int startOfWeekOffset(int day, int dow) { // offset of first day corresponding to the day of week in first 7 days (zero origin) @@ -560,54 +789,81 @@ public final class WeekFields implements Serializable { if (newVal == currentVal) { return temporal; } - // Compute the difference and add that using the base using of the field - return (R) temporal.plus(newVal - currentVal, baseUnit); + + if (rangeUnit == FOREVER) { // replace year of WeekBasedYear + // Create a new date object with the same chronology, + // the desired year and the same week and dow. + int idow = temporal.get(weekDef.dayOfWeek); + int wowby = temporal.get(weekDef.weekOfWeekBasedYear); + return (R) ofWeekBasedYear(Chronology.from(temporal), (int)newValue, wowby, idow); + } else { + // Compute the difference and add that using the base unit of the field + return (R) temporal.plus(newVal - currentVal, baseUnit); + } } @Override - public Map resolve(TemporalAccessor temporal, long value) { + public Map resolve(TemporalAccessor temporal, long value, ResolverStyle resolverStyle) { int newValue = range.checkValidIntValue(value, this); int sow = weekDef.getFirstDayOfWeek().getValue(); if (rangeUnit == WEEKS) { // day-of-week int isoDow = Math.floorMod((sow - 1) + (newValue - 1), 7) + 1; return Collections.singletonMap(DAY_OF_WEEK, (long) isoDow); } - if ((temporal.isSupported(YEAR) && temporal.isSupported(DAY_OF_WEEK)) == false) { + if (temporal.isSupported(DAY_OF_WEEK) == false) { return null; } - int dow = localizedDayOfWeek(temporal, sow); - int year = temporal.get(YEAR); Chronology chrono = Chronology.from(temporal); // defaults to ISO - if (rangeUnit == MONTHS) { // week-of-month - if (temporal.isSupported(MONTH_OF_YEAR) == false) { - return null; + int dow = localizedDayOfWeek(temporal); + if (temporal.isSupported(YEAR)) { + int year = temporal.get(YEAR); + if (rangeUnit == MONTHS) { // week-of-month + if (temporal.isSupported(MONTH_OF_YEAR) == false) { + return null; + } + int month = temporal.get(ChronoField.MONTH_OF_YEAR); + @SuppressWarnings("rawtypes") + ChronoLocalDate date = chrono.date(year, month, 1); + int dateDow = localizedDayOfWeek(date); + long weeks = newValue - localizedWeekOfMonth(date); + int days = dow - dateDow; + date = date.plus(weeks * 7 + days, DAYS); + Map result = new HashMap<>(4, 1.0f); + result.put(EPOCH_DAY, date.toEpochDay()); + result.put(YEAR, null); + result.put(MONTH_OF_YEAR, null); + result.put(DAY_OF_WEEK, null); + return result; + } else if (rangeUnit == YEARS) { // week-of-year + @SuppressWarnings("rawtypes") + ChronoLocalDate date = chrono.date(year, 1, 1); + int dateDow = localizedDayOfWeek(date); + long weeks = newValue - localizedWeekOfYear(date); + int days = dow - dateDow; + date = date.plus(weeks * 7 + days, DAYS); + Map result = new HashMap<>(4, 1.0f); + result.put(EPOCH_DAY, date.toEpochDay()); + result.put(YEAR, null); + result.put(DAY_OF_WEEK, null); + return result; + } + } else if (rangeUnit == WEEK_BASED_YEARS || rangeUnit == FOREVER) { + if (temporal.isSupported(weekDef.weekBasedYear) && + temporal.isSupported(weekDef.weekOfWeekBasedYear)) { + // week-of-week-based-year and year-of-week-based-year + int yowby = temporal.get(weekDef.weekBasedYear); + int wowby = temporal.get(weekDef.weekOfWeekBasedYear); + ChronoLocalDate date = ofWeekBasedYear(Chronology.from(temporal), yowby, wowby, dow); + + Map result = new HashMap<>(4, 1.0f); + result.put(EPOCH_DAY, date.toEpochDay()); + result.put(DAY_OF_WEEK, null); + result.put(weekDef.weekOfWeekBasedYear, null); + result.put(weekDef.weekBasedYear, null); + return result; } - int month = temporal.get(ChronoField.MONTH_OF_YEAR); - ChronoLocalDate date = chrono.date(year, month, 1); - int dateDow = localizedDayOfWeek(date, sow); - long weeks = newValue - localizedWeekOfMonth(date, dateDow); - int days = dow - dateDow; - date = date.plus(weeks * 7 + days, DAYS); - Map result = new HashMap<>(4, 1.0f); - result.put(EPOCH_DAY, date.toEpochDay()); - result.put(YEAR, null); - result.put(MONTH_OF_YEAR, null); - result.put(DAY_OF_WEEK, null); - return result; - } else if (rangeUnit == YEARS) { // week-of-year - ChronoLocalDate date = chrono.date(year, 1, 1); - int dateDow = localizedDayOfWeek(date, sow); - long weeks = newValue - localizedWeekOfYear(date, dateDow); - int days = dow - dateDow; - date = date.plus(weeks * 7 + days, DAYS); - Map result = new HashMap<>(4, 1.0f); - result.put(EPOCH_DAY, date.toEpochDay()); - result.put(YEAR, null); - result.put(DAY_OF_WEEK, null); - return result; - } else { - throw new IllegalStateException("unreachable"); } + return null; } //----------------------------------------------------------------------- @@ -616,6 +872,18 @@ public final class WeekFields implements Serializable { return name; } + @Override + public String getDisplayName(Locale locale) { + Objects.requireNonNull(locale, "locale"); + if (rangeUnit == YEARS) { // only have values for week-of-year + LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() + .getLocaleResources(locale); + ResourceBundle rb = lr.getJavaTimeFormatData(); + return rb.containsKey("field.week") ? rb.getString("field.week") : getName(); + } + return getName(); + } + @Override public TemporalUnit getBaseUnit() { return baseUnit; @@ -626,6 +894,11 @@ public final class WeekFields implements Serializable { return rangeUnit; } + @Override + public boolean isDateBased() { + return true; + } + @Override public ValueRange range() { return range; @@ -641,6 +914,10 @@ public final class WeekFields implements Serializable { return temporal.isSupported(DAY_OF_MONTH); } else if (rangeUnit == YEARS) { // week-of-year return temporal.isSupported(DAY_OF_YEAR); + } else if (rangeUnit == WEEK_BASED_YEARS) { + return temporal.isSupported(DAY_OF_YEAR); + } else if (rangeUnit == FOREVER) { + return temporal.isSupported(YEAR); } } return false; @@ -650,27 +927,68 @@ public final class WeekFields implements Serializable { public ValueRange rangeRefinedBy(TemporalAccessor temporal) { if (rangeUnit == ChronoUnit.WEEKS) { // day-of-week return range; - } - - TemporalField field = null; - if (rangeUnit == MONTHS) { // week-of-month - field = DAY_OF_MONTH; + } else if (rangeUnit == MONTHS) { // week-of-month + return rangeByWeek(temporal, DAY_OF_MONTH); } else if (rangeUnit == YEARS) { // week-of-year - field = DAY_OF_YEAR; + return rangeByWeek(temporal, DAY_OF_YEAR); + } else if (rangeUnit == WEEK_BASED_YEARS) { + return rangeWeekOfWeekBasedYear(temporal); + } else if (rangeUnit == FOREVER) { + return YEAR.range(); } else { - throw new IllegalStateException("unreachable"); + throw new IllegalStateException("unreachable, rangeUnit: " + rangeUnit + ", this: " + this); } + } - // Offset the ISO DOW by the start of this week - int sow = weekDef.getFirstDayOfWeek().getValue(); - int dow = localizedDayOfWeek(temporal, sow); - + /** + * Map the field range to a week range + * @param temporal the temporal + * @param field the field to get the range of + * @return the ValueRange with the range adjusted to weeks. + */ + private ValueRange rangeByWeek(TemporalAccessor temporal, TemporalField field) { + int dow = localizedDayOfWeek(temporal); int offset = startOfWeekOffset(temporal.get(field), dow); ValueRange fieldRange = temporal.range(field); return ValueRange.of(computeWeek(offset, (int) fieldRange.getMinimum()), computeWeek(offset, (int) fieldRange.getMaximum())); } + /** + * Map the field range to a week range of a week year. + * @param temporal the temporal + * @param field the field to get the range of + * @return the ValueRange with the range adjusted to weeks. + */ + private ValueRange rangeWeekOfWeekBasedYear(TemporalAccessor temporal) { + if (!temporal.isSupported(DAY_OF_YEAR)) { + return WEEK_OF_YEAR_RANGE; + } + int dow = localizedDayOfWeek(temporal); + int doy = temporal.get(DAY_OF_YEAR); + int offset = startOfWeekOffset(doy, dow); + int week = computeWeek(offset, doy); + if (week == 0) { + // Day is in end of week of previous year + // Recompute from the last day of the previous year + ChronoLocalDate date = Chronology.from(temporal).date(temporal); + date = date.minus(doy + 7, DAYS); // Back down into previous year + return rangeWeekOfWeekBasedYear(date); + } + // Check if day of year is in partial week associated with next year + ValueRange dayRange = temporal.range(DAY_OF_YEAR); + int yearLen = (int)dayRange.getMaximum(); + int newYearWeek = computeWeek(offset, yearLen + weekDef.getMinimalDaysInFirstWeek()); + + if (week >= newYearWeek) { + // Overlaps with weeks of following year; recompute from a week in following year + ChronoLocalDate date = Chronology.from(temporal).date(temporal); + date = date.plus(yearLen - doy + 1 + 7, ChronoUnit.DAYS); + return rangeWeekOfWeekBasedYear(date); + } + return ValueRange.of(1, newYearWeek-1); + } + //----------------------------------------------------------------------- @Override public String toString() { diff --git a/jdk/src/share/classes/java/time/temporal/package-info.java b/jdk/src/share/classes/java/time/temporal/package-info.java index d769120f4fd..fe4d3f891b6 100644 --- a/jdk/src/share/classes/java/time/temporal/package-info.java +++ b/jdk/src/share/classes/java/time/temporal/package-info.java @@ -112,9 +112,9 @@ * such as the "last day of the month", or "next Wednesday". * These are modeled as functions that adjust a base date-time. * The functions implement {@link java.time.temporal.TemporalAdjuster} and operate on {@code Temporal}. - * A set of common functions are provided in {@link java.time.temporal.Adjusters}. + * A set of common functions are provided in {@code TemporalAdjuster}. * For example, to find the first occurrence of a day-of-week after a given date, use - * {@link java.time.temporal.Adjusters#next(DayOfWeek)}, such as + * {@link java.time.temporal.TemporalAdjuster#next(DayOfWeek)}, such as * {@code date.with(next(MONDAY))}. * Applications can also define adjusters by implementing {@code TemporalAdjuster}. *

    @@ -127,7 +127,7 @@ * The most common implementations of the query interface are method references. * The {@code from(TemporalAccessor)} methods on major classes can all be used, such as * {@code LocalDate::from} or {@code Month::from}. - * Further implementations are provided in {@link java.time.temporal.Queries}. + * Further implementations are provided in {@code TemporalQuery} as static methods. * Applications can also define queries by implementing {@code TemporalQuery}. *

    * diff --git a/jdk/src/share/classes/java/time/zone/TzdbZoneRulesProvider.java b/jdk/src/share/classes/java/time/zone/TzdbZoneRulesProvider.java index 22f6ffddd24..b40fe987bab 100644 --- a/jdk/src/share/classes/java/time/zone/TzdbZoneRulesProvider.java +++ b/jdk/src/share/classes/java/time/zone/TzdbZoneRulesProvider.java @@ -64,6 +64,7 @@ package java.time.zone; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.StreamCorruptedException; import java.util.Arrays; @@ -75,7 +76,6 @@ import java.util.Objects; import java.util.Set; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; -import java.util.zip.ZipFile; /** * Loads time-zone rules for 'TZDB'. @@ -106,10 +106,8 @@ final class TzdbZoneRulesProvider extends ZoneRulesProvider { public TzdbZoneRulesProvider() { try { String libDir = System.getProperty("java.home") + File.separator + "lib"; - File tzdbJar = new File(libDir, "tzdb.jar"); - try (ZipFile zf = new ZipFile(tzdbJar); - DataInputStream dis = new DataInputStream( - zf.getInputStream(zf.getEntry("TZDB.dat")))) { + try (DataInputStream dis = new DataInputStream( + new FileInputStream(new File(libDir, "tzdb.dat")))) { load(dis); } } catch (Exception ex) { diff --git a/jdk/src/share/classes/java/time/zone/ZoneOffsetTransition.java b/jdk/src/share/classes/java/time/zone/ZoneOffsetTransition.java index 6d080aba27d..1b5810b0594 100644 --- a/jdk/src/share/classes/java/time/zone/ZoneOffsetTransition.java +++ b/jdk/src/share/classes/java/time/zone/ZoneOffsetTransition.java @@ -321,7 +321,7 @@ public final class ZoneOffsetTransition } /** - * Does this transition represent a gap in the local time-line. + * Does this transition represent an overlap in the local time-line. *

    * Overlaps occur where there are local date-times that exist twice. * An example would be when the offset changes from {@code +02:00} to {@code +01:00}. diff --git a/jdk/src/share/classes/java/time/zone/ZoneOffsetTransitionRule.java b/jdk/src/share/classes/java/time/zone/ZoneOffsetTransitionRule.java index 5275d18417b..bb1b79fb332 100644 --- a/jdk/src/share/classes/java/time/zone/ZoneOffsetTransitionRule.java +++ b/jdk/src/share/classes/java/time/zone/ZoneOffsetTransitionRule.java @@ -61,8 +61,8 @@ */ package java.time.zone; -import static java.time.temporal.Adjusters.nextOrSame; -import static java.time.temporal.Adjusters.previousOrSame; +import static java.time.temporal.TemporalAdjuster.nextOrSame; +import static java.time.temporal.TemporalAdjuster.previousOrSame; import java.io.DataInput; import java.io.DataOutput; diff --git a/jdk/src/share/classes/java/time/zone/ZoneRulesProvider.java b/jdk/src/share/classes/java/time/zone/ZoneRulesProvider.java index d3e906d3937..5c88e3ea0cb 100644 --- a/jdk/src/share/classes/java/time/zone/ZoneRulesProvider.java +++ b/jdk/src/share/classes/java/time/zone/ZoneRulesProvider.java @@ -141,7 +141,7 @@ public abstract class ZoneRulesProvider { // if the property java.time.zone.DefaultZoneRulesProvider is // set then its value is the class name of the default provider final List loaded = new ArrayList<>(); - AccessController.doPrivileged(new PrivilegedAction() { + AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String prop = System.getProperty("java.time.zone.DefaultZoneRulesProvider"); if (prop != null) { diff --git a/jdk/src/share/classes/java/util/Formatter.java b/jdk/src/share/classes/java/util/Formatter.java index 65a6f0b3634..52e9a4a511f 100644 --- a/jdk/src/share/classes/java/util/Formatter.java +++ b/jdk/src/share/classes/java/util/Formatter.java @@ -56,7 +56,7 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; -import java.time.temporal.Queries; +import java.time.temporal.TemporalQuery; import sun.misc.DoubleConsts; import sun.misc.FormattedFloatingDecimal; @@ -4160,7 +4160,7 @@ public final class Formatter implements Closeable, Flushable { break; } case DateTime.ZONE: { // 'Z' (symbol) - ZoneId zid = t.query(Queries.zone()); + ZoneId zid = t.query(TemporalQuery.zone()); if (zid == null) { throw new IllegalFormatConversionException(c, t.getClass()); } diff --git a/jdk/src/share/classes/java/util/GregorianCalendar.java b/jdk/src/share/classes/java/util/GregorianCalendar.java index 96501286e75..1f818ed6f64 100644 --- a/jdk/src/share/classes/java/util/GregorianCalendar.java +++ b/jdk/src/share/classes/java/util/GregorianCalendar.java @@ -45,7 +45,7 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.chrono.IsoChronology; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; +import java.time.temporal.TemporalQuery; import sun.util.calendar.BaseCalendar; import sun.util.calendar.CalendarDate; import sun.util.calendar.CalendarSystem; diff --git a/jdk/src/share/classes/java/util/TimeZone.java b/jdk/src/share/classes/java/util/TimeZone.java index cc8fe5dc356..b49d8d210ef 100644 --- a/jdk/src/share/classes/java/util/TimeZone.java +++ b/jdk/src/share/classes/java/util/TimeZone.java @@ -559,7 +559,7 @@ abstract public class TimeZone implements Serializable, Cloneable { * @since 1.8 */ public ZoneId toZoneId() { - return ZoneId.of(getID(), ZoneId.OLD_IDS_POST_2005); + return ZoneId.of(getID(), ZoneId.SHORT_IDS); } private static TimeZone getTimeZone(String ID, boolean fallback) { diff --git a/jdk/src/share/classes/sun/text/resources/FormatData.java b/jdk/src/share/classes/sun/text/resources/FormatData.java index 76576336846..960249a8752 100644 --- a/jdk/src/share/classes/sun/text/resources/FormatData.java +++ b/jdk/src/share/classes/sun/text/resources/FormatData.java @@ -79,9 +79,9 @@ package sun.text.resources; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData extends ListResourceBundle { +public class FormatData extends ParallelListResourceBundle { /** * Overrides ListResourceBundle */ @@ -117,12 +117,6 @@ public class FormatData extends ListResourceBundle { "Heisei", }; - // Minguo era strings - final String[] rocEras ={ - "Before R.O.C.", - "R.O.C.", - }; - return new Object[][] { { "MonthNames", new String[] { @@ -158,6 +152,23 @@ public class FormatData extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "Sunday", // Sunday @@ -205,13 +216,7 @@ public class FormatData extends ListResourceBundle { }, { "Eras", julianEras }, - { "cldr.long.Eras", - new String[] { - "Before Christ", - "Anno Domini" - } - }, - { "cldr.short.Eras", + { "short.Eras", julianEras }, { "narrow.Eras", new String[] { @@ -230,10 +235,6 @@ public class FormatData extends ListResourceBundle { }, { "japanese.Eras", japaneseEras }, - { "cldr.japanese.long.Eras", - japaneseEras }, - { "cldr.japanese.short.Eras", - japaneseEras }, { "japanese.short.Eras", japaneseEraAbbrs }, @@ -822,14 +823,6 @@ public class FormatData extends ListResourceBundle { "H:mm", // short time pattern } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "G y MMMM d", - "G y MMM d", - "GGGGG yyyy-MM-dd", - } - }, { "buddhist.DatePatterns", new String[] { "EEEE d MMMM G yyyy", // full date pattern @@ -851,14 +844,6 @@ public class FormatData extends ListResourceBundle { "h:mm a", // short time pattern } }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "G y MMMM d", - "G y MMM d", - "GGGGG yy-MM-dd", - } - }, { "japanese.DatePatterns", new String[] { "GGGG yyyy MMMM d (EEEE)", // full date pattern @@ -872,99 +857,7 @@ public class FormatData extends ListResourceBundle { "{1} {0}" // date-time pattern } }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "G y MMMM d", - "G y MMM d", - "GGGGG yyy-MM-dd", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, GGGG y MMMM dd", - "GGGG y MMMM d", - "GGGG y MMM d", - "G yyy-MM-dd", - } - }, - { "islamic.MonthNames", - new String[] { - "Muharram", - "Safar", - "Rabi\u02bb I", - "Rabi\u02bb II", - "Jumada I", - "Jumada II", - "Rajab", - "Sha\u02bbban", - "Ramadan", - "Shawwal", - "Dhu\u02bbl-Qi\u02bbdah", - "Dhu\u02bbl-Hijjah", - "", - } - }, - { "islamic.MonthAbbreviations", - new String[] { - "Muh.", - "Saf.", - "Rab. I", - "Rab. II", - "Jum. I", - "Jum. II", - "Raj.", - "Sha.", - "Ram.", - "Shaw.", - "Dhu\u02bbl-Q.", - "Dhu\u02bbl-H.", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "AH", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, MMMM d, y G", - "MMMM d, y G", - "MMM d, y G", - "M/d/yy G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, MMMM d, y GGGG", - "MMMM d, y GGGG", - "MMM d, y GGGG", - "M/d/yy GGGG", - } - }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "Islamic-Civil Calendar" }, - { "calendarname.islamicc", "Islamic-Civil Calendar" }, - { "calendarname.islamic", "Islamic Calendar" }, - { "calendarname.japanese", "Japanese Calendar" }, - { "calendarname.gregorian", "Gregorian Calendar" }, - { "calendarname.gregory", "Gregorian Calendar" }, - { "calendarname.roc", "Minguo Calendar" }, - { "calendarname.buddhist", "Buddhist Calendar" }, - { "field.era", "Era" }, - { "field.year", "Year" }, - { "field.month", "Month" }, - { "field.week", "Week" }, - { "field.weekday", "Day of the Week" }, - { "field.dayperiod", "Dayperiod" }, - { "field.hour", "Hour" }, - { "field.minute", "Minute" }, - { "field.second", "Second" }, - { "field.zone", "Zone" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/JavaTimeSupplementary.java b/jdk/src/share/classes/sun/text/resources/JavaTimeSupplementary.java new file mode 100644 index 00000000000..b67164be1cc --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/JavaTimeSupplementary.java @@ -0,0 +1,287 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Buddhist Calendar" }, + { "calendarname.gregorian", + "Gregorian Calendar" }, + { "calendarname.gregory", + "Gregorian Calendar" }, + { "calendarname.islamic", + "Islamic Calendar" }, + { "calendarname.islamic-civil", + "Islamic-Civil Calendar" }, + { "calendarname.islamicc", + "Islamic-Civil Calendar" }, + { "calendarname.japanese", + "Japanese Calendar" }, + { "calendarname.roc", + "Minguo Calendar" }, + { "field.dayperiod", + "Dayperiod" }, + { "field.era", + "Era" }, + { "field.hour", + "Hour" }, + { "field.minute", + "Minute" }, + { "field.month", + "Month" }, + { "field.second", + "Second" }, + { "field.week", + "Week" }, + { "field.weekday", + "Day of the Week" }, + { "field.year", + "Year" }, + { "field.zone", + "Zone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, MMMM d, y GGGG", + "MMMM d, y GGGG", + "MMM d, y GGGG", + "M/d/yy GGGG", + } + }, + { "islamic.Eras", + new String[] { + "", + "AH", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "Muh.", + "Saf.", + "Rab. I", + "Rab. II", + "Jum. I", + "Jum. II", + "Raj.", + "Sha.", + "Ram.", + "Shaw.", + "Dhu\u02bbl-Q.", + "Dhu\u02bbl-H.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Muharram", + "Safar", + "Rabi\u02bb I", + "Rabi\u02bb II", + "Jumada I", + "Jumada II", + "Rajab", + "Sha\u02bbban", + "Ramadan", + "Shawwal", + "Dhu\u02bbl-Qi\u02bbdah", + "Dhu\u02bbl-Hijjah", + "", + } + }, + { "islamic.MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "AH", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, G y MMMM dd", + "G y MMMM d", + "G y MMM d", + "GGGGG yyyy-MM-dd", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "B.E.", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "G y MMMM d (EEEE)", + "G y MMMM d", + "G y MMM d", + "GGGGGy.MM.dd", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "", + "Meiji", + "Taisho", + "Showa", + "Heisei", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "", + "Meiji", + "Taisho", + "Showa", + "Heisei", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, G y MMMM dd", + "G y MMMM d", + "G y MMM d", + "GGGGG yyy-MM-dd", + } + }, + { "java.time.short.Eras", + new String[] { + "BC", + "AD", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, GGGG y MMMM dd", + "GGGG y MMMM d", + "GGGG y MMM d", + "G yyy-MM-dd", + } + }, + { "roc.Eras", + new String[] { + "Before R.O.C.", + "R.O.C.", + } + }, + { "roc.short.Eras", + new String[] { + "Before R.O.C.", + "R.O.C.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar.java b/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar.java index b50abe12538..3be4cd39e6f 100644 --- a/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar.java +++ b/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar.java @@ -79,11 +79,11 @@ package sun.text.resources.ar; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ar extends ListResourceBundle { +public class FormatData_ar extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -126,6 +126,23 @@ public class FormatData_ar extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u064a", + "\u0641", + "\u0645", + "\u0623", + "\u0648", + "\u0646", + "\u0644", + "\u063a", + "\u0633", + "\u0643", + "\u0628", + "\u062f", + "", + } + }, { "DayNames", new String[] { "\u0627\u0644\u0623\u062d\u062f", // Sunday @@ -148,6 +165,17 @@ public class FormatData_ar extends ListResourceBundle { "\u0633" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "\u0627\u0644\u0623\u062d\u062f", + "\u0627\u0644\u0627\u062b\u0646\u064a\u0646", + "\u0627\u0644\u062b\u0644\u0627\u062b\u0627\u0621", + "\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621", + "\u0627\u0644\u062e\u0645\u064a\u0633", + "\u0627\u0644\u062c\u0645\u0639\u0629", + "\u0627\u0644\u0633\u0628\u062a", + } + }, { "DayNarrows", new String[] { "\u062d", @@ -171,6 +199,42 @@ public class FormatData_ar extends ListResourceBundle { "\u0645" } }, + { "short.Eras", + new String[] { + "\u0642.\u0645", + "\u0645", + } + }, + { "japanese.Eras", + new String[] { + "\u0645", + "\u0645\u064a\u062c\u064a", + "\u062a\u064a\u0634\u0648", + "\u0634\u0648\u0648\u0627", + "\u0647\u064a\u0633\u064a", + } + }, + { "japanese.short.Eras", + new String[] { + "\u0645", + "\u0645\u064a\u062c\u064a", + "\u062a\u064a\u0634\u0648", + "\u0634\u0648\u0648\u0627", + "\u0647\u064a\u0633\u064a", + } + }, + { "buddhist.Eras", + new String[] { + "BC", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a", + } + }, + { "buddhist.short.Eras", + new String[] { + "BC", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a", + } + }, { "NumberPatterns", new String[] { "#,##0.###;#,##0.###-", // decimal pattern @@ -200,114 +264,6 @@ public class FormatData_ar extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE\u060c d MMMM\u060c y G", - "d MMMM\u060c y G", - "dd\u200f/MM\u200f/y G", - "d\u200f/M\u200f/y G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE\u060c d MMMM\u060c y G", - "d MMMM\u060c y G", - "dd\u200f/MM\u200f/y G", - "d\u200f/M\u200f/y G", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE\u060c d MMMM\u060c y G", - "d MMMM\u060c y G", - "dd\u200f/MM\u200f/y G", - "d\u200f/M\u200f/y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE\u060c d MMMM\u060c y GGGG", - "d MMMM\u060c y GGGG", - "dd\u200f/MM\u200f/y GGGG", - "d\u200f/M\u200f/y GGGG", - } - }, - { "islamic.MonthNames", - new String[] { - "\u0645\u062d\u0631\u0645", - "\u0635\u0641\u0631", - "\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644", - "\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631", - "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649", - "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629", - "\u0631\u062c\u0628", - "\u0634\u0639\u0628\u0627\u0646", - "\u0631\u0645\u0636\u0627\u0646", - "\u0634\u0648\u0627\u0644", - "\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629", - "\u0630\u0648 \u0627\u0644\u062d\u062c\u0629", - "", - } - }, - { "islamic.MonthAbbreviations", - new String[] { - "\u0645\u062d\u0631\u0645", - "\u0635\u0641\u0631", - "\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644", - "\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631", - "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649", - "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629", - "\u0631\u062c\u0628", - "\u0634\u0639\u0628\u0627\u0646", - "\u0631\u0645\u0636\u0627\u0646", - "\u0634\u0648\u0627\u0644", - "\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629", - "\u0630\u0648 \u0627\u0644\u062d\u062c\u0629", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "\u0647\u0640", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE\u060c d MMMM y", - "d MMMM y", - "d MMM\u060c y G", - "d\u200f/M\u200f/yyyy", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE\u060c d MMMM y", - "d MMMM y", - "d MMM\u060c y GGGG", - "d\u200f/M\u200f/yyyy", - } - }, - { "calendarname.islamic-civil", "\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a" }, - { "calendarname.islamicc", "\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a" }, - { "calendarname.islamic", "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0647\u062c\u0631\u064a" }, - { "calendarname.japanese", "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u064a\u0627\u0628\u0627\u0646\u064a" }, - { "calendarname.gregorian", "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a" }, - { "calendarname.gregory", "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a" }, - { "calendarname.roc", "\u062a\u0642\u0648\u064a\u0645 \u0645\u064a\u0646\u062c\u0648" }, - { "calendarname.buddhist", "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a" }, - { "field.era", "\u0627\u0644\u0639\u0635\u0631" }, - { "field.year", "\u0627\u0644\u0633\u0646\u0629" }, - { "field.month", "\u0627\u0644\u0634\u0647\u0631" }, - { "field.week", "\u0627\u0644\u0623\u0633\u0628\u0648\u0639" }, - { "field.weekday", "\u0627\u0644\u064a\u0648\u0645" }, - { "field.dayperiod", "\u0635/\u0645" }, - { "field.hour", "\u0627\u0644\u0633\u0627\u0639\u0627\u062a" }, - { "field.minute", "\u0627\u0644\u062f\u0642\u0627\u0626\u0642" }, - { "field.second", "\u0627\u0644\u062b\u0648\u0627\u0646\u064a" }, - { "field.zone", "\u0627\u0644\u062a\u0648\u0642\u064a\u062a" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_JO.java b/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_JO.java index 660a4c6d795..32676d3ae86 100644 --- a/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_JO.java +++ b/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_JO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -42,11 +42,11 @@ package sun.text.resources.ar; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ar_JO extends ListResourceBundle { +public class FormatData_ar_JO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_LB.java b/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_LB.java index 73ecf991cfd..da510b23a1c 100644 --- a/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_LB.java +++ b/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_LB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -42,11 +42,11 @@ package sun.text.resources.ar; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ar_LB extends ListResourceBundle { +public class FormatData_ar_LB extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_SY.java b/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_SY.java index 052b6e3c6c9..c2fec882cbd 100644 --- a/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_SY.java +++ b/jdk/src/share/classes/sun/text/resources/ar/FormatData_ar_SY.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -42,11 +42,11 @@ package sun.text.resources.ar; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ar_SY extends ListResourceBundle { +public class FormatData_ar_SY extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/ar/JavaTimeSupplementary_ar.java b/jdk/src/share/classes/sun/text/resources/ar/JavaTimeSupplementary_ar.java new file mode 100644 index 00000000000..9f261e6e1ee --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/ar/JavaTimeSupplementary_ar.java @@ -0,0 +1,285 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ar; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ar extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "\u0627\u0644\u0631\u0628\u0639 \u0627\u0644\u0623\u0648\u0644", + "\u0627\u0644\u0631\u0628\u0639 \u0627\u0644\u062b\u0627\u0646\u064a", + "\u0627\u0644\u0631\u0628\u0639 \u0627\u0644\u062b\u0627\u0644\u062b", + "\u0627\u0644\u0631\u0628\u0639 \u0627\u0644\u0631\u0627\u0628\u0639", + } + }, + { "QuarterNarrows", + new String[] { + "\u0661", + "\u0662", + "\u0663", + "\u0664", + } + }, + { "calendarname.buddhist", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a" }, + { "calendarname.gregorian", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a" }, + { "calendarname.gregory", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a" }, + { "calendarname.islamic", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0647\u062c\u0631\u064a" }, + { "calendarname.islamic-civil", + "\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a" }, + { "calendarname.islamicc", + "\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a" }, + { "calendarname.japanese", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u064a\u0627\u0628\u0627\u0646\u064a" }, + { "calendarname.roc", + "\u062a\u0642\u0648\u064a\u0645 \u0645\u064a\u0646\u062c\u0648" }, + { "field.dayperiod", + "\u0635/\u0645" }, + { "field.era", + "\u0627\u0644\u0639\u0635\u0631" }, + { "field.hour", + "\u0627\u0644\u0633\u0627\u0639\u0627\u062a" }, + { "field.minute", + "\u0627\u0644\u062f\u0642\u0627\u0626\u0642" }, + { "field.month", + "\u0627\u0644\u0634\u0647\u0631" }, + { "field.second", + "\u0627\u0644\u062b\u0648\u0627\u0646\u064a" }, + { "field.week", + "\u0627\u0644\u0623\u0633\u0628\u0648\u0639" }, + { "field.weekday", + "\u0627\u0644\u064a\u0648\u0645" }, + { "field.year", + "\u0627\u0644\u0633\u0646\u0629" }, + { "field.zone", + "\u0627\u0644\u062a\u0648\u0642\u064a\u062a" }, + { "islamic.DatePatterns", + new String[] { + "EEEE\u060c d MMMM y", + "d MMMM y", + "d MMM\u060c y GGGG", + "d\u200f/M\u200f/yyyy", + } + }, + { "islamic.Eras", + new String[] { + "", + "\u0647\u0640", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "\u0645\u062d\u0631\u0645", + "\u0635\u0641\u0631", + "\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644", + "\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631", + "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649", + "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629", + "\u0631\u062c\u0628", + "\u0634\u0639\u0628\u0627\u0646", + "\u0631\u0645\u0636\u0627\u0646", + "\u0634\u0648\u0627\u0644", + "\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629", + "\u0630\u0648 \u0627\u0644\u062d\u062c\u0629", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "\u0645\u062d\u0631\u0645", + "\u0635\u0641\u0631", + "\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644", + "\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631", + "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649", + "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629", + "\u0631\u062c\u0628", + "\u0634\u0639\u0628\u0627\u0646", + "\u0631\u0645\u0636\u0627\u0646", + "\u0634\u0648\u0627\u0644", + "\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629", + "\u0630\u0648 \u0627\u0644\u062d\u062c\u0629", + "", + } + }, + { "islamic.MonthNarrows", + new String[] { + "\u0661", + "\u0662", + "\u0663", + "\u0664", + "\u0665", + "\u0666", + "\u0667", + "\u0668", + "\u0669", + "\u0661\u0660", + "\u0661\u0661", + "\u0661\u0662", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u0647\u0640", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE\u060c d MMMM\u060c y G", + "d MMMM\u060c y G", + "dd\u200f/MM\u200f/y G", + "d\u200f/M\u200f/y G", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE\u060c d MMMM y", + "d MMMM y", + "d MMM\u060c y G", + "d\u200f/M\u200f/yyyy", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE\u060c d MMMM\u060c y G", + "d MMMM\u060c y G", + "dd\u200f/MM\u200f/y G", + "d\u200f/M\u200f/y G", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u0645", + "\u0645\u064a\u062c\u064a", + "\u062a\u064a\u0634\u0648", + "\u0634\u0648\u0648\u0627", + "\u0647\u064a\u0633\u064a", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u0645", + "\u0645\u064a\u062c\u064a", + "\u062a\u064a\u0634\u0648", + "\u0634\u0648\u0648\u0627", + "\u0647\u064a\u0633\u064a", + } + }, + { "java.time.long.Eras", + new String[] { + "\u0642\u0628\u0644 \u0627\u0644\u0645\u064a\u0644\u0627\u062f", + "\u0645\u064a\u0644\u0627\u062f\u064a", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE\u060c d MMMM\u060c y G", + "d MMMM\u060c y G", + "dd\u200f/MM\u200f/y G", + "d\u200f/M\u200f/y G", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0642.\u0645", + "\u0645", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE\u060c d MMMM\u060c y GGGG", + "d MMMM\u060c y GGGG", + "dd\u200f/MM\u200f/y GGGG", + "d\u200f/M\u200f/y GGGG", + } + }, + { "roc.Eras", + new String[] { + "Before R.O.C.", + "\u062c\u0645\u0647\u0648\u0631\u064a\u0629 \u0627\u0644\u0635\u064a", + } + }, + { "roc.short.Eras", + new String[] { + "Before R.O.C.", + "\u062c\u0645\u0647\u0648\u0631\u064a\u0629 \u0627\u0644\u0635\u064a", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/be/FormatData_be.java b/jdk/src/share/classes/sun/text/resources/be/FormatData_be.java index 84c15394658..bed17d2f4f1 100644 --- a/jdk/src/share/classes/sun/text/resources/be/FormatData_be.java +++ b/jdk/src/share/classes/sun/text/resources/be/FormatData_be.java @@ -79,11 +79,11 @@ package sun.text.resources.be; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_be extends ListResourceBundle { +public class FormatData_be extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -177,6 +177,12 @@ public class FormatData_be extends ListResourceBundle { "\u043d.\u0435." } }, + { "short.Eras", + new String[] { + "\u0434\u0430 \u043d.\u044d.", + "\u043d.\u044d.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -214,29 +220,6 @@ public class FormatData_be extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d MMMM y G", - "d MMMM y G", - "d MMM y G", - "d.M.yy", - } - }, - { "calendarname.islamic-civil", "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.islamicc", "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.islamic", "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.buddhist", "\u0431\u0443\u0434\u044b\u0441\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.japanese", "\u044f\u043f\u043e\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.gregorian", "\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "calendarname.gregory", "\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, - { "field.era", "\u044d\u0440\u0430" }, - { "field.year", "\u0433\u043e\u0434" }, - { "field.month", "\u043c\u0435\u0441\u044f\u0446" }, - { "field.week", "\u0442\u044b\u0434\u0437\u0435\u043d\u044c" }, - { "field.weekday", "\u0434\u0437\u0435\u043d\u044c \u0442\u044b\u0434\u043d\u044f" }, - { "field.hour", "\u0433\u0430\u0434\u0437\u0456\u043d\u0430" }, - { "field.minute", "\u0445\u0432\u0456\u043b\u0456\u043d\u0430" }, - { "field.second", "\u0441\u0435\u043a\u0443\u043d\u0434\u0430" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/be/FormatData_be_BY.java b/jdk/src/share/classes/sun/text/resources/be/FormatData_be_BY.java index b9b4463e99a..803f5699907 100644 --- a/jdk/src/share/classes/sun/text/resources/be/FormatData_be_BY.java +++ b/jdk/src/share/classes/sun/text/resources/be/FormatData_be_BY.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -43,11 +43,11 @@ package sun.text.resources.be; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_be_BY extends ListResourceBundle { +public class FormatData_be_BY extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/be/JavaTimeSupplementary_be.java b/jdk/src/share/classes/sun/text/resources/be/JavaTimeSupplementary_be.java new file mode 100644 index 00000000000..baa42ca6aa4 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/be/JavaTimeSupplementary_be.java @@ -0,0 +1,138 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.be; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_be extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1-\u0448\u044b \u043a\u0432.", + "2-\u0433\u0456 \u043a\u0432.", + "3-\u0446\u0456 \u043a\u0432.", + "4-\u0442\u044b \u043a\u0432.", + } + }, + { "QuarterNames", + new String[] { + "1-\u0448\u044b \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "2-\u0433\u0456 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "3-\u0446\u0456 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "4-\u0442\u044b \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + } + }, + { "calendarname.buddhist", + "\u0431\u0443\u0434\u044b\u0441\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.gregorian", + "\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.gregory", + "\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic", + "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic-civil", + "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.islamicc", + "\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "calendarname.japanese", + "\u044f\u043f\u043e\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440" }, + { "field.dayperiod", + "\u0414\u041f/\u041f\u041f" }, + { "field.era", + "\u044d\u0440\u0430" }, + { "field.hour", + "\u0433\u0430\u0434\u0437\u0456\u043d\u0430" }, + { "field.minute", + "\u0445\u0432\u0456\u043b\u0456\u043d\u0430" }, + { "field.month", + "\u043c\u0435\u0441\u044f\u0446" }, + { "field.second", + "\u0441\u0435\u043a\u0443\u043d\u0434\u0430" }, + { "field.week", + "\u0442\u044b\u0434\u0437\u0435\u043d\u044c" }, + { "field.weekday", + "\u0434\u0437\u0435\u043d\u044c \u0442\u044b\u0434\u043d\u044f" }, + { "field.year", + "\u0433\u043e\u0434" }, + { "field.zone", + "Zone" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "d MMM y G", + "d.M.yy", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0434\u0430 \u043d.\u0435.", + "\u043d.\u0435.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg.java b/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg.java index 2d9ec8da0de..b97e2746277 100644 --- a/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg.java +++ b/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg.java @@ -79,11 +79,11 @@ package sun.text.resources.bg; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_bg extends ListResourceBundle { +public class FormatData_bg extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -121,6 +121,23 @@ public class FormatData_bg extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u044f", + "\u0444", + "\u043c", + "\u0430", + "\u043c", + "\u044e", + "\u044e", + "\u0430", + "\u0441", + "\u043e", + "\u043d", + "\u0434", + "", + } + }, { "DayNames", new String[] { "\u041d\u0435\u0434\u0435\u043b\u044f", // Sunday @@ -160,6 +177,12 @@ public class FormatData_bg extends ListResourceBundle { "\u043d.\u0435." } }, + { "short.Eras", + new String[] { + "\u043f\u0440. \u043d. \u0435.", + "\u043e\u0442 \u043d. \u0435.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -197,41 +220,6 @@ public class FormatData_bg extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "islamic.MonthNames", - new String[] { - "\u043c\u0443\u0445\u0430\u0440\u0430\u043c", - "\u0441\u0430\u0444\u0430\u0440", - "\u0440\u0430\u0431\u0438-1", - "\u0440\u0430\u0431\u0438-2", - "\u0434\u0436\u0443\u043c\u0430\u0434\u0430-1", - "\u0434\u0436\u0443\u043c\u0430\u0434\u0430-2", - "\u0440\u0430\u0434\u0436\u0430\u0431", - "\u0448\u0430\u0431\u0430\u043d", - "\u0440\u0430\u043c\u0430\u0437\u0430\u043d", - "\u0428\u0430\u0432\u0430\u043b", - "\u0414\u0445\u0443\u043b-\u041a\u0430\u0430\u0434\u0430", - "\u0414\u0445\u0443\u043b-\u0445\u0438\u0434\u0436\u0430", - "", - } - }, - { "calendarname.islamic-civil", "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamicc", "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamic", "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.japanese", "\u042f\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregorian", "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregory", "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.roc", "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u0442\u0430\u0439" }, - { "calendarname.buddhist", "\u0411\u0443\u0434\u0438\u0441\u0442\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "field.era", "\u0435\u0440\u0430" }, - { "field.year", "\u0433\u043e\u0434\u0438\u043d\u0430" }, - { "field.month", "\u043c\u0435\u0441\u0435\u0446" }, - { "field.week", "\u0441\u0435\u0434\u043c\u0438\u0446\u0430" }, - { "field.weekday", "\u0414\u0435\u043d \u043e\u0442 \u0441\u0435\u0434\u043c\u0438\u0446\u0430\u0442\u0430" }, - { "field.dayperiod", "\u0434\u0435\u043d" }, - { "field.hour", "\u0447\u0430\u0441" }, - { "field.minute", "\u043c\u0438\u043d\u0443\u0442\u0430" }, - { "field.second", "\u0441\u0435\u043a\u0443\u043d\u0434\u0430" }, - { "field.zone", "\u0437\u043e\u043d\u0430" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg_BG.java b/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg_BG.java index 72bcc7b775b..7ea06d3a472 100644 --- a/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg_BG.java +++ b/jdk/src/share/classes/sun/text/resources/bg/FormatData_bg_BG.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -43,11 +43,11 @@ package sun.text.resources.bg; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_bg_BG extends ListResourceBundle { +public class FormatData_bg_BG extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/bg/JavaTimeSupplementary_bg.java b/jdk/src/share/classes/sun/text/resources/bg/JavaTimeSupplementary_bg.java new file mode 100644 index 00000000000..b3ac5969154 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/bg/JavaTimeSupplementary_bg.java @@ -0,0 +1,163 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.bg; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_bg extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "I \u0442\u0440\u0438\u043c.", + "II \u0442\u0440\u0438\u043c.", + "III \u0442\u0440\u0438\u043c.", + "IV \u0442\u0440\u0438\u043c.", + } + }, + { "QuarterNames", + new String[] { + "1-\u0432\u043e \u0442\u0440\u0438\u043c\u0435\u0441\u0435\u0447\u0438\u0435", + "2-\u0440\u043e \u0442\u0440\u0438\u043c\u0435\u0441\u0435\u0447\u0438\u0435", + "3-\u0442\u043e \u0442\u0440\u0438\u043c\u0435\u0441\u0435\u0447\u0438\u0435", + "4-\u0442\u043e \u0442\u0440\u0438\u043c\u0435\u0441\u0435\u0447\u0438\u0435", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u0411\u0443\u0434\u0438\u0441\u0442\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregorian", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregory", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic", + "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic-civil", + "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamicc", + "\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.japanese", + "\u042f\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.roc", + "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u0442\u0430\u0439" }, + { "field.dayperiod", + "\u0434\u0435\u043d" }, + { "field.era", + "\u0435\u0440\u0430" }, + { "field.hour", + "\u0447\u0430\u0441" }, + { "field.minute", + "\u043c\u0438\u043d\u0443\u0442\u0430" }, + { "field.month", + "\u043c\u0435\u0441\u0435\u0446" }, + { "field.second", + "\u0441\u0435\u043a\u0443\u043d\u0434\u0430" }, + { "field.week", + "\u0441\u0435\u0434\u043c\u0438\u0446\u0430" }, + { "field.weekday", + "\u0414\u0435\u043d \u043e\u0442 \u0441\u0435\u0434\u043c\u0438\u0446\u0430\u0442\u0430" }, + { "field.year", + "\u0433\u043e\u0434\u0438\u043d\u0430" }, + { "field.zone", + "\u0437\u043e\u043d\u0430" }, + { "islamic.MonthNames", + new String[] { + "\u043c\u0443\u0445\u0430\u0440\u0430\u043c", + "\u0441\u0430\u0444\u0430\u0440", + "\u0440\u0430\u0431\u0438-1", + "\u0440\u0430\u0431\u0438-2", + "\u0434\u0436\u0443\u043c\u0430\u0434\u0430-1", + "\u0434\u0436\u0443\u043c\u0430\u0434\u0430-2", + "\u0440\u0430\u0434\u0436\u0430\u0431", + "\u0448\u0430\u0431\u0430\u043d", + "\u0440\u0430\u043c\u0430\u0437\u0430\u043d", + "\u0428\u0430\u0432\u0430\u043b", + "\u0414\u0445\u0443\u043b-\u041a\u0430\u0430\u0434\u0430", + "\u0414\u0445\u0443\u043b-\u0445\u0438\u0434\u0436\u0430", + "", + } + }, + { "java.time.long.Eras", + new String[] { + "\u043f\u0440.\u0425\u0440.", + "\u0441\u043b.\u0425\u0440.", + } + }, + { "java.time.short.Eras", + new String[] { + "\u043f\u0440.\u043d.\u0435.", + "\u043d.\u0435.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca.java b/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca.java index 10522d5e22c..153b907e377 100644 --- a/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca.java +++ b/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca.java @@ -79,11 +79,11 @@ package sun.text.resources.ca; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ca extends ListResourceBundle { +public class FormatData_ca extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -104,6 +104,23 @@ public class FormatData_ca extends ListResourceBundle { "", } }, + { "MonthNarrows", + new String[] { + "G", + "F", + "M", + "A", + "M", + "J", + "G", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthNames", new String[] { "gener", // january @@ -183,6 +200,17 @@ public class FormatData_ca extends ListResourceBundle { "dissabte" // Saturday } }, + { "standalone.DayNames", + new String[] { + "Diumenge", + "Dilluns", + "Dimarts", + "Dimecres", + "Dijous", + "Divendres", + "Dissabte", + } + }, { "DayAbbreviations", new String[] { "dg.", // abb Sunday @@ -194,6 +222,17 @@ public class FormatData_ca extends ListResourceBundle { "ds." // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "dg", + "dl", + "dt", + "dc", + "dj", + "dv", + "ds", + } + }, { "DayNarrows", new String[] { "G", @@ -216,6 +255,12 @@ public class FormatData_ca extends ListResourceBundle { "s", } }, + { "short.Eras", + new String[] { + "aC", + "dC", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -253,24 +298,6 @@ public class FormatData_ca extends ListResourceBundle { } }, { "DateTimePatternChars", "GuMtkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "calendari civil isl\u00e0mic" }, - { "calendarname.islamicc", "calendari civil isl\u00e0mic" }, - { "calendarname.roc", "calendari de la Rep\u00fablica de Xina" }, - { "calendarname.islamic", "calendari musulm\u00e0" }, - { "calendarname.buddhist", "calendari budista" }, - { "calendarname.japanese", "calendari japon\u00e8s" }, - { "calendarname.gregorian", "calendari gregori\u00e0" }, - { "calendarname.gregory", "calendari gregori\u00e0" }, - { "field.era", "era" }, - { "field.year", "any" }, - { "field.month", "mes" }, - { "field.week", "setmana" }, - { "field.weekday", "dia de la setmana" }, - { "field.dayperiod", "a.m./p.m." }, - { "field.hour", "hora" }, - { "field.minute", "minut" }, - { "field.second", "segon" }, - { "field.zone", "zona" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca_ES.java b/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca_ES.java index c3bd646f044..8571094b519 100644 --- a/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca_ES.java +++ b/jdk/src/share/classes/sun/text/resources/ca/FormatData_ca_ES.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -43,11 +43,11 @@ package sun.text.resources.ca; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ca_ES extends ListResourceBundle { +public class FormatData_ca_ES extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/ca/JavaTimeSupplementary_ca.java b/jdk/src/share/classes/sun/text/resources/ca/JavaTimeSupplementary_ca.java new file mode 100644 index 00000000000..cd991360b07 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/ca/JavaTimeSupplementary_ca.java @@ -0,0 +1,140 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ca; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ca extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1T", + "2T", + "3T", + "4T", + } + }, + { "QuarterNames", + new String[] { + "1r trimestre", + "2n trimestre", + "3r trimestre", + "4t trimestre", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "calendari budista" }, + { "calendarname.gregorian", + "calendari gregori\u00e0" }, + { "calendarname.gregory", + "calendari gregori\u00e0" }, + { "calendarname.islamic", + "calendari musulm\u00e0" }, + { "calendarname.islamic-civil", + "calendari civil isl\u00e0mic" }, + { "calendarname.islamicc", + "calendari civil isl\u00e0mic" }, + { "calendarname.japanese", + "calendari japon\u00e8s" }, + { "calendarname.roc", + "calendari de la Rep\u00fablica de Xina" }, + { "field.dayperiod", + "a.m./p.m." }, + { "field.era", + "era" }, + { "field.hour", + "hora" }, + { "field.minute", + "minut" }, + { "field.month", + "mes" }, + { "field.second", + "segon" }, + { "field.week", + "setmana" }, + { "field.weekday", + "dia de la setmana" }, + { "field.year", + "any" }, + { "field.zone", + "zona" }, + { "java.time.short.Eras", + new String[] { + "aC", + "dC", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs.java b/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs.java index cb2d780cb82..19ab68d18cd 100644 --- a/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs.java +++ b/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs.java @@ -79,11 +79,11 @@ package sun.text.resources.cs; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_cs extends ListResourceBundle { +public class FormatData_cs extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -155,6 +155,40 @@ public class FormatData_cs extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "l", + "\u00fa", + "b", + "d", + "k", + "\u010d", + "\u010d", + "s", + "z", + "\u0159", + "l", + "p", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "l", + "\u00fa", + "b", + "d", + "k", + "\u010d", + "\u010d", + "s", + "z", + "\u0159", + "l", + "p", + "", + } + }, { "DayNames", new String[] { "Ned\u011ble", // Sunday @@ -166,6 +200,17 @@ public class FormatData_cs extends ListResourceBundle { "Sobota" // Saturday } }, + { "standalone.DayNames", + new String[] { + "ned\u011ble", + "pond\u011bl\u00ed", + "\u00fater\u00fd", + "st\u0159eda", + "\u010dtvrtek", + "p\u00e1tek", + "sobota", + } + }, { "DayAbbreviations", new String[] { "Ne", // abb Sunday @@ -177,6 +222,17 @@ public class FormatData_cs extends ListResourceBundle { "So" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "ne", + "po", + "\u00fat", + "st", + "\u010dt", + "p\u00e1", + "so", + } + }, { "DayNarrows", new String[] { "N", @@ -188,6 +244,17 @@ public class FormatData_cs extends ListResourceBundle { "S", } }, + { "standalone.DayNarrows", + new String[] { + "N", + "P", + "\u00da", + "S", + "\u010c", + "P", + "S", + } + }, { "AmPmMarkers", new String[] { "dop.", // am marker @@ -200,6 +267,18 @@ public class FormatData_cs extends ListResourceBundle { "po Kr." } }, + { "short.Eras", + new String[] { + "p\u0159. n. l.", + "n. l.", + } + }, + { "narrow.Eras", + new String[] { + "p\u0159.n.l.", + "n. l.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -237,22 +316,6 @@ public class FormatData_cs extends ListResourceBundle { } }, { "DateTimePatternChars", "GuMtkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159" }, - { "calendarname.islamicc", "Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159" }, - { "calendarname.islamic", "Muslimsk\u00fd kalend\u00e1\u0159" }, - { "calendarname.buddhist", "Buddhistick\u00fd kalend\u00e1\u0159" }, - { "calendarname.japanese", "Japonsk\u00fd kalend\u00e1\u0159" }, - { "calendarname.gregorian", "Gregori\u00e1nsk\u00fd kalend\u00e1\u0159" }, - { "calendarname.gregory", "Gregori\u00e1nsk\u00fd kalend\u00e1\u0159" }, - { "field.year", "Rok" }, - { "field.month", "M\u011bs\u00edc" }, - { "field.week", "T\u00fdden" }, - { "field.weekday", "Den v t\u00fddnu" }, - { "field.dayperiod", "AM/PM" }, - { "field.hour", "Hodina" }, - { "field.minute", "Minuta" }, - { "field.second", "Sekunda" }, - { "field.zone", "\u010casov\u00e9 p\u00e1smo" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs_CZ.java b/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs_CZ.java index f8619e40fb5..cf6b34a02e1 100644 --- a/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs_CZ.java +++ b/jdk/src/share/classes/sun/text/resources/cs/FormatData_cs_CZ.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -43,11 +43,11 @@ package sun.text.resources.cs; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_cs_CZ extends ListResourceBundle { +public class FormatData_cs_CZ extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/cs/JavaTimeSupplementary_cs.java b/jdk/src/share/classes/sun/text/resources/cs/JavaTimeSupplementary_cs.java new file mode 100644 index 00000000000..7636eb489d8 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/cs/JavaTimeSupplementary_cs.java @@ -0,0 +1,190 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.cs; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_cs extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1. \u010dtvrtlet\u00ed", + "2. \u010dtvrtlet\u00ed", + "3. \u010dtvrtlet\u00ed", + "4. \u010dtvrtlet\u00ed", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Buddhistick\u00fd kalend\u00e1\u0159" }, + { "calendarname.gregorian", + "Gregori\u00e1nsk\u00fd kalend\u00e1\u0159" }, + { "calendarname.gregory", + "Gregori\u00e1nsk\u00fd kalend\u00e1\u0159" }, + { "calendarname.islamic", + "Muslimsk\u00fd kalend\u00e1\u0159" }, + { "calendarname.islamic-civil", + "Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159" }, + { "calendarname.islamicc", + "Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159" }, + { "calendarname.japanese", + "Japonsk\u00fd kalend\u00e1\u0159" }, + { "calendarname.roc", + "Kalend\u00e1\u0159 \u010c\u00ednsk\u00e9 republiky" }, + { "field.dayperiod", + "AM/PM" }, + { "field.era", + "Letopo\u010det" }, + { "field.hour", + "Hodina" }, + { "field.minute", + "Minuta" }, + { "field.month", + "M\u011bs\u00edc" }, + { "field.second", + "Sekunda" }, + { "field.week", + "T\u00fdden" }, + { "field.weekday", + "Den v t\u00fddnu" }, + { "field.year", + "Rok" }, + { "field.zone", + "\u010casov\u00e9 p\u00e1smo" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d. MMMM y G", + "d. MMMM y G", + "d. M. y G", + "dd.MM.yy GGGGG", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. M. y G", + "dd.MM.yy GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "p\u0159. n. l.", + "n. l.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d. MMMM y G", + "d. MMMM y G", + "d. M. y G", + "dd.MM.yy GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "p\u0159.Kr.", + "po Kr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. M. y GGGG", + "dd.MM.yy G", + } + }, + { "roc.Eras", + new String[] { + "P\u0159ed R. O. C.", + "", + } + }, + { "roc.short.Eras", + new String[] { + "P\u0159ed R. O. C.", + "", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/da/FormatData_da.java b/jdk/src/share/classes/sun/text/resources/da/FormatData_da.java index 295a5aaddf6..13efb6f3df9 100644 --- a/jdk/src/share/classes/sun/text/resources/da/FormatData_da.java +++ b/jdk/src/share/classes/sun/text/resources/da/FormatData_da.java @@ -79,11 +79,11 @@ package sun.text.resources.da; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_da extends ListResourceBundle { +public class FormatData_da extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -121,6 +121,23 @@ public class FormatData_da extends ListResourceBundle { "", } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthAbbreviations", new String[] { "jan", // abb january @@ -186,6 +203,18 @@ public class FormatData_da extends ListResourceBundle { "\ufffd" // NaN } }, + { "Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, + { "short.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, { "TimePatterns", new String[] { "HH:mm:ss z", // full time pattern @@ -208,64 +237,6 @@ public class FormatData_da extends ListResourceBundle { } }, { "DateTimePatternChars", "GuMtkHmsSEDFwWahKzZ" }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d/M/y GGGGG", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d/M/y GGGGG", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d. MMM y GGGG", - "d/M/y G", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d/M/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d. MMM y GGGG", - "d/M/y GGGG", - } - }, - { "calendarname.islamic-civil", "verdslig islamisk kalender" }, - { "calendarname.islamicc", "verdslig islamisk kalender" }, - { "calendarname.roc", "kalender for Republikken Kina" }, - { "calendarname.islamic", "islamisk kalender" }, - { "calendarname.buddhist", "buddhistisk kalender" }, - { "calendarname.japanese", "japansk kalender" }, - { "calendarname.gregorian", "gregoriansk kalender" }, - { "calendarname.gregory", "gregoriansk kalender" }, - { "field.era", "\u00e6ra" }, - { "field.year", "\u00e5r" }, - { "field.month", "m\u00e5ned" }, - { "field.week", "uge" }, - { "field.weekday", "ugedag" }, - { "field.dayperiod", "dagtid" }, - { "field.hour", "time" }, - { "field.minute", "minut" }, - { "field.second", "sekund" }, - { "field.zone", "tidszone" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/da/FormatData_da_DK.java b/jdk/src/share/classes/sun/text/resources/da/FormatData_da_DK.java index c8c9b27702a..1565a5f9b3c 100644 --- a/jdk/src/share/classes/sun/text/resources/da/FormatData_da_DK.java +++ b/jdk/src/share/classes/sun/text/resources/da/FormatData_da_DK.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -43,11 +43,11 @@ package sun.text.resources.da; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_da_DK extends ListResourceBundle { +public class FormatData_da_DK extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/da/JavaTimeSupplementary_da.java b/jdk/src/share/classes/sun/text/resources/da/JavaTimeSupplementary_da.java new file mode 100644 index 00000000000..bc88aae782e --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/da/JavaTimeSupplementary_da.java @@ -0,0 +1,194 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.da; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_da extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "1. kvartal", + "2. kvartal", + "3. kvartal", + "4. kvartal", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "buddhistisk kalender" }, + { "calendarname.gregorian", + "gregoriansk kalender" }, + { "calendarname.gregory", + "gregoriansk kalender" }, + { "calendarname.islamic", + "islamisk kalender" }, + { "calendarname.islamic-civil", + "verdslig islamisk kalender" }, + { "calendarname.islamicc", + "verdslig islamisk kalender" }, + { "calendarname.japanese", + "japansk kalender" }, + { "calendarname.roc", + "kalender for Republikken Kina" }, + { "field.dayperiod", + "dagtid" }, + { "field.era", + "\u00e6ra" }, + { "field.hour", + "time" }, + { "field.minute", + "minut" }, + { "field.month", + "m\u00e5ned" }, + { "field.second", + "sekund" }, + { "field.week", + "uge" }, + { "field.weekday", + "ugedag" }, + { "field.year", + "\u00e5r" }, + { "field.zone", + "tidszone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d/M/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d/M/yyyy", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d/M/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d/M/y GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d/M/y GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d/M/y G", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/de/FormatData_de.java b/jdk/src/share/classes/sun/text/resources/de/FormatData_de.java index e8a6c924831..435a79742d2 100644 --- a/jdk/src/share/classes/sun/text/resources/de/FormatData_de.java +++ b/jdk/src/share/classes/sun/text/resources/de/FormatData_de.java @@ -79,11 +79,11 @@ package sun.text.resources.de; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_de extends ListResourceBundle { +public class FormatData_de extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -121,6 +121,23 @@ public class FormatData_de extends ListResourceBundle { "", } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthAbbreviations", new String[] { "Jan", // abb january @@ -160,6 +177,17 @@ public class FormatData_de extends ListResourceBundle { "Sa" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "So", + "Mo", + "Di", + "Mi", + "Do", + "Fr", + "Sa", + } + }, { "DayNarrows", new String[] { "S", @@ -177,6 +205,12 @@ public class FormatData_de extends ListResourceBundle { "n. Chr." } }, + { "short.Eras", + new String[] { + "v. Chr.", + "n. Chr.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -214,72 +248,6 @@ public class FormatData_de extends ListResourceBundle { } }, { "DateTimePatternChars", "GuMtkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d.M.yyyy", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d.M.y GGGGG", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d.M.y GGGGG", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d. MMM y GGGG", - "d.M.y G", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d. MMMM y G", - "d. MMMM y G", - "d. MMM y G", - "d.M.y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d. MMM y GGGG", - "d.M.y GGGG", - } - }, - { "calendarname.islamic-civil", "B\u00fcrgerlicher islamischer Kalender" }, - { "calendarname.islamicc", "B\u00fcrgerlicher islamischer Kalender" }, - { "calendarname.roc", "Kalender der Republik China" }, - { "calendarname.islamic", "Islamischer Kalender" }, - { "calendarname.buddhist", "Buddhistischer Kalender" }, - { "calendarname.japanese", "Japanischer Kalender" }, - { "calendarname.gregorian", "Gregorianischer Kalender" }, - { "calendarname.gregory", "Gregorianischer Kalender" }, - { "field.era", "Epoche" }, - { "field.year", "Jahr" }, - { "field.month", "Monat" }, - { "field.week", "Woche" }, - { "field.weekday", "Wochentag" }, - { "field.dayperiod", "Tagesh\u00e4lfte" }, - { "field.hour", "Stunde" }, - { "field.minute", "Minute" }, - { "field.second", "Sekunde" }, - { "field.zone", "Zone" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/de/FormatData_de_AT.java b/jdk/src/share/classes/sun/text/resources/de/FormatData_de_AT.java index aed48ffe786..e842ffffbfa 100644 --- a/jdk/src/share/classes/sun/text/resources/de/FormatData_de_AT.java +++ b/jdk/src/share/classes/sun/text/resources/de/FormatData_de_AT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -43,11 +43,11 @@ package sun.text.resources.de; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_de_AT extends ListResourceBundle { +public class FormatData_de_AT extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/de/FormatData_de_CH.java b/jdk/src/share/classes/sun/text/resources/de/FormatData_de_CH.java index 8229b7e9b93..ac153156fd0 100644 --- a/jdk/src/share/classes/sun/text/resources/de/FormatData_de_CH.java +++ b/jdk/src/share/classes/sun/text/resources/de/FormatData_de_CH.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -43,11 +43,11 @@ package sun.text.resources.de; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_de_CH extends ListResourceBundle { +public class FormatData_de_CH extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/de/FormatData_de_DE.java b/jdk/src/share/classes/sun/text/resources/de/FormatData_de_DE.java index b1f53b44b0e..a0ad8f06943 100644 --- a/jdk/src/share/classes/sun/text/resources/de/FormatData_de_DE.java +++ b/jdk/src/share/classes/sun/text/resources/de/FormatData_de_DE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -43,11 +43,11 @@ package sun.text.resources.de; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_de_DE extends ListResourceBundle { +public class FormatData_de_DE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/de/FormatData_de_LU.java b/jdk/src/share/classes/sun/text/resources/de/FormatData_de_LU.java index 02f99b14d79..13ea4f824e8 100644 --- a/jdk/src/share/classes/sun/text/resources/de/FormatData_de_LU.java +++ b/jdk/src/share/classes/sun/text/resources/de/FormatData_de_LU.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.de; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_de_LU extends ListResourceBundle { +public class FormatData_de_LU extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/de/JavaTimeSupplementary_de.java b/jdk/src/share/classes/sun/text/resources/de/JavaTimeSupplementary_de.java new file mode 100644 index 00000000000..b5c64df02dd --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/de/JavaTimeSupplementary_de.java @@ -0,0 +1,194 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.de; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_de extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1. Quartal", + "2. Quartal", + "3. Quartal", + "4. Quartal", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Buddhistischer Kalender" }, + { "calendarname.gregorian", + "Gregorianischer Kalender" }, + { "calendarname.gregory", + "Gregorianischer Kalender" }, + { "calendarname.islamic", + "Islamischer Kalender" }, + { "calendarname.islamic-civil", + "B\u00fcrgerlicher islamischer Kalender" }, + { "calendarname.islamicc", + "B\u00fcrgerlicher islamischer Kalender" }, + { "calendarname.japanese", + "Japanischer Kalender" }, + { "calendarname.roc", + "Kalender der Republik China" }, + { "field.dayperiod", + "Tagesh\u00e4lfte" }, + { "field.era", + "Epoche" }, + { "field.hour", + "Stunde" }, + { "field.minute", + "Minute" }, + { "field.month", + "Monat" }, + { "field.second", + "Sekunde" }, + { "field.week", + "Woche" }, + { "field.weekday", + "Wochentag" }, + { "field.year", + "Jahr" }, + { "field.zone", + "Zone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d.M.y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M.yyyy", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M.y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M.y GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "v. Chr.", + "n. Chr.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M.y GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "v. Chr.", + "n. Chr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d.M.y G", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/el/FormatData_el.java b/jdk/src/share/classes/sun/text/resources/el/FormatData_el.java index 398bbdd8e51..430d0e99a19 100644 --- a/jdk/src/share/classes/sun/text/resources/el/FormatData_el.java +++ b/jdk/src/share/classes/sun/text/resources/el/FormatData_el.java @@ -79,11 +79,11 @@ package sun.text.resources.el; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_el extends ListResourceBundle { +public class FormatData_el extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -143,6 +143,57 @@ public class FormatData_el extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "\u0399\u03b1\u03bd", + "\u03a6\u03b5\u03b2", + "\u039c\u03ac\u03c1", + "\u0391\u03c0\u03c1", + "\u039c\u03ac\u03b9", + "\u0399\u03bf\u03cd\u03bd", + "\u0399\u03bf\u03cd\u03bb", + "\u0391\u03c5\u03b3", + "\u03a3\u03b5\u03c0", + "\u039f\u03ba\u03c4", + "\u039d\u03bf\u03ad", + "\u0394\u03b5\u03ba", + "", + } + }, + { "MonthNarrows", + new String[] { + "\u0399", + "\u03a6", + "\u039c", + "\u0391", + "\u039c", + "\u0399", + "\u0399", + "\u0391", + "\u03a3", + "\u039f", + "\u039d", + "\u0394", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "\u0399", + "\u03a6", + "\u039c", + "\u0391", + "\u039c", + "\u0399", + "\u0399", + "\u0391", + "\u03a3", + "\u039f", + "\u039d", + "\u0394", + "", + } + }, { "DayNames", new String[] { "\u039a\u03c5\u03c1\u03b9\u03b1\u03ba\u03ae", // Sunday @@ -154,6 +205,17 @@ public class FormatData_el extends ListResourceBundle { "\u03a3\u03ac\u03b2\u03b2\u03b1\u03c4\u03bf" // Saturday } }, + { "standalone.DayNames", + new String[] { + "\u039a\u03c5\u03c1\u03b9\u03b1\u03ba\u03ae", + "\u0394\u03b5\u03c5\u03c4\u03ad\u03c1\u03b1", + "\u03a4\u03c1\u03af\u03c4\u03b7", + "\u03a4\u03b5\u03c4\u03ac\u03c1\u03c4\u03b7", + "\u03a0\u03ad\u03bc\u03c0\u03c4\u03b7", + "\u03a0\u03b1\u03c1\u03b1\u03c3\u03ba\u03b5\u03c5\u03ae", + "\u03a3\u03ac\u03b2\u03b2\u03b1\u03c4\u03bf", + } + }, { "DayAbbreviations", new String[] { "\u039a\u03c5\u03c1", // abb Sunday @@ -165,6 +227,17 @@ public class FormatData_el extends ListResourceBundle { "\u03a3\u03b1\u03b2" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "\u039a\u03c5\u03c1", + "\u0394\u03b5\u03c5", + "\u03a4\u03c1\u03af", + "\u03a4\u03b5\u03c4", + "\u03a0\u03ad\u03bc", + "\u03a0\u03b1\u03c1", + "\u03a3\u03ac\u03b2", + } + }, { "DayNarrows", new String[] { "\u039a", @@ -176,6 +249,23 @@ public class FormatData_el extends ListResourceBundle { "\u03a3", } }, + { "standalone.DayNarrows", + new String[] { + "\u039a", + "\u0394", + "\u03a4", + "\u03a4", + "\u03a0", + "\u03a0", + "\u03a3", + } + }, + { "short.Eras", + new String[] { + "\u03c0.\u03a7.", + "\u03bc.\u03a7.", + } + }, { "AmPmMarkers", new String[] { "\u03c0\u03bc", // am marker @@ -219,58 +309,6 @@ public class FormatData_el extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM, y G", - "d/M/yyyy", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM, y G", - "d/M/yy", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM, y G", - "d/M/y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d MMMM, y GGGG", - "d MMMM, y GGGG", - "d MMM, y GGGG", - "d/M/y GGGG", - } - }, - { "calendarname.islamic-civil", "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.islamicc", "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.islamic", "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.japanese", "\u0399\u03b1\u03c0\u03c9\u03bd\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.gregorian", "\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.gregory", "\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "calendarname.roc", "\u0397\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf \u03c4\u03b7\u03c2 \u0394\u03b7\u03bc\u03bf\u03ba\u03c1\u03b1\u03c4\u03af\u03b1\u03c2 \u03c4\u03b7\u03c2 \u039a\u03af\u03bd\u03b1\u03c2" }, - { "calendarname.buddhist", "\u0392\u03bf\u03c5\u03b4\u03b9\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, - { "field.era", "\u03a0\u03b5\u03c1\u03af\u03bf\u03b4\u03bf\u03c2" }, - { "field.year", "\u0388\u03c4\u03bf\u03c2" }, - { "field.month", "\u039c\u03ae\u03bd\u03b1\u03c2" }, - { "field.week", "\u0395\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1" }, - { "field.weekday", "\u0397\u03bc\u03ad\u03c1\u03b1 \u03b5\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1\u03c2" }, - { "field.dayperiod", "\u03c0.\u03bc./\u03bc.\u03bc." }, - { "field.hour", "\u038f\u03c1\u03b1" }, - { "field.minute", "\u039b\u03b5\u03c0\u03c4\u03cc" }, - { "field.second", "\u0394\u03b5\u03c5\u03c4\u03b5\u03c1\u03cc\u03bb\u03b5\u03c0\u03c4\u03bf" }, - { "field.zone", "\u0396\u03ce\u03bd\u03b7" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/el/FormatData_el_CY.java b/jdk/src/share/classes/sun/text/resources/el/FormatData_el_CY.java index 9835e129518..364ffa8b602 100644 --- a/jdk/src/share/classes/sun/text/resources/el/FormatData_el_CY.java +++ b/jdk/src/share/classes/sun/text/resources/el/FormatData_el_CY.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.el; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_el_CY extends ListResourceBundle { +public class FormatData_el_CY extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", diff --git a/jdk/src/share/classes/sun/text/resources/el/FormatData_el_GR.java b/jdk/src/share/classes/sun/text/resources/el/FormatData_el_GR.java index 2ea3cbee9a7..af8bb882aee 100644 --- a/jdk/src/share/classes/sun/text/resources/el/FormatData_el_GR.java +++ b/jdk/src/share/classes/sun/text/resources/el/FormatData_el_GR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.el; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_el_GR extends ListResourceBundle { +public class FormatData_el_GR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/el/JavaTimeSupplementary_el.java b/jdk/src/share/classes/sun/text/resources/el/JavaTimeSupplementary_el.java new file mode 100644 index 00000000000..2b798c0a98b --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/el/JavaTimeSupplementary_el.java @@ -0,0 +1,184 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.el; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_el extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "\u03a41", + "\u03a42", + "\u03a43", + "\u03a44", + } + }, + { "QuarterNames", + new String[] { + "1\u03bf \u03c4\u03c1\u03af\u03bc\u03b7\u03bd\u03bf", + "2\u03bf \u03c4\u03c1\u03af\u03bc\u03b7\u03bd\u03bf", + "3\u03bf \u03c4\u03c1\u03af\u03bc\u03b7\u03bd\u03bf", + "4\u03bf \u03c4\u03c1\u03af\u03bc\u03b7\u03bd\u03bf", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u0392\u03bf\u03c5\u03b4\u03b9\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.gregorian", + "\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.gregory", + "\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.islamic", + "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.islamic-civil", + "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.islamicc", + "\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.japanese", + "\u0399\u03b1\u03c0\u03c9\u03bd\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf" }, + { "calendarname.roc", + "\u0397\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf \u03c4\u03b7\u03c2 \u0394\u03b7\u03bc\u03bf\u03ba\u03c1\u03b1\u03c4\u03af\u03b1\u03c2 \u03c4\u03b7\u03c2 \u039a\u03af\u03bd\u03b1\u03c2" }, + { "field.dayperiod", + "\u03c0.\u03bc./\u03bc.\u03bc." }, + { "field.era", + "\u03a0\u03b5\u03c1\u03af\u03bf\u03b4\u03bf\u03c2" }, + { "field.hour", + "\u038f\u03c1\u03b1" }, + { "field.minute", + "\u039b\u03b5\u03c0\u03c4\u03cc" }, + { "field.month", + "\u039c\u03ae\u03bd\u03b1\u03c2" }, + { "field.second", + "\u0394\u03b5\u03c5\u03c4\u03b5\u03c1\u03cc\u03bb\u03b5\u03c0\u03c4\u03bf" }, + { "field.week", + "\u0395\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1" }, + { "field.weekday", + "\u0397\u03bc\u03ad\u03c1\u03b1 \u03b5\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1\u03c2" }, + { "field.year", + "\u0388\u03c4\u03bf\u03c2" }, + { "field.zone", + "\u0396\u03ce\u03bd\u03b7" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/yyyy", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/yy", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/y G", + } + }, + { "java.time.short.Eras", + new String[] { + "\u03c0.\u03a7.", + "\u03bc.\u03a7.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y GGGG", + "d MMMM, y GGGG", + "d MMM, y GGGG", + "d/M/y GGGG", + } + }, + { "roc.Eras", + new String[] { + "\u03a0\u03c1\u03b9\u03bd R.O.C.", + "R.O.C.", + } + }, + { "roc.short.Eras", + new String[] { + "\u03a0\u03c1\u03b9\u03bd R.O.C.", + "R.O.C.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en.java index 881753051df..d51c9f3ce5b 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en extends ListResourceBundle { +public class FormatData_en extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { // This locale inherits almost everything from the root default locale. However, diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_AU.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_AU.java index bfebc8e6cca..e0d8802ac85 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_AU.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_AU.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_AU extends ListResourceBundle { +public class FormatData_en_AU extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_CA.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_CA.java index eb06b7d926a..e94ed48ea0a 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_CA.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_CA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_CA extends ListResourceBundle { +public class FormatData_en_CA extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_GB.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_GB.java index 3360d08f8f6..4666fc955ff 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_GB.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_GB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_GB extends ListResourceBundle { +public class FormatData_en_GB extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_IE.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_IE.java index b2734e31358..bef5bde72c3 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_IE.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_IE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_IE extends ListResourceBundle { +public class FormatData_en_IE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_IN.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_IN.java index 99aeb4c8977..4bc7ea9f784 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_IN.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_IN.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -31,16 +31,16 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; /** * The locale elements for English in India. * */ -public class FormatData_en_IN extends ListResourceBundle { +public class FormatData_en_IN extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_MT.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_MT.java index aeb413b2e38..55c353a7034 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_MT.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_MT.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_MT extends ListResourceBundle { +public class FormatData_en_MT extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_NZ.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_NZ.java index 6fbfd5ec870..c7e4bc5fcec 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_NZ.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_NZ.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_NZ extends ListResourceBundle { +public class FormatData_en_NZ extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_PH.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_PH.java index 5e6b4796611..2f0b90bcfd4 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_PH.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_PH.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_PH extends ListResourceBundle { +public class FormatData_en_PH extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_SG.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_SG.java index 35b85bce33f..c46c7652eca 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_SG.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_SG.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_SG extends ListResourceBundle { +public class FormatData_en_SG extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_US.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_US.java index 6c8f6527bd3..b4dceac5041 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_US.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_US.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_US extends ListResourceBundle { +public class FormatData_en_US extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_ZA.java b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_ZA.java index 73620eaf1a8..b6298db6f0c 100644 --- a/jdk/src/share/classes/sun/text/resources/en/FormatData_en_ZA.java +++ b/jdk/src/share/classes/sun/text/resources/en/FormatData_en_ZA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.en; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_en_ZA extends ListResourceBundle { +public class FormatData_en_ZA extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en.java b/jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en.java new file mode 100644 index 00000000000..e7650b3e701 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en.java @@ -0,0 +1,186 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.en; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_en extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1st quarter", + "2nd quarter", + "3rd quarter", + "4th quarter", + } + }, + { "calendarname.buddhist", + "Buddhist Calendar" }, + { "calendarname.gregorian", + "Gregorian Calendar" }, + { "calendarname.gregory", + "Gregorian Calendar" }, + { "calendarname.islamic", + "Islamic Calendar" }, + { "calendarname.islamic-civil", + "Islamic-Civil Calendar" }, + { "calendarname.islamicc", + "Islamic-Civil Calendar" }, + { "calendarname.japanese", + "Japanese Calendar" }, + { "calendarname.roc", + "Minguo Calendar" }, + { "field.dayperiod", + "AM/PM" }, + { "field.era", + "Era" }, + { "field.hour", + "Hour" }, + { "field.minute", + "Minute" }, + { "field.month", + "Month" }, + { "field.second", + "Second" }, + { "field.week", + "Week" }, + { "field.weekday", + "Day of the Week" }, + { "field.year", + "Year" }, + { "field.zone", + "Time Zone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, MMMM d, y GGGG", + "MMMM d, y GGGG", + "MMM d, y GGGG", + "M/d/yy GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy GGGGG", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "Before Christ", + "Anno Domini", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "BC", + "AD", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, MMMM d, y GGGG", + "MMMM d, y GGGG", + "MMM d, y GGGG", + "M/d/yy G", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en_GB.java b/jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en_GB.java new file mode 100644 index 00000000000..231c2ccde08 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en_GB.java @@ -0,0 +1,122 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.en; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_en_GB extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "dd/MM/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd/MM/y G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd/MM/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd/MM/y GGGGG", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd/MM/y GGGGG", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "dd/MM/y G", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en_SG.java b/jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en_SG.java new file mode 100644 index 00000000000..e413fc0a20d --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/en/JavaTimeSupplementary_en_SG.java @@ -0,0 +1,106 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.en; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_en_SG extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/yy GGGGG", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/yy GGGGG", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM, y G", + "d/M/yy GGGGG", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y GGGG", + "d MMMM, y GGGG", + "d MMM, y GGGG", + "d/M/yy G", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es.java index 7ea5b998221..abb1607282b 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es.java @@ -76,11 +76,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es extends ListResourceBundle { +public class FormatData_es extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ public class FormatData_es extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "E", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "domingo", // Sunday @@ -151,6 +168,18 @@ public class FormatData_es extends ListResourceBundle { "S", } }, + { "Eras", + new String[] { + "antes de Cristo", + "anno D\u00f3mini", + } + }, + { "short.Eras", + new String[] { + "a.C.", + "d.C.", + } + }, { "NumberPatterns", new String[] { "#,##0.###;-#,##0.###", // decimal pattern @@ -195,72 +224,6 @@ public class FormatData_es extends ListResourceBundle { } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/y G", - "dd/MM/y G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/y G", - "dd/MM/y GGGGG", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/y G", - "dd/MM/y GGGGG", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y GGGG", - "d 'de' MMMM 'de' y GGGG", - "dd/MM/y GGGG", - "dd/MM/y G", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/y G", - "dd/MM/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y GGGG", - "d 'de' MMMM 'de' y GGGG", - "dd/MM/y GGGG", - "dd/MM/y GGGG", - } - }, - { "calendarname.islamic-civil", "calendario civil isl\u00e1mico" }, - { "calendarname.islamicc", "calendario civil isl\u00e1mico" }, - { "calendarname.islamic", "calendario isl\u00e1mico" }, - { "calendarname.japanese", "calendario japon\u00e9s" }, - { "calendarname.gregorian", "calendario gregoriano" }, - { "calendarname.gregory", "calendario gregoriano" }, - { "calendarname.roc", "calendario de la Rep\u00fablica de China" }, - { "calendarname.buddhist", "calendario budista" }, - { "field.era", "era" }, - { "field.year", "a\u00f1o" }, - { "field.month", "mes" }, - { "field.week", "semana" }, - { "field.weekday", "d\u00eda de la semana" }, - { "field.dayperiod", "periodo del d\u00eda" }, - { "field.hour", "hora" }, - { "field.minute", "minuto" }, - { "field.second", "segundo" }, - { "field.zone", "zona" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_AR.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_AR.java index 9a29d322709..cdebbc30bb0 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_AR.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_AR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_AR extends ListResourceBundle { +public class FormatData_es_AR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_BO.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_BO.java index bef286bc178..a6777a954a1 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_BO.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_BO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_BO extends ListResourceBundle { +public class FormatData_es_BO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CL.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CL.java index 37fe4dfe5be..87805df3a97 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CL.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_CL extends ListResourceBundle { +public class FormatData_es_CL extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CO.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CO.java index 2c12d0cefeb..ff5ab5b367f 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CO.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_CO extends ListResourceBundle { +public class FormatData_es_CO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CR.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CR.java index 2cac9a2354d..b33b68561d1 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CR.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_CR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_CR extends ListResourceBundle { +public class FormatData_es_CR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_DO.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_DO.java index 7ce3269676c..c8f1345b29d 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_DO.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_DO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_DO extends ListResourceBundle { +public class FormatData_es_DO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_EC.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_EC.java index c17e649a96d..a5283df03f8 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_EC.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_EC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_EC extends ListResourceBundle { +public class FormatData_es_EC extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_ES.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_ES.java index 06d4b30c164..15ad162b56e 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_ES.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_ES.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_ES extends ListResourceBundle { +public class FormatData_es_ES extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_GT.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_GT.java index dafe2846bf5..8e868b3f280 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_GT.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_GT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_GT extends ListResourceBundle { +public class FormatData_es_GT extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_HN.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_HN.java index 667eceb844b..3ddb5fca48d 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_HN.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_HN.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_HN extends ListResourceBundle { +public class FormatData_es_HN extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_MX.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_MX.java index c63084dd4b1..19864b4c173 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_MX.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_MX.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_MX extends ListResourceBundle { +public class FormatData_es_MX extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_NI.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_NI.java index 3d210e6646d..f11f80de1cd 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_NI.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_NI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_NI extends ListResourceBundle { +public class FormatData_es_NI extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PA.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PA.java index 51e67086562..c149ba9f254 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PA.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_PA extends ListResourceBundle { +public class FormatData_es_PA extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PE.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PE.java index 2913a43d443..afa72f032eb 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PE.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_PE extends ListResourceBundle { +public class FormatData_es_PE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PR.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PR.java index 7440f2e5abc..f15271f83a4 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PR.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_PR extends ListResourceBundle { +public class FormatData_es_PR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PY.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PY.java index 7ab5dce4ed2..8b9b3bf595c 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PY.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_PY.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_PY extends ListResourceBundle { +public class FormatData_es_PY extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_SV.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_SV.java index 9d9e946e704..ae98bf88ddf 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_SV.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_SV.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_SV extends ListResourceBundle { +public class FormatData_es_SV extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_US.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_US.java index fb8d11d5cc5..339d3adc755 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_US.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_US.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_US extends ListResourceBundle { +public class FormatData_es_US extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "AmPmMarkers", diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_UY.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_UY.java index 919245567f7..c2a4e7b1ce4 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_UY.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_UY.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_UY extends ListResourceBundle { +public class FormatData_es_UY extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_VE.java b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_VE.java index 4bfececf2ed..507cc83cbaf 100644 --- a/jdk/src/share/classes/sun/text/resources/es/FormatData_es_VE.java +++ b/jdk/src/share/classes/sun/text/resources/es/FormatData_es_VE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.es; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_es_VE extends ListResourceBundle { +public class FormatData_es_VE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/es/JavaTimeSupplementary_es.java b/jdk/src/share/classes/sun/text/resources/es/JavaTimeSupplementary_es.java new file mode 100644 index 00000000000..002cb91e3f5 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/es/JavaTimeSupplementary_es.java @@ -0,0 +1,206 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.es; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_es extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "T1", + "T2", + "T3", + "T4", + } + }, + { "QuarterNames", + new String[] { + "1er trimestre", + "2\u00ba trimestre", + "3er trimestre", + "4\u00ba trimestre", + } + }, + { "QuarterNarrows", + new String[] { + "1T", + "2T", + "3T", + "4T", + } + }, + { "calendarname.buddhist", + "calendario budista" }, + { "calendarname.gregorian", + "calendario gregoriano" }, + { "calendarname.gregory", + "calendario gregoriano" }, + { "calendarname.islamic", + "calendario isl\u00e1mico" }, + { "calendarname.islamic-civil", + "calendario civil isl\u00e1mico" }, + { "calendarname.islamicc", + "calendario civil isl\u00e1mico" }, + { "calendarname.japanese", + "calendario japon\u00e9s" }, + { "calendarname.roc", + "calendario de la Rep\u00fablica de China" }, + { "field.dayperiod", + "periodo del d\u00eda" }, + { "field.era", + "era" }, + { "field.hour", + "hora" }, + { "field.minute", + "minuto" }, + { "field.month", + "mes" }, + { "field.second", + "segundo" }, + { "field.week", + "semana" }, + { "field.weekday", + "d\u00eda de la semana" }, + { "field.year", + "a\u00f1o" }, + { "field.zone", + "zona" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/y GGGG", + "dd/MM/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/y G", + "dd/MM/y G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/y G", + "dd/MM/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/y G", + "dd/MM/y GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "antes de Cristo", + "anno D\u00f3mini", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/y G", + "dd/MM/y GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "antes de Cristo", + "anno D\u00f3mini", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/y GGGG", + "dd/MM/y G", + } + }, + { "roc.Eras", + new String[] { + "antes de R.O.C.", + "", + } + }, + { "roc.short.Eras", + new String[] { + "antes de R.O.C.", + "", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/et/FormatData_et.java b/jdk/src/share/classes/sun/text/resources/et/FormatData_et.java index a68a22fc464..b7f70d02377 100644 --- a/jdk/src/share/classes/sun/text/resources/et/FormatData_et.java +++ b/jdk/src/share/classes/sun/text/resources/et/FormatData_et.java @@ -76,11 +76,11 @@ package sun.text.resources.et; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_et extends ListResourceBundle { +public class FormatData_et extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ public class FormatData_et extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "V", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "p\u00fchap\u00e4ev", // Sunday @@ -157,6 +174,12 @@ public class FormatData_et extends ListResourceBundle { "m.a.j." } }, + { "short.Eras", + new String[] { + "e.m.a.", + "m.a.j.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -193,25 +216,6 @@ public class FormatData_et extends ListResourceBundle { "{1} {0}" // date-time pattern } }, - { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "calendarname.islamic-civil", "islami ilmalik kalender" }, - { "calendarname.islamicc", "islami ilmalik kalender" }, - { "calendarname.roc", "Hiina Vabariigi kalender" }, - { "calendarname.islamic", "islamikalender" }, - { "calendarname.buddhist", "budistlik kalender" }, - { "calendarname.japanese", "Jaapani kalender" }, - { "calendarname.gregorian", "Gregoriuse kalender" }, - { "calendarname.gregory", "Gregoriuse kalender" }, - { "field.era", "ajastu" }, - { "field.year", "aasta" }, - { "field.month", "kuu" }, - { "field.week", "n\u00e4dal" }, - { "field.weekday", "n\u00e4dalap\u00e4ev" }, - { "field.dayperiod", "enne/p\u00e4rast l\u00f5unat" }, - { "field.hour", "tund" }, - { "field.minute", "minut" }, - { "field.second", "sekund" }, - { "field.zone", "v\u00f6\u00f6nd" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/et/FormatData_et_EE.java b/jdk/src/share/classes/sun/text/resources/et/FormatData_et_EE.java index 602c92a5681..d6bffb985e3 100644 --- a/jdk/src/share/classes/sun/text/resources/et/FormatData_et_EE.java +++ b/jdk/src/share/classes/sun/text/resources/et/FormatData_et_EE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.et; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_et_EE extends ListResourceBundle { +public class FormatData_et_EE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/et/JavaTimeSupplementary_et.java b/jdk/src/share/classes/sun/text/resources/et/JavaTimeSupplementary_et.java new file mode 100644 index 00000000000..2c28fdb3a62 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/et/JavaTimeSupplementary_et.java @@ -0,0 +1,146 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.et; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_et extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "1. kvartal", + "2. kvartal", + "3. kvartal", + "4. kvartal", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "budistlik kalender" }, + { "calendarname.gregorian", + "Gregoriuse kalender" }, + { "calendarname.gregory", + "Gregoriuse kalender" }, + { "calendarname.islamic", + "islamikalender" }, + { "calendarname.islamic-civil", + "islami ilmalik kalender" }, + { "calendarname.islamicc", + "islami ilmalik kalender" }, + { "calendarname.japanese", + "Jaapani kalender" }, + { "calendarname.roc", + "Hiina Vabariigi kalender" }, + { "field.dayperiod", + "enne/p\u00e4rast l\u00f5unat" }, + { "field.era", + "ajastu" }, + { "field.hour", + "tund" }, + { "field.minute", + "minut" }, + { "field.month", + "kuu" }, + { "field.second", + "sekund" }, + { "field.week", + "n\u00e4dal" }, + { "field.weekday", + "n\u00e4dalap\u00e4ev" }, + { "field.year", + "aasta" }, + { "field.zone", + "v\u00f6\u00f6nd" }, + { "java.time.long.Eras", + new String[] { + "enne meie aega", + "meie aja j\u00e4rgi", + } + }, + { "java.time.short.Eras", + new String[] { + "e.m.a.", + "m.a.j.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi.java b/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi.java index a7b77a7e425..f80df887abf 100644 --- a/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi.java +++ b/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi.java @@ -76,11 +76,11 @@ package sun.text.resources.fi; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fi extends ListResourceBundle { +public class FormatData_fi extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -152,6 +152,23 @@ public class FormatData_fi extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "T", + "H", + "M", + "H", + "T", + "K", + "H", + "E", + "S", + "L", + "M", + "J", + "", + } + }, { "standalone.MonthNarrows", new String[] { "T", @@ -169,6 +186,24 @@ public class FormatData_fi extends ListResourceBundle { "", } }, + { "long.Eras", + new String[] { + "ennen Kristuksen syntym\u00e4\u00e4", + "j\u00e4lkeen Kristuksen syntym\u00e4n", + } + }, + { "Eras", + new String[] { + "eKr.", + "jKr.", + } + }, + { "narrow.Eras", + new String[] { + "eK", + "jK", + } + }, { "DayNames", new String[] { "sunnuntai", // Sunday @@ -180,6 +215,17 @@ public class FormatData_fi extends ListResourceBundle { "lauantai" // Saturday } }, + { "standalone.DayNames", + new String[] { + "sunnuntai", + "maanantai", + "tiistai", + "keskiviikko", + "torstai", + "perjantai", + "lauantai", + } + }, { "DayAbbreviations", new String[] { "su", // abb Sunday @@ -191,6 +237,17 @@ public class FormatData_fi extends ListResourceBundle { "la" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "su", + "ma", + "ti", + "ke", + "to", + "pe", + "la", + } + }, { "DayNarrows", new String[] { "S", @@ -236,14 +293,6 @@ public class FormatData_fi extends ListResourceBundle { "H:mm", // short time pattern } }, - { "cldr.DatePatterns", - new String[] { - "cccc, d. MMMM y", - "d. MMMM y", - "d.M.yyyy", - "d.M.yyyy", - } - }, { "DatePatterns", new String[] { "d. MMMM'ta 'yyyy", // full date pattern @@ -270,89 +319,6 @@ public class FormatData_fi extends ListResourceBundle { "ip.", } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "cccc d. MMMM y G", - "d. MMMM y G", - "d.M.y G", - "d.M.y G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "cccc d. MMMM y G", - "d. MMMM y G", - "d.M.y G", - "d.M.y G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "cccc d. MMMM y G", - "d. MMMM y G", - "d.M.y G", - "d.M.y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d.M.y GGGG", - "d.M.y GGGG", - } - }, - { "islamic.MonthNames", - new String[] { - "muharram", - "safar", - "rabi\u2019 al-awwal", - "rabi\u2019 al-akhir", - "d\u017eumada-l-ula", - "d\u017eumada-l-akhira", - "rad\u017eab", - "\u0161a\u2019ban", - "ramadan", - "\u0161awwal", - "dhu-l-qa\u2019da", - "dhu-l-hidd\u017ea", - "", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "cccc d. MMMM y G", - "d. MMMM y G", - "d.M.y G", - "d.M.y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d. MMMM y GGGG", - "d. MMMM y GGGG", - "d.M.y GGGG", - "d.M.y GGGG", - } - }, - { "calendarname.islamic-civil", "islamilainen siviilikalenteri" }, - { "calendarname.islamicc", "islamilainen siviilikalenteri" }, - { "calendarname.islamic", "islamilainen kalenteri" }, - { "calendarname.japanese", "japanilainen kalenteri" }, - { "calendarname.gregorian", "gregoriaaninen kalenteri" }, - { "calendarname.gregory", "gregoriaaninen kalenteri" }, - { "calendarname.roc", "Kiinan tasavallan kalenteri" }, - { "calendarname.buddhist", "buddhalainen kalenteri" }, - { "field.era", "aikakausi" }, - { "field.year", "vuosi" }, - { "field.month", "kuukausi" }, - { "field.week", "viikko" }, - { "field.weekday", "viikonp\u00e4iv\u00e4" }, - { "field.dayperiod", "vuorokaudenaika" }, - { "field.hour", "tunti" }, - { "field.minute", "minuutti" }, - { "field.second", "sekunti" }, - { "field.zone", "aikavy\u00f6hyke" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi_FI.java b/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi_FI.java index 335644d8885..ad2be2ca6e9 100644 --- a/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi_FI.java +++ b/jdk/src/share/classes/sun/text/resources/fi/FormatData_fi_FI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.fi; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fi_FI extends ListResourceBundle { +public class FormatData_fi_FI extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/fi/JavaTimeSupplementary_fi.java b/jdk/src/share/classes/sun/text/resources/fi/JavaTimeSupplementary_fi.java new file mode 100644 index 00000000000..e55d5950759 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/fi/JavaTimeSupplementary_fi.java @@ -0,0 +1,219 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.fi; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_fi extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1. nelj.", + "2. nelj.", + "3. nelj.", + "4. nelj.", + } + }, + { "QuarterNames", + new String[] { + "1. nelj\u00e4nnes", + "2. nelj\u00e4nnes", + "3. nelj\u00e4nnes", + "4. nelj\u00e4nnes", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "buddhalainen kalenteri" }, + { "calendarname.gregorian", + "gregoriaaninen kalenteri" }, + { "calendarname.gregory", + "gregoriaaninen kalenteri" }, + { "calendarname.islamic", + "islamilainen kalenteri" }, + { "calendarname.islamic-civil", + "islamilainen siviilikalenteri" }, + { "calendarname.islamicc", + "islamilainen siviilikalenteri" }, + { "calendarname.japanese", + "japanilainen kalenteri" }, + { "calendarname.roc", + "Kiinan tasavallan kalenteri" }, + { "field.dayperiod", + "vuorokaudenaika" }, + { "field.era", + "aikakausi" }, + { "field.hour", + "tunti" }, + { "field.minute", + "minuutti" }, + { "field.month", + "kuukausi" }, + { "field.second", + "sekunti" }, + { "field.week", + "viikko" }, + { "field.weekday", + "viikonp\u00e4iv\u00e4" }, + { "field.year", + "vuosi" }, + { "field.zone", + "aikavy\u00f6hyke" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d.M.y GGGG", + "d.M.y GGGG", + } + }, + { "islamic.MonthNames", + new String[] { + "muharram", + "safar", + "rabi\u2019 al-awwal", + "rabi\u2019 al-akhir", + "d\u017eumada-l-ula", + "d\u017eumada-l-akhira", + "rad\u017eab", + "\u0161a\u2019ban", + "ramadan", + "\u0161awwal", + "dhu-l-qa\u2019da", + "dhu-l-hidd\u017ea", + "", + } + }, + { "java.time.DatePatterns", + new String[] { + "cccc, d. MMMM y", + "d. MMMM y", + "d.M.yyyy", + "d.M.yyyy", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "cccc d. MMMM y G", + "d. MMMM y G", + "d.M.y G", + "d.M.y G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "cccc d. MMMM y G", + "d. MMMM y G", + "d.M.y G", + "d.M.y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "cccc d. MMMM y G", + "d. MMMM y G", + "d.M.y G", + "d.M.y G", + } + }, + { "java.time.long.Eras", + new String[] { + "ennen Kristuksen syntym\u00e4\u00e4", + "j\u00e4lkeen Kristuksen syntym\u00e4n", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "cccc d. MMMM y G", + "d. MMMM y G", + "d.M.y G", + "d.M.y G", + } + }, + { "java.time.short.Eras", + new String[] { + "eKr.", + "jKr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d.M.y GGGG", + "d.M.y GGGG", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr.java b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr.java index ec3493700b7..7feee171002 100644 --- a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr.java +++ b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr.java @@ -76,11 +76,11 @@ package sun.text.resources.fr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fr extends ListResourceBundle { +public class FormatData_fr extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ public class FormatData_fr extends ListResourceBundle { "" // abb mo month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "dimanche", // Sunday @@ -140,6 +157,17 @@ public class FormatData_fr extends ListResourceBundle { "sam." // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "dim.", + "lun.", + "mar.", + "mer.", + "jeu.", + "ven.", + "sam.", + } + }, { "DayNarrows", new String[] { "D", @@ -157,6 +185,30 @@ public class FormatData_fr extends ListResourceBundle { "ap. J.-C." } }, + { "short.Eras", + new String[] { + "av. J.-C.", + "ap. J.-C.", + } + }, + { "buddhist.Eras", + new String[] { + "BC", + "\u00e8re bouddhiste", + } + }, + { "buddhist.short.Eras", + new String[] { + "BC", + "\u00e8re b.", + } + }, + { "buddhist.narrow.Eras", + new String[] { + "BC", + "E.B.", + } + }, { "NumberPatterns", new String[] { "#,##0.###;-#,##0.###", // decimal pattern @@ -201,112 +253,6 @@ public class FormatData_fr extends ListResourceBundle { } }, { "DateTimePatternChars", "GaMjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM, y G", - "d/M/yyyy", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM, y G", - "d/M/y GGGGG", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM, y G", - "d/M/y GGGGG", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM, y GGGG", - "d/M/y G", - } - }, - { "islamic.MonthNames", - new String[] { - "Mouharram", - "Safar", - "Rabi\u02bb-oul-Aououal", - "Rabi\u02bb-out-Tani", - "Djoumada-l-Oula", - "Djoumada-t-Tania", - "Radjab", - "Cha\u02bbban", - "Ramadan", - "Chaououal", - "Dou-l-Qa\u02bbda", - "Dou-l-Hidjja", - "", - } - }, - { "islamic.MonthAbbreviations", - new String[] { - "Mouh.", - "Saf.", - "Rabi\u02bb-oul-A.", - "Rabi\u02bb-out-T.", - "Djoum.-l-O.", - "Djoum.-t-T.", - "Radj.", - "Cha.", - "Ram.", - "Chaou.", - "Dou-l-Q.", - "Dou-l-H.", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "AH", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM, y G", - "d/M/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM, y GGGG", - "d/M/y GGGG", - } - }, - { "calendarname.islamic-civil", "Calendrier civil musulman" }, - { "calendarname.islamicc", "Calendrier civil musulman" }, - { "calendarname.islamic", "Calendrier musulman" }, - { "calendarname.japanese", "Calendrier japonais" }, - { "calendarname.gregorian", "Calendrier gr\u00e9gorien" }, - { "calendarname.gregory", "Calendrier gr\u00e9gorien" }, - { "calendarname.roc", "Calendrier r\u00e9publicain chinois" }, - { "calendarname.buddhist", "Calendrier bouddhiste" }, - { "field.era", "\u00e8re" }, - { "field.year", "ann\u00e9e" }, - { "field.month", "mois" }, - { "field.week", "semaine" }, - { "field.weekday", "jour de la semaine" }, - { "field.dayperiod", "cadran" }, - { "field.hour", "heure" }, - { "field.minute", "minute" }, - { "field.second", "seconde" }, - { "field.zone", "fuseau horaire" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_BE.java b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_BE.java index ce21b2c6750..8e7a542c9d1 100644 --- a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_BE.java +++ b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_BE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -40,11 +40,11 @@ package sun.text.resources.fr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fr_BE extends ListResourceBundle { +public class FormatData_fr_BE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_CA.java b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_CA.java index be4e105832b..dd99afcfa88 100644 --- a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_CA.java +++ b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_CA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -40,11 +40,11 @@ package sun.text.resources.fr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fr_CA extends ListResourceBundle { +public class FormatData_fr_CA extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_CH.java b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_CH.java index ca5397eb0d8..f8cdcf1d85c 100644 --- a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_CH.java +++ b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_CH.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -40,11 +40,11 @@ package sun.text.resources.fr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fr_CH extends ListResourceBundle { +public class FormatData_fr_CH extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_FR.java b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_FR.java index b9e43b559b6..09a8794d4ab 100644 --- a/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_FR.java +++ b/jdk/src/share/classes/sun/text/resources/fr/FormatData_fr_FR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.fr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_fr_FR extends ListResourceBundle { +public class FormatData_fr_FR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/fr/JavaTimeSupplementary_fr.java b/jdk/src/share/classes/sun/text/resources/fr/JavaTimeSupplementary_fr.java new file mode 100644 index 00000000000..bc7c9d7fa1d --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/fr/JavaTimeSupplementary_fr.java @@ -0,0 +1,264 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.fr; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_fr extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "T1", + "T2", + "T3", + "T4", + } + }, + { "QuarterNames", + new String[] { + "1er trimestre", + "2e trimestre", + "3e trimestre", + "4e trimestre", + } + }, + { "QuarterNarrows", + new String[] { + "T1", + "T2", + "T3", + "T4", + } + }, + { "calendarname.buddhist", + "Calendrier bouddhiste" }, + { "calendarname.gregorian", + "Calendrier gr\u00e9gorien" }, + { "calendarname.gregory", + "Calendrier gr\u00e9gorien" }, + { "calendarname.islamic", + "Calendrier musulman" }, + { "calendarname.islamic-civil", + "Calendrier civil musulman" }, + { "calendarname.islamicc", + "Calendrier civil musulman" }, + { "calendarname.japanese", + "Calendrier japonais" }, + { "calendarname.roc", + "Calendrier r\u00e9publicain chinois" }, + { "field.dayperiod", + "cadran" }, + { "field.era", + "\u00e8re" }, + { "field.hour", + "heure" }, + { "field.minute", + "minute" }, + { "field.month", + "mois" }, + { "field.second", + "seconde" }, + { "field.week", + "semaine" }, + { "field.weekday", + "jour de la semaine" }, + { "field.year", + "ann\u00e9e" }, + { "field.zone", + "fuseau horaire" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM, y GGGG", + "d/M/y GGGG", + } + }, + { "islamic.Eras", + new String[] { + "", + "AH", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "Mouh.", + "Saf.", + "Rabi\u02bb-oul-A.", + "Rabi\u02bb-out-T.", + "Djoum.-l-O.", + "Djoum.-t-T.", + "Radj.", + "Cha.", + "Ram.", + "Chaou.", + "Dou-l-Q.", + "Dou-l-H.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Mouharram", + "Safar", + "Rabi\u02bb-oul-Aououal", + "Rabi\u02bb-out-Tani", + "Djoumada-l-Oula", + "Djoumada-t-Tania", + "Radjab", + "Cha\u02bbban", + "Ramadan", + "Chaououal", + "Dou-l-Qa\u02bbda", + "Dou-l-Hidjja", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "AH", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM, y G", + "d/M/yyyy", + } + }, + { "java.time.buddhist.long.Eras", + new String[] { + "BC", + "\u00e8re bouddhiste", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\u00e8re bouddhiste", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM, y G", + "d/M/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM, y G", + "d/M/y GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "avant J\u00e9sus-Christ", + "apr\u00e8s J\u00e9sus-Christ", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM, y G", + "d/M/y GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "BC", + "ap. J.-C.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM, y GGGG", + "d/M/y G", + } + }, + { "roc.Eras", + new String[] { + "avant RdC", + "RdC", + } + }, + { "roc.short.Eras", + new String[] { + "avant RdC", + "RdC", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/ga/FormatData_ga.java b/jdk/src/share/classes/sun/text/resources/ga/FormatData_ga.java index f778affdbc2..fea8a7d1e1b 100644 --- a/jdk/src/share/classes/sun/text/resources/ga/FormatData_ga.java +++ b/jdk/src/share/classes/sun/text/resources/ga/FormatData_ga.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.ga; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ga extends ListResourceBundle { +public class FormatData_ga extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", @@ -81,6 +100,23 @@ public class FormatData_ga extends ListResourceBundle { "", } }, + { "MonthNarrows", + new String[] { + "E", + "F", + "M", + "A", + "B", + "M", + "I", + "L", + "M", + "D", + "S", + "N", + "", + } + }, { "DayNames", new String[] { "D\u00e9 Domhnaigh", @@ -115,6 +151,12 @@ public class FormatData_ga extends ListResourceBundle { "AD", } }, + { "short.Eras", + new String[] { + "RC", + "AD", + } + }, { "NumberPatterns", new String[] { "#,##0.###", diff --git a/jdk/src/share/classes/sun/text/resources/ga/FormatData_ga_IE.java b/jdk/src/share/classes/sun/text/resources/ga/FormatData_ga_IE.java index 2109c0dabfa..993f6fa5b42 100644 --- a/jdk/src/share/classes/sun/text/resources/ga/FormatData_ga_IE.java +++ b/jdk/src/share/classes/sun/text/resources/ga/FormatData_ga_IE.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.ga; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ga_IE extends ListResourceBundle { +public class FormatData_ga_IE extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", diff --git a/jdk/src/share/classes/sun/text/resources/ga/JavaTimeSupplementary_ga.java b/jdk/src/share/classes/sun/text/resources/ga/JavaTimeSupplementary_ga.java new file mode 100644 index 00000000000..931b60b14a9 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/ga/JavaTimeSupplementary_ga.java @@ -0,0 +1,96 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ga; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ga extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "R1", + "R2", + "R3", + "R4", + } + }, + { "QuarterNames", + new String[] { + "1\u00fa r\u00e1ithe", + "2\u00fa r\u00e1ithe", + "3\u00fa r\u00e1ithe", + "4\u00fa r\u00e1ithe", + } + }, + { "java.time.short.Eras", + new String[] { + "RC", + "AD", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/hi/FormatData_hi_IN.java b/jdk/src/share/classes/sun/text/resources/hi/FormatData_hi_IN.java index 61711a0e322..97b5c0c8d60 100644 --- a/jdk/src/share/classes/sun/text/resources/hi/FormatData_hi_IN.java +++ b/jdk/src/share/classes/sun/text/resources/hi/FormatData_hi_IN.java @@ -67,15 +67,15 @@ package sun.text.resources.hi; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; /** * The locale elements for Hindi. * */ -public class FormatData_hi_IN extends ListResourceBundle { +public class FormatData_hi_IN extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -113,6 +113,23 @@ public class FormatData_hi_IN extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u091c", + "\u092b\u093c", + "\u092e\u093e", + "\u0905", + "\u092e", + "\u091c\u0942", + "\u091c\u0941", + "\u0905", + "\u0938\u093f", + "\u0905", + "\u0928", + "\u0926\u093f", + "", + } + }, { "DayNames", new String[] { "\u0930\u0935\u093f\u0935\u093e\u0930", // Sunday @@ -158,6 +175,12 @@ public class FormatData_hi_IN extends ListResourceBundle { "\u0938\u0928" } }, + { "short.Eras", + new String[] { + "\u0908\u0938\u093e\u092a\u0942\u0930\u094d\u0935", + "\u0938\u0928", + } + }, { "NumberElements", new String[] { ".", // decimal separator @@ -195,24 +218,6 @@ public class FormatData_hi_IN extends ListResourceBundle { } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.islamicc", "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.roc", "\u091a\u0940\u0928\u0940 \u0917\u0923\u0924\u0902\u0924\u094d\u0930 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.islamic", "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.buddhist", "\u092c\u094c\u0926\u094d\u0927 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.japanese", "\u091c\u093e\u092a\u093e\u0928\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.gregorian", "\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "calendarname.gregory", "\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, - { "field.era", "\u092f\u0941\u0917" }, - { "field.year", "\u0935\u0930\u094d\u0937" }, - { "field.month", "\u092e\u093e\u0938" }, - { "field.week", "\u0938\u092a\u094d\u0924\u093e\u0939" }, - { "field.weekday", "\u0938\u092a\u094d\u0924\u093e\u0939 \u0915\u093e \u0926\u093f\u0928" }, - { "field.dayperiod", "\u0938\u092e\u092f \u0905\u0935\u0927\u093f" }, - { "field.hour", "\u0918\u0902\u091f\u093e" }, - { "field.minute", "\u092e\u093f\u0928\u091f" }, - { "field.second", "\u0938\u0947\u0915\u0947\u0902\u0921" }, - { "field.zone", "\u0915\u094d\u0937\u0947\u0924\u094d\u0930" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/hi/JavaTimeSupplementary_hi_IN.java b/jdk/src/share/classes/sun/text/resources/hi/JavaTimeSupplementary_hi_IN.java new file mode 100644 index 00000000000..e59acabd337 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/hi/JavaTimeSupplementary_hi_IN.java @@ -0,0 +1,167 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.hi; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_hi_IN extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "\u0924\u093f\u092e\u093e\u0939\u0940", + "\u0926\u0942\u0938\u0930\u0940 \u0924\u093f\u092e\u093e\u0939\u0940", + "\u0924\u0940\u0938\u0930\u0940 \u0924\u093f\u092e\u093e\u0939\u0940", + "\u091a\u094c\u0925\u0940 \u0924\u093f\u092e\u093e\u0939\u0940", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u092c\u094c\u0926\u094d\u0927 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.gregorian", + "\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.gregory", + "\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.islamic", + "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.islamic-civil", + "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.islamicc", + "\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.japanese", + "\u091c\u093e\u092a\u093e\u0928\u0940 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "calendarname.roc", + "\u091a\u0940\u0928\u0940 \u0917\u0923\u0924\u0902\u0924\u094d\u0930 \u092a\u0902\u091a\u093e\u0902\u0917" }, + { "field.dayperiod", + "\u0938\u092e\u092f \u0905\u0935\u0927\u093f" }, + { "field.era", + "\u092f\u0941\u0917" }, + { "field.hour", + "\u0918\u0902\u091f\u093e" }, + { "field.minute", + "\u092e\u093f\u0928\u091f" }, + { "field.month", + "\u092e\u093e\u0938" }, + { "field.second", + "\u0938\u0947\u0915\u0947\u0902\u0921" }, + { "field.week", + "\u0938\u092a\u094d\u0924\u093e\u0939" }, + { "field.weekday", + "\u0938\u092a\u094d\u0924\u093e\u0939 \u0915\u093e \u0926\u093f\u0928" }, + { "field.year", + "\u0935\u0930\u094d\u0937" }, + { "field.zone", + "\u0915\u094d\u0937\u0947\u0924\u094d\u0930" }, + { "islamic.MonthNames", + new String[] { + "\u092e\u0941\u0939\u0930\u094d\u0930\u092e", + "\u0938\u092b\u0930", + "\u0930\u093e\u092c\u0940 \u092a\u094d\u0930\u0925\u092e", + "\u0930\u093e\u092c\u0940 \u0926\u094d\u0935\u093f\u0924\u0940\u092f", + "\u091c\u0941\u092e\u094d\u0921\u093e \u092a\u094d\u0930\u0925\u092e", + "\u091c\u0941\u092e\u094d\u0921\u093e \u0926\u094d\u0935\u093f\u0924\u0940\u092f", + "\u0930\u091c\u092c", + "\u0936\u093e\u0935\u0928", + "\u0930\u092e\u091c\u093e\u0928", + "\u0936\u0935\u094d\u0935\u094d\u0932", + "Dhu\u02bbl-Qi\u02bbdah", + "Dhu\u02bbl-Hijjah", + "", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u0938\u0928", + "\u092e\u0947\u091c\u0940", + "\u0924\u093e\u0908\u0936\u094b", + "\u0936\u094b\u0935\u093e", + "\u0939\u0947\u0908\u0938\u0947\u0908", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u0938\u0928", + "\u092e\u0947\u091c\u0940", + "\u0924\u093e\u0908\u0936\u094b", + "\u0936\u094b\u0935\u093e", + "\u0939\u0947\u0908\u0938\u0947\u0908", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0908\u0938\u093e\u092a\u0942\u0930\u094d\u0935", + "\u0938\u0928", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr.java b/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr.java index 8d3a64d5c0c..cd50304a62f 100644 --- a/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr.java +++ b/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr.java @@ -76,11 +76,11 @@ package sun.text.resources.hr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_hr extends ListResourceBundle { +public class FormatData_hr extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -157,6 +157,23 @@ public class FormatData_hr extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "1.", + "2.", + "3.", + "4.", + "5.", + "6.", + "7.", + "8.", + "9.", + "10.", + "11.", + "12.", + "", + } + }, { "standalone.MonthNarrows", new String[] { "1.", @@ -185,6 +202,17 @@ public class FormatData_hr extends ListResourceBundle { "subota" // Saturday } }, + { "standalone.DayNames", + new String[] { + "nedjelja", + "ponedjeljak", + "utorak", + "srijeda", + "\u010detvrtak", + "petak", + "subota", + } + }, { "DayAbbreviations", new String[] { "ned", // abb Sunday @@ -196,6 +224,17 @@ public class FormatData_hr extends ListResourceBundle { "sub" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "ned", + "pon", + "uto", + "sri", + "\u010det", + "pet", + "sub", + } + }, { "DayNarrows", new String[] { "N", @@ -218,6 +257,18 @@ public class FormatData_hr extends ListResourceBundle { "s", } }, + { "Eras", + new String[] { + "Prije Krista", + "Poslije Krista", + } + }, + { "short.Eras", + new String[] { + "p. n. e.", + "A. D.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -255,58 +306,6 @@ public class FormatData_hr extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d. MMMM y. G", - "d. MMMM y. G", - "d. M. y. G", - "d.M.y.", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d. MMMM y. G", - "d. MMMM y. G", - "d. M. y. G", - "d.M.y. G", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d. MMMM y. G", - "d. MMMM y. G", - "d. M. y. G", - "d.M.y. G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d. MMMM y. GGGG", - "d. MMMM y. GGGG", - "d. M. y. GGGG", - "d.M.y. GGGG", - } - }, - { "calendarname.islamic-civil", "islamski civilni kalendar" }, - { "calendarname.islamicc", "islamski civilni kalendar" }, - { "calendarname.roc", "kalendar Republike Kine" }, - { "calendarname.islamic", "islamski kalendar" }, - { "calendarname.buddhist", "budisti\u010dki kalendar" }, - { "calendarname.japanese", "japanski kalendar" }, - { "calendarname.gregorian", "gregorijanski kalendar" }, - { "calendarname.gregory", "gregorijanski kalendar" }, - { "field.era", "era" }, - { "field.year", "godina" }, - { "field.month", "mjesec" }, - { "field.week", "tjedan" }, - { "field.weekday", "dan u tjednu" }, - { "field.dayperiod", "dio dana" }, - { "field.hour", "sat" }, - { "field.minute", "minuta" }, - { "field.second", "sekunda" }, - { "field.zone", "zona" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr_HR.java b/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr_HR.java index b99f1c4b467..5060f64cfb3 100644 --- a/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr_HR.java +++ b/jdk/src/share/classes/sun/text/resources/hr/FormatData_hr_HR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.hr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_hr_HR extends ListResourceBundle { +public class FormatData_hr_HR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/hr/JavaTimeSupplementary_hr.java b/jdk/src/share/classes/sun/text/resources/hr/JavaTimeSupplementary_hr.java new file mode 100644 index 00000000000..cd090390523 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/hr/JavaTimeSupplementary_hr.java @@ -0,0 +1,190 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.hr; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_hr extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1kv", + "2kv", + "3kv", + "4kv", + } + }, + { "QuarterNames", + new String[] { + "1. kvartal", + "2. kvartal", + "3. kvartal", + "4. kvartal", + } + }, + { "QuarterNarrows", + new String[] { + "1.", + "2.", + "3.", + "4.", + } + }, + { "calendarname.buddhist", + "budisti\u010dki kalendar" }, + { "calendarname.gregorian", + "gregorijanski kalendar" }, + { "calendarname.gregory", + "gregorijanski kalendar" }, + { "calendarname.islamic", + "islamski kalendar" }, + { "calendarname.islamic-civil", + "islamski civilni kalendar" }, + { "calendarname.islamicc", + "islamski civilni kalendar" }, + { "calendarname.japanese", + "japanski kalendar" }, + { "calendarname.roc", + "kalendar Republike Kine" }, + { "field.dayperiod", + "dio dana" }, + { "field.era", + "era" }, + { "field.hour", + "sat" }, + { "field.minute", + "minuta" }, + { "field.month", + "mjesec" }, + { "field.second", + "sekunda" }, + { "field.week", + "tjedan" }, + { "field.weekday", + "dan u tjednu" }, + { "field.year", + "godina" }, + { "field.zone", + "zona" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d. MMMM y. G", + "d. MMMM y. G", + "d. M. y. G", + "d.M.y.", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d. MMMM y. G", + "d. MMMM y. G", + "d. M. y. G", + "d.M.y. G", + } + }, + { "java.time.long.Eras", + new String[] { + "Prije Krista", + "Poslije Krista", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d. MMMM y. G", + "d. MMMM y. G", + "d. M. y. G", + "d.M.y. G", + } + }, + { "java.time.short.Eras", + new String[] { + "Prije Krista", + "Poslije Krista", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d. MMMM y. GGGG", + "d. MMMM y. GGGG", + "d. M. y. GGGG", + "d.M.y. GGGG", + } + }, + { "roc.Eras", + new String[] { + "prije R.O.C.", + "R.O.C.", + } + }, + { "roc.short.Eras", + new String[] { + "prije R.O.C.", + "R.O.C.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu.java b/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu.java index 8d2f4d8adb4..d5e53685114 100644 --- a/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu.java +++ b/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu.java @@ -76,11 +76,11 @@ package sun.text.resources.hu; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_hu extends ListResourceBundle { +public class FormatData_hu extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -101,6 +101,23 @@ public class FormatData_hu extends ListResourceBundle { "" // month 13 if applicable } }, + { "standalone.MonthNames", + new String[] { + "janu\u00e1r", + "febru\u00e1r", + "m\u00e1rcius", + "\u00e1prilis", + "m\u00e1jus", + "j\u00fanius", + "j\u00falius", + "augusztus", + "szeptember", + "okt\u00f3ber", + "november", + "december", + "", + } + }, { "MonthAbbreviations", new String[] { "jan.", // abb january @@ -118,6 +135,57 @@ public class FormatData_hu extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "jan.", + "febr.", + "m\u00e1rc.", + "\u00e1pr.", + "m\u00e1j.", + "j\u00fan.", + "j\u00fal.", + "aug.", + "szept.", + "okt.", + "nov.", + "dec.", + "", + } + }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "\u00c1", + "M", + "J", + "J", + "A", + "Sz", + "O", + "N", + "D", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "J", + "F", + "M", + "\u00c1", + "M", + "J", + "J", + "A", + "Sz", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "vas\u00e1rnap", // Sunday @@ -129,6 +197,17 @@ public class FormatData_hu extends ListResourceBundle { "szombat" // Saturday } }, + { "standalone.DayNames", + new String[] { + "vas\u00e1rnap", + "h\u00e9tf\u0151", + "kedd", + "szerda", + "cs\u00fct\u00f6rt\u00f6k", + "p\u00e9ntek", + "szombat", + } + }, { "DayAbbreviations", new String[] { "V", // abb Sunday @@ -140,6 +219,17 @@ public class FormatData_hu extends ListResourceBundle { "Szo" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "V", + "H", + "K", + "Sze", + "Cs", + "P", + "Szo", + } + }, { "DayNarrows", new String[] { "V", @@ -151,6 +241,17 @@ public class FormatData_hu extends ListResourceBundle { "Sz", } }, + { "standalone.DayNarrows", + new String[] { + "V", + "H", + "K", + "Sz", + "Cs", + "P", + "Sz", + } + }, { "AmPmMarkers", new String[] { "DE", // am marker @@ -163,6 +264,12 @@ public class FormatData_hu extends ListResourceBundle { "i.u." } }, + { "short.Eras", + new String[] { + "i. e.", + "i. sz.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -200,47 +307,18 @@ public class FormatData_hu extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "islamic.MonthNames", + { "buddhist.Eras", new String[] { - "Moharrem", - "Safar", - "R\u00e9bi el avvel", - "R\u00e9bi el accher", - "Dsem\u00e1di el avvel", - "Dsem\u00e1di el accher", - "Redseb", - "Sab\u00e1n", - "Ramad\u00e1n", - "Sevv\u00e1l", - "Ds\u00fcl kade", - "Ds\u00fcl hedse", - "", + "BC", + "BK", } }, - { "islamic.Eras", + { "buddhist.short.Eras", new String[] { - "", - "MF", + "BC", + "BK", } }, - { "calendarname.islamic-civil", "iszl\u00e1m civil napt\u00e1r" }, - { "calendarname.islamicc", "iszl\u00e1m civil napt\u00e1r" }, - { "calendarname.islamic", "iszl\u00e1m napt\u00e1r" }, - { "calendarname.japanese", "jap\u00e1n napt\u00e1r" }, - { "calendarname.gregorian", "Gergely-napt\u00e1r" }, - { "calendarname.gregory", "Gergely-napt\u00e1r" }, - { "calendarname.roc", "K\u00ednai k\u00f6zt\u00e1rsas\u00e1gi napt\u00e1r" }, - { "calendarname.buddhist", "buddhista napt\u00e1r" }, - { "field.era", "\u00e9ra" }, - { "field.year", "\u00e9v" }, - { "field.month", "h\u00f3nap" }, - { "field.week", "h\u00e9t" }, - { "field.weekday", "h\u00e9t napja" }, - { "field.dayperiod", "napszak" }, - { "field.hour", "\u00f3ra" }, - { "field.minute", "perc" }, - { "field.second", "m\u00e1sodperc" }, - { "field.zone", "z\u00f3na" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu_HU.java b/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu_HU.java index 5786409e24a..aff72bf3b81 100644 --- a/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu_HU.java +++ b/jdk/src/share/classes/sun/text/resources/hu/FormatData_hu_HU.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.hu; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_hu_HU extends ListResourceBundle { +public class FormatData_hu_HU extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/hu/JavaTimeSupplementary_hu.java b/jdk/src/share/classes/sun/text/resources/hu/JavaTimeSupplementary_hu.java new file mode 100644 index 00000000000..78845bf290b --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/hu/JavaTimeSupplementary_hu.java @@ -0,0 +1,235 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.hu; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_hu extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "N1", + "N2", + "N3", + "N4", + } + }, + { "QuarterNames", + new String[] { + "I. negyed\u00e9v", + "II. negyed\u00e9v", + "III. negyed\u00e9v", + "IV. negyed\u00e9v", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "buddhista napt\u00e1r" }, + { "calendarname.gregorian", + "Gergely-napt\u00e1r" }, + { "calendarname.gregory", + "Gergely-napt\u00e1r" }, + { "calendarname.islamic", + "iszl\u00e1m napt\u00e1r" }, + { "calendarname.islamic-civil", + "iszl\u00e1m civil napt\u00e1r" }, + { "calendarname.islamicc", + "iszl\u00e1m civil napt\u00e1r" }, + { "calendarname.japanese", + "jap\u00e1n napt\u00e1r" }, + { "calendarname.roc", + "K\u00ednai k\u00f6zt\u00e1rsas\u00e1gi napt\u00e1r" }, + { "field.dayperiod", + "napszak" }, + { "field.era", + "\u00e9ra" }, + { "field.hour", + "\u00f3ra" }, + { "field.minute", + "perc" }, + { "field.month", + "h\u00f3nap" }, + { "field.second", + "m\u00e1sodperc" }, + { "field.week", + "h\u00e9t" }, + { "field.weekday", + "h\u00e9t napja" }, + { "field.year", + "\u00e9v" }, + { "field.zone", + "z\u00f3na" }, + { "islamic.DatePatterns", + new String[] { + "y. MMMM d., EEEE", + "y. MMMM d.", + "yyyy.MM.dd.", + "yyyy.MM.dd.", + } + }, + { "islamic.Eras", + new String[] { + "", + "MF", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "Muh.", + "Saf.", + "Rab. I", + "Rab. II", + "Jum. I", + "Jum. II", + "Raj.", + "Sha.", + "Ram.", + "Shaw.", + "Ds\u00fcl-Q.", + "Ds\u00fcl-H.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Moharrem", + "Safar", + "R\u00e9bi el avvel", + "R\u00e9bi el accher", + "Dsem\u00e1di el avvel", + "Dsem\u00e1di el accher", + "Redseb", + "Sab\u00e1n", + "Ramad\u00e1n", + "Sevv\u00e1l", + "Ds\u00fcl kade", + "Ds\u00fcl hedse", + "", + } + }, + { "islamic.MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "MF", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "BK", + } + }, + { "java.time.long.Eras", + new String[] { + "id\u0151sz\u00e1m\u00edt\u00e1sunk el\u0151tt", + "id\u0151sz\u00e1m\u00edt\u00e1sunk szerint", + } + }, + { "java.time.short.Eras", + new String[] { + "i.e.", + "i.u.", + } + }, + { "roc.Eras", + new String[] { + "R.O.C. el\u0151tt", + "", + } + }, + { "roc.short.Eras", + new String[] { + "R.O.C. el\u0151tt", + "", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/in/FormatData_in.java b/jdk/src/share/classes/sun/text/resources/in/FormatData_in.java index b99a9502702..4eb35408d76 100644 --- a/jdk/src/share/classes/sun/text/resources/in/FormatData_in.java +++ b/jdk/src/share/classes/sun/text/resources/in/FormatData_in.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.in; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_in extends ListResourceBundle { +public class FormatData_in extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", diff --git a/jdk/src/share/classes/sun/text/resources/in/FormatData_in_ID.java b/jdk/src/share/classes/sun/text/resources/in/FormatData_in_ID.java index c72751009aa..f7e28a9ee3c 100644 --- a/jdk/src/share/classes/sun/text/resources/in/FormatData_in_ID.java +++ b/jdk/src/share/classes/sun/text/resources/in/FormatData_in_ID.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.in; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_in_ID extends ListResourceBundle { +public class FormatData_in_ID extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "TimePatterns", diff --git a/jdk/src/share/classes/sun/text/resources/is/FormatData_is.java b/jdk/src/share/classes/sun/text/resources/is/FormatData_is.java index b9324a7bf5a..ffb2cb0bb47 100644 --- a/jdk/src/share/classes/sun/text/resources/is/FormatData_is.java +++ b/jdk/src/share/classes/sun/text/resources/is/FormatData_is.java @@ -76,11 +76,11 @@ package sun.text.resources.is; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_is extends ListResourceBundle { +public class FormatData_is extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ public class FormatData_is extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "\u00c1", + "L", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthNarrows", new String[] { "j", @@ -216,13 +233,6 @@ public class FormatData_is extends ListResourceBundle { } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "\u00cdslamskt borgaradagatal" }, - { "calendarname.islamicc", "\u00cdslamskt borgaradagatal" }, - { "calendarname.islamic", "\u00cdslamskt dagatal" }, - { "calendarname.buddhist", "B\u00fadd\u00edskt dagatal" }, - { "calendarname.japanese", "Japanskt dagatal" }, - { "calendarname.gregorian", "Gregor\u00edskt dagatal" }, - { "calendarname.gregory", "Gregor\u00edskt dagatal" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/is/FormatData_is_IS.java b/jdk/src/share/classes/sun/text/resources/is/FormatData_is_IS.java index af9be46e9d1..dd82870c7c0 100644 --- a/jdk/src/share/classes/sun/text/resources/is/FormatData_is_IS.java +++ b/jdk/src/share/classes/sun/text/resources/is/FormatData_is_IS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.is; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_is_IS extends ListResourceBundle { +public class FormatData_is_IS extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/is/JavaTimeSupplementary_is.java b/jdk/src/share/classes/sun/text/resources/is/JavaTimeSupplementary_is.java new file mode 100644 index 00000000000..bc2c3272737 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/is/JavaTimeSupplementary_is.java @@ -0,0 +1,140 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.is; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_is extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "F1", + "F2", + "F3", + "F4", + } + }, + { "QuarterNames", + new String[] { + "1st fj\u00f3r\u00f0ungur", + "2nd fj\u00f3r\u00f0ungur", + "3rd fj\u00f3r\u00f0ungur", + "4th fj\u00f3r\u00f0ungur", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "B\u00fadd\u00edskt dagatal" }, + { "calendarname.gregorian", + "Gregor\u00edskt dagatal" }, + { "calendarname.gregory", + "Gregor\u00edskt dagatal" }, + { "calendarname.islamic", + "\u00cdslamskt dagatal" }, + { "calendarname.islamic-civil", + "\u00cdslamskt borgaradagatal" }, + { "calendarname.islamicc", + "\u00cdslamskt borgaradagatal" }, + { "calendarname.japanese", + "Japanskt dagatal" }, + { "calendarname.roc", + "k\u00ednverskt dagatal" }, + { "field.dayperiod", + "f.h./e.h." }, + { "field.era", + "t\u00edmabil" }, + { "field.hour", + "klukkustund" }, + { "field.minute", + "m\u00edn\u00fata" }, + { "field.month", + "m\u00e1nu\u00f0ur" }, + { "field.second", + "sek\u00fanda" }, + { "field.week", + "vika" }, + { "field.weekday", + "vikudagur" }, + { "field.year", + "\u00e1r" }, + { "field.zone", + "sv\u00e6\u00f0i" }, + { "java.time.short.Eras", + new String[] { + "fyrir Krist", + "eftir Krist", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/it/FormatData_it.java b/jdk/src/share/classes/sun/text/resources/it/FormatData_it.java index e3ca1d05fb3..4c75a09bed6 100644 --- a/jdk/src/share/classes/sun/text/resources/it/FormatData_it.java +++ b/jdk/src/share/classes/sun/text/resources/it/FormatData_it.java @@ -76,11 +76,11 @@ package sun.text.resources.it; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_it extends ListResourceBundle { +public class FormatData_it extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,40 @@ public class FormatData_it extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "G", + "F", + "M", + "A", + "M", + "G", + "L", + "A", + "S", + "O", + "N", + "D", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "G", + "F", + "M", + "A", + "M", + "G", + "L", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "domenica", // Sunday @@ -146,6 +180,17 @@ public class FormatData_it extends ListResourceBundle { "sabato" // Saturday } }, + { "standalone.DayNames", + new String[] { + "Domenica", + "Luned\u00ec", + "Marted\u00ec", + "Mercoled\u00ec", + "Gioved\u00ec", + "Venerd\u00ec", + "Sabato", + } + }, { "DayAbbreviations", new String[] { "dom", // abb Sunday @@ -174,6 +219,12 @@ public class FormatData_it extends ListResourceBundle { "dopo Cristo" } }, + { "short.Eras", + new String[] { + "aC", + "dC", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -211,71 +262,6 @@ public class FormatData_it extends ListResourceBundle { } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "dd MMMM y G", - "dd/MMM/y G", - "dd/MM/y G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "dd MMMM y G", - "dd/MMM/y G", - "dd/MM/y G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "dd MMMM y G", - "dd/MMM/y G", - "dd/MM/y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "dd MMMM y GGGG", - "dd/MMM/y GGGG", - "dd/MM/y GGGG", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "dd MMMM y G", - "dd/MMM/y G", - "dd/MM/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "dd MMMM y GGGG", - "dd/MMM/y GGGG", - "dd/MM/y GGGG", - } - }, - { "calendarname.islamic-civil", "calendario civile islamico" }, - { "calendarname.islamicc", "calendario civile islamico" }, - { "calendarname.islamic", "calendario islamico" }, - { "calendarname.buddhist", "calendario buddista" }, - { "calendarname.japanese", "calendario giapponese" }, - { "calendarname.gregorian", "calendario gregoriano" }, - { "calendarname.gregory", "calendario gregoriano" }, - { "field.era", "era" }, - { "field.year", "anno" }, - { "field.month", "mese" }, - { "field.week", "settimana" }, - { "field.weekday", "giorno della settimana" }, - { "field.dayperiod", "periodo del giorno" }, - { "field.hour", "ora" }, - { "field.minute", "minuto" }, - { "field.second", "secondo" }, - { "field.zone", "zona" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/it/FormatData_it_CH.java b/jdk/src/share/classes/sun/text/resources/it/FormatData_it_CH.java index 1858e245adc..def550612f5 100644 --- a/jdk/src/share/classes/sun/text/resources/it/FormatData_it_CH.java +++ b/jdk/src/share/classes/sun/text/resources/it/FormatData_it_CH.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -40,11 +40,11 @@ package sun.text.resources.it; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_it_CH extends ListResourceBundle { +public class FormatData_it_CH extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/it/FormatData_it_IT.java b/jdk/src/share/classes/sun/text/resources/it/FormatData_it_IT.java index 254ae81f125..5a9e54f80f3 100644 --- a/jdk/src/share/classes/sun/text/resources/it/FormatData_it_IT.java +++ b/jdk/src/share/classes/sun/text/resources/it/FormatData_it_IT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.it; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_it_IT extends ListResourceBundle { +public class FormatData_it_IT extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/it/JavaTimeSupplementary_it.java b/jdk/src/share/classes/sun/text/resources/it/JavaTimeSupplementary_it.java new file mode 100644 index 00000000000..692b3d70cde --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/it/JavaTimeSupplementary_it.java @@ -0,0 +1,200 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.it; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_it extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "T1", + "T2", + "T3", + "T4", + } + }, + { "QuarterNames", + new String[] { + "1o trimestre", + "2o trimestre", + "3o trimestre", + "4o trimestre", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "calendario buddista" }, + { "calendarname.gregorian", + "calendario gregoriano" }, + { "calendarname.gregory", + "calendario gregoriano" }, + { "calendarname.islamic", + "calendario islamico" }, + { "calendarname.islamic-civil", + "calendario civile islamico" }, + { "calendarname.islamicc", + "calendario civile islamico" }, + { "calendarname.japanese", + "calendario giapponese" }, + { "calendarname.roc", + "Calendario Minguo" }, + { "field.dayperiod", + "periodo del giorno" }, + { "field.era", + "era" }, + { "field.hour", + "ora" }, + { "field.minute", + "minuto" }, + { "field.month", + "mese" }, + { "field.second", + "secondo" }, + { "field.week", + "settimana" }, + { "field.weekday", + "giorno della settimana" }, + { "field.year", + "anno" }, + { "field.zone", + "zona" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "dd MMMM y GGGG", + "dd/MMM/y GGGG", + "dd/MM/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "dd MMMM y G", + "dd/MMM/y G", + "dd/MM/y G", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "EB", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "dd MMMM y G", + "dd/MMM/y G", + "dd/MM/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "dd MMMM y G", + "dd/MMM/y G", + "dd/MM/y G", + } + }, + { "java.time.long.Eras", + new String[] { + "a.C.", + "d.C", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "dd MMMM y G", + "dd/MMM/y G", + "dd/MM/y G", + } + }, + { "java.time.short.Eras", + new String[] { + "BC", + "dopo Cristo", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "dd MMMM y GGGG", + "dd/MMM/y GGGG", + "dd/MM/y GGGG", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw.java b/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw.java index 61d82fbcaaf..4e52da31e05 100644 --- a/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw.java +++ b/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw.java @@ -76,11 +76,11 @@ package sun.text.resources.iw; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_iw extends ListResourceBundle { +public class FormatData_iw extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,23 @@ public class FormatData_iw extends ListResourceBundle { "", } }, + { "MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, { "DayNames", new String[] { "\u05d9\u05d5\u05dd \u05e8\u05d0\u05e9\u05d5\u05df", // Sunday @@ -185,6 +202,12 @@ public class FormatData_iw extends ListResourceBundle { "\u05dc\u05e4\u05e1\u05d4\"\u05e0" } }, + { "short.Eras", + new String[] { + "\u05dc\u05e4\u05e0\u05d4\u05f4\u05e1", + "\u05dc\u05e1\u05d4\u05f4\u05e0", + } + }, { "TimePatterns", new String[] { "HH:mm:ss z", // full time pattern @@ -207,46 +230,6 @@ public class FormatData_iw extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "islamic.MonthNames", - new String[] { - "\u05de\u05d5\u05d7\u05e8\u05dd", - "\u05e1\u05e4\u05e8", - "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", - "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05ea\u05e0\u05d9", - "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", - "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05ea\u05e0\u05d9", - "\u05e8\u05d2\u05f3\u05d0\u05d1", - "\u05e9\u05e2\u05d1\u05d0\u05df", - "\u05e8\u05d0\u05de\u05d3\u05df", - "\u05e9\u05d5\u05d5\u05d0\u05dc", - "\u05d6\u05d5 \u05d0\u05dc-QI'DAH", - "\u05d6\u05d5 \u05d0\u05dc-\u05d7\u05d9\u05d2\u05f3\u05d4", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4", - } - }, - { "calendarname.islamic-civil", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, - { "calendarname.islamicc", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, - { "calendarname.islamic", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9" }, - { "calendarname.buddhist", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d1\u05d5\u05d3\u05d4\u05d9\u05e1\u05d8\u05d9" }, - { "calendarname.japanese", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d9\u05e4\u05e0\u05d9" }, - { "calendarname.gregorian", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, - { "calendarname.gregory", "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, - { "field.era", "\u05ea\u05e7\u05d5\u05e4\u05d4" }, - { "field.year", "\u05e9\u05e0\u05d4" }, - { "field.month", "\u05d7\u05d5\u05d3\u05e9" }, - { "field.week", "\u05e9\u05d1\u05d5\u05e2" }, - { "field.weekday", "\u05d9\u05d5\u05dd \u05d1\u05e9\u05d1\u05d5\u05e2" }, - { "field.dayperiod", "\u05dc\u05e4\u05d4\u05f4\u05e6/\u05d0\u05d7\u05d4\u05f4\u05e6" }, - { "field.hour", "\u05e9\u05e2\u05d4" }, - { "field.minute", "\u05d3\u05e7\u05d4" }, - { "field.second", "\u05e9\u05e0\u05d9\u05d9\u05d4" }, - { "field.zone", "\u05d0\u05d6\u05d5\u05e8" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw_IL.java b/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw_IL.java index 21e72ef9b4e..4605023d4f3 100644 --- a/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw_IL.java +++ b/jdk/src/share/classes/sun/text/resources/iw/FormatData_iw_IL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.iw; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_iw_IL extends ListResourceBundle { +public class FormatData_iw_IL extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/iw/JavaTimeSupplementary_iw.java b/jdk/src/share/classes/sun/text/resources/iw/JavaTimeSupplementary_iw.java new file mode 100644 index 00000000000..ef18ac9f211 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/iw/JavaTimeSupplementary_iw.java @@ -0,0 +1,167 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.iw; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_iw extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "\u05e8\u05d1\u05e2\u05d5\u05df 1", + "\u05e8\u05d1\u05e2\u05d5\u05df 2", + "\u05e8\u05d1\u05e2\u05d5\u05df 3", + "\u05e8\u05d1\u05e2\u05d5\u05df 4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d1\u05d5\u05d3\u05d4\u05d9\u05e1\u05d8\u05d9" }, + { "calendarname.gregorian", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, + { "calendarname.gregory", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, + { "calendarname.islamic", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9" }, + { "calendarname.islamic-civil", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, + { "calendarname.islamicc", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, + { "calendarname.japanese", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d9\u05e4\u05e0\u05d9" }, + { "calendarname.roc", + "\u05dc\u05d5\u05d7 \u05d4\u05e9\u05e0\u05d4 \u05d4\u05e1\u05d9\u05e0\u05d9 Minguo" }, + { "field.dayperiod", + "\u05dc\u05e4\u05d4\u05f4\u05e6/\u05d0\u05d7\u05d4\u05f4\u05e6" }, + { "field.era", + "\u05ea\u05e7\u05d5\u05e4\u05d4" }, + { "field.hour", + "\u05e9\u05e2\u05d4" }, + { "field.minute", + "\u05d3\u05e7\u05d4" }, + { "field.month", + "\u05d7\u05d5\u05d3\u05e9" }, + { "field.second", + "\u05e9\u05e0\u05d9\u05d9\u05d4" }, + { "field.week", + "\u05e9\u05d1\u05d5\u05e2" }, + { "field.weekday", + "\u05d9\u05d5\u05dd \u05d1\u05e9\u05d1\u05d5\u05e2" }, + { "field.year", + "\u05e9\u05e0\u05d4" }, + { "field.zone", + "\u05d0\u05d6\u05d5\u05e8" }, + { "islamic.Eras", + new String[] { + "", + "\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4", + } + }, + { "islamic.MonthNames", + new String[] { + "\u05de\u05d5\u05d7\u05e8\u05dd", + "\u05e1\u05e4\u05e8", + "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", + "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05ea\u05e0\u05d9", + "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", + "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05ea\u05e0\u05d9", + "\u05e8\u05d2\u05f3\u05d0\u05d1", + "\u05e9\u05e2\u05d1\u05d0\u05df", + "\u05e8\u05d0\u05de\u05d3\u05df", + "\u05e9\u05d5\u05d5\u05d0\u05dc", + "\u05d6\u05d5 \u05d0\u05dc-QI'DAH", + "\u05d6\u05d5 \u05d0\u05dc-\u05d7\u05d9\u05d2\u05f3\u05d4", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4", + } + }, + { "java.time.long.Eras", + new String[] { + "\u05dc\u05e4\u05e0\u05d9 \u05d4\u05e1\u05e4\u05d9\u05e8\u05d4", + "\u05dc\u05e1\u05e4\u05d9\u05e8\u05d4", + } + }, + { "java.time.short.Eras", + new String[] { + "\u05dc\u05e1\u05d4\"\u05e0", + "\u05dc\u05e4\u05e1\u05d4\"\u05e0", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/iw/JavaTimeSupplementary_iw_IL.java b/jdk/src/share/classes/sun/text/resources/iw/JavaTimeSupplementary_iw_IL.java new file mode 100644 index 00000000000..bf6543fed3e --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/iw/JavaTimeSupplementary_iw_IL.java @@ -0,0 +1,167 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.iw; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_iw_IL extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "\u05e8\u05d1\u05e2\u05d5\u05df 1", + "\u05e8\u05d1\u05e2\u05d5\u05df 2", + "\u05e8\u05d1\u05e2\u05d5\u05df 3", + "\u05e8\u05d1\u05e2\u05d5\u05df 4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d1\u05d5\u05d3\u05d4\u05d9\u05e1\u05d8\u05d9" }, + { "calendarname.gregorian", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, + { "calendarname.gregory", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9" }, + { "calendarname.islamic", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9" }, + { "calendarname.islamic-civil", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, + { "calendarname.islamicc", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9" }, + { "calendarname.japanese", + "\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d9\u05e4\u05e0\u05d9" }, + { "calendarname.roc", + "\u05dc\u05d5\u05d7 \u05d4\u05e9\u05e0\u05d4 \u05d4\u05e1\u05d9\u05e0\u05d9 Minguo" }, + { "field.dayperiod", + "\u05dc\u05e4\u05d4\u05f4\u05e6/\u05d0\u05d7\u05d4\u05f4\u05e6" }, + { "field.era", + "\u05ea\u05e7\u05d5\u05e4\u05d4" }, + { "field.hour", + "\u05e9\u05e2\u05d4" }, + { "field.minute", + "\u05d3\u05e7\u05d4" }, + { "field.month", + "\u05d7\u05d5\u05d3\u05e9" }, + { "field.second", + "\u05e9\u05e0\u05d9\u05d9\u05d4" }, + { "field.week", + "\u05e9\u05d1\u05d5\u05e2" }, + { "field.weekday", + "\u05d9\u05d5\u05dd \u05d1\u05e9\u05d1\u05d5\u05e2" }, + { "field.year", + "\u05e9\u05e0\u05d4" }, + { "field.zone", + "\u05d0\u05d6\u05d5\u05e8" }, + { "islamic.Eras", + new String[] { + "", + "\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4", + } + }, + { "islamic.MonthNames", + new String[] { + "\u05de\u05d5\u05d7\u05e8\u05dd", + "\u05e1\u05e4\u05e8", + "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", + "\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05ea\u05e0\u05d9", + "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc", + "\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05ea\u05e0\u05d9", + "\u05e8\u05d2\u05f3\u05d0\u05d1", + "\u05e9\u05e2\u05d1\u05d0\u05df", + "\u05e8\u05d0\u05de\u05d3\u05df", + "\u05e9\u05d5\u05d5\u05d0\u05dc", + "\u05d6\u05d5 \u05d0\u05dc-QI'DAH", + "\u05d6\u05d5 \u05d0\u05dc-\u05d7\u05d9\u05d2\u05f3\u05d4", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4", + } + }, + { "java.time.long.Eras", + new String[] { + "\u05dc\u05e4\u05e0\u05d9 \u05d4\u05e1\u05e4\u05d9\u05e8\u05d4", + "\u05dc\u05e1\u05e4\u05d9\u05e8\u05d4", + } + }, + { "java.time.short.Eras", + new String[] { + "\u05dc\u05e4\u05e0\u05d4\u05f4\u05e1", + "\u05dc\u05e1\u05d4\u05f4\u05e0", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja.java b/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja.java index 53eba9df55d..591cd35cb49 100644 --- a/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja.java +++ b/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja.java @@ -76,11 +76,11 @@ package sun.text.resources.ja; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ja extends ListResourceBundle { +public class FormatData_ja extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -182,16 +182,7 @@ public class FormatData_ja extends ListResourceBundle { "\u4ecf\u66a6", // Butsureki } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "GGGGy\u5e74M\u6708d\u65e5EEEE", - "GGGGy\u5e74M\u6708d\u65e5", - "Gy/MM/dd", - "Gy/MM/dd", - } - }, { "japanese.Eras", japaneseEras }, - { "cldr.japanese.short.Eras", japaneseEras }, { "japanese.FirstYear", new String[] { // first year name "\u5143", // "Gan"-nen @@ -233,14 +224,6 @@ public class FormatData_ja extends ListResourceBundle { "{1} {0}" // date-time pattern } }, - { "cldr.japanese.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy\u5e74M\u6708d\u65e5", - "Gyy/MM/dd", - } - }, { "japanese.DatePatterns", new String[] { "GGGGyyyy'\u5e74'M'\u6708'd'\u65e5'", // full date pattern @@ -263,42 +246,6 @@ public class FormatData_ja extends ListResourceBundle { } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy/MM/dd", - "Gy/MM/dd", - } - }, - { "roc.DatePatterns", - new String[] { - "GGGGy\u5e74M\u6708d\u65e5EEEE", - "GGGGy\u5e74M\u6708d\u65e5", - "GGGGy/MM/dd", - "GGGGy/MM/dd", - } - }, - { "calendarname.islamic-civil", "\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6" }, - { "calendarname.islamicc", "\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6" }, - { "calendarname.islamic", "\u30a4\u30b9\u30e9\u30e0\u66a6" }, - { "calendarname.japanese", "\u548c\u66a6" }, - { "calendarname.gregorian", "\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6]" }, - { "calendarname.gregory", "\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6]" }, - { "calendarname.roc", "\u4e2d\u83ef\u6c11\u56fd\u66a6" }, - { "calendarname.buddhist", "\u30bf\u30a4\u4ecf\u6559\u66a6" }, - { "field.era", "\u6642\u4ee3" }, - { "field.year", "\u5e74" }, - { "field.month", "\u6708" }, - { "field.week", "\u9031" }, - { "field.weekday", "\u66dc\u65e5" }, - { "field.dayperiod", "\u5348\u524d/\u5348\u5f8c" }, - { "field.hour", "\u6642" }, - { "field.minute", "\u5206" }, - { "field.second", "\u79d2" }, - { "field.zone", "\u30bf\u30a4\u30e0\u30be\u30fc\u30f3" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja_JP.java b/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja_JP.java index a7d2622d1f4..19875a2cd7d 100644 --- a/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja_JP.java +++ b/jdk/src/share/classes/sun/text/resources/ja/FormatData_ja_JP.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.ja; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ja_JP extends ListResourceBundle { +public class FormatData_ja_JP extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/ja/JavaTimeSupplementary_ja.java b/jdk/src/share/classes/sun/text/resources/ja/JavaTimeSupplementary_ja.java new file mode 100644 index 00000000000..851c1d8918f --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/ja/JavaTimeSupplementary_ja.java @@ -0,0 +1,254 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ja; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ja extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "\u7b2c1\u56db\u534a\u671f", + "\u7b2c2\u56db\u534a\u671f", + "\u7b2c3\u56db\u534a\u671f", + "\u7b2c4\u56db\u534a\u671f", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u30bf\u30a4\u4ecf\u6559\u66a6" }, + { "calendarname.gregorian", + "\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6]" }, + { "calendarname.gregory", + "\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6]" }, + { "calendarname.islamic", + "\u30a4\u30b9\u30e9\u30e0\u66a6" }, + { "calendarname.islamic-civil", + "\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6" }, + { "calendarname.islamicc", + "\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6" }, + { "calendarname.japanese", + "\u548c\u66a6" }, + { "calendarname.roc", + "\u4e2d\u83ef\u6c11\u56fd\u66a6" }, + { "field.dayperiod", + "\u5348\u524d/\u5348\u5f8c" }, + { "field.era", + "\u6642\u4ee3" }, + { "field.hour", + "\u6642" }, + { "field.minute", + "\u5206" }, + { "field.month", + "\u6708" }, + { "field.second", + "\u79d2" }, + { "field.week", + "\u9031" }, + { "field.weekday", + "\u66dc\u65e5" }, + { "field.year", + "\u5e74" }, + { "field.zone", + "\u30bf\u30a4\u30e0\u30be\u30fc\u30f3" }, + { "islamic.MonthAbbreviations", + new String[] { + "\u30e0\u30cf\u30c3\u30e9\u30e0", + "\u30b5\u30d5\u30a2\u30eb", + "\u30e9\u30d3\u30fc\u30fb\u30a6\u30eb\u30fb\u30a2\u30a6\u30ef\u30eb", + "\u30e9\u30d3\u30fc\u30fb\u30a6\u30c3\u30fb\u30b5\u30fc\u30cb\u30fc", + "\u30b8\u30e5\u30de\u30fc\u30c0\u30eb\u30fb\u30a2\u30a6\u30ef\u30eb", + "\u30b8\u30e5\u30de\u30fc\u30c0\u30c3\u30b5\u30fc\u30cb\u30fc", + "\u30e9\u30b8\u30e3\u30d6", + "\u30b7\u30e3\u30a2\u30d0\u30fc\u30f3", + "\u30e9\u30de\u30c0\u30fc\u30f3", + "\u30b7\u30e3\u30a6\u30ef\u30fc\u30eb", + "\u30ba\u30eb\u30fb\u30ab\u30a4\u30c0", + "\u30ba\u30eb\u30fb\u30d2\u30c3\u30b8\u30e3", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "\u30e0\u30cf\u30c3\u30e9\u30e0", + "\u30b5\u30d5\u30a2\u30eb", + "\u30e9\u30d3\u30fc\u30fb\u30a6\u30eb\u30fb\u30a2\u30a6\u30ef\u30eb", + "\u30e9\u30d3\u30fc\u30fb\u30a6\u30c3\u30fb\u30b5\u30fc\u30cb\u30fc", + "\u30b8\u30e5\u30de\u30fc\u30c0\u30eb\u30fb\u30a2\u30a6\u30ef\u30eb", + "\u30b8\u30e5\u30de\u30fc\u30c0\u30c3\u30b5\u30fc\u30cb\u30fc", + "\u30e9\u30b8\u30e3\u30d6", + "\u30b7\u30e3\u30a2\u30d0\u30fc\u30f3", + "\u30e9\u30de\u30c0\u30fc\u30f3", + "\u30b7\u30e3\u30a6\u30ef\u30fc\u30eb", + "\u30ba\u30eb\u30fb\u30ab\u30a4\u30c0", + "\u30ba\u30eb\u30fb\u30d2\u30c3\u30b8\u30e3", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "Gy/MM/dd", + "Gy/MM/dd", + } + }, + { "java.time.buddhist.long.Eras", + new String[] { + "BC", + "\u4ecf\u66a6", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "\u7d00\u5143\u524d", + "\u4ecf\u66a6", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "Gy'\u5e74'M'\u6708'd'\u65e5'", + "GGGGGy.MM.dd", + "GGGGGy.MM.dd", + "GGGGGy.MM.dd", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u897f\u66a6", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u897f\u66a6", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.long.Eras", + new String[] { + "\u7d00\u5143\u524d", + "\u897f\u66a6", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy/MM/dd", + "Gy/MM/dd", + } + }, + { "java.time.short.Eras", + new String[] { + "\u7d00\u5143\u524d", + "\u897f\u66a6", + } + }, + { "roc.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy/MM/dd", + "GGGGy/MM/dd", + } + }, + { "roc.Eras", + new String[] { + "\u6c11\u56fd\u524d", + "\u6c11\u56fd", + } + }, + { "roc.short.Eras", + new String[] { + "\u6c11\u56fd\u524d", + "\u6c11\u56fd", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko.java b/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko.java index 15872b2ede5..4483ad2e948 100644 --- a/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko.java +++ b/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko.java @@ -76,11 +76,11 @@ package sun.text.resources.ko; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ko extends ListResourceBundle { +public class FormatData_ko extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -123,6 +123,23 @@ public class FormatData_ko extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "1\uc6d4", + "2\uc6d4", + "3\uc6d4", + "4\uc6d4", + "5\uc6d4", + "6\uc6d4", + "7\uc6d4", + "8\uc6d4", + "9\uc6d4", + "10\uc6d4", + "11\uc6d4", + "12\uc6d4", + "", + } + }, { "DayNames", new String[] { "\uc77c\uc694\uc77c", // Sunday @@ -156,6 +173,27 @@ public class FormatData_ko extends ListResourceBundle { "\ud1a0", } }, + { "Eras", + new String[] { + "\uae30\uc6d0\uc804", + "\uc11c\uae30", + } + }, + { "buddhist.Eras", + new String[] { + "BC", + "\ubd88\uae30", + } + }, + { "japanese.Eras", + new String[] { + "\uc11c\uae30", + "\uba54\uc774\uc9c0", + "\ub2e4\uc774\uc1fc", + "\uc1fc\uc640", + "\ud5e4\uc774\uc138\uc774", + } + }, { "AmPmMarkers", new String[] { "\uc624\uc804", // am marker @@ -183,34 +221,7 @@ public class FormatData_ko extends ListResourceBundle { "{1} {0}" // date-time pattern } }, - { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "G y\ub144 M\uc6d4 d\uc77c EEEE", - "G y\ub144 M\uc6d4 d\uc77c", - "G y. M. d", - "G y. M. d", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "G y\ub144 M\uc6d4 d\uc77c EEEE", - "G y\ub144 M\uc6d4 d\uc77c", - "G y. M. d", - "G y. M. d", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "G y\ub144 M\uc6d4 d\uc77c EEEE", - "G y\ub144 M\uc6d4 d\uc77c", - "G y. M. d", - "G y. M. d", - } - }, - { "roc.DatePatterns", + { "buddhist.DatePatterns", new String[] { "GGGG y\ub144 M\uc6d4 d\uc77c EEEE", "GGGG y\ub144 M\uc6d4 d\uc77c", @@ -218,24 +229,15 @@ public class FormatData_ko extends ListResourceBundle { "GGGG y. M. d", } }, - { "calendarname.islamic-civil", "\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825" }, - { "calendarname.islamicc", "\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825" }, - { "calendarname.islamic", "\uc774\uc2ac\ub78c\ub825" }, - { "calendarname.japanese", "\uc77c\ubcf8\ub825" }, - { "calendarname.gregorian", "\ud0dc\uc591\ub825" }, - { "calendarname.gregory", "\ud0dc\uc591\ub825" }, - { "calendarname.roc", "\ub300\ub9cc\ub825" }, - { "calendarname.buddhist", "\ubd88\uad50\ub825" }, - { "field.era", "\uc5f0\ud638" }, - { "field.year", "\ub144" }, - { "field.month", "\uc6d4" }, - { "field.week", "\uc8fc" }, - { "field.weekday", "\uc694\uc77c" }, - { "field.dayperiod", "\uc624\uc804/\uc624\ud6c4" }, - { "field.hour", "\uc2dc" }, - { "field.minute", "\ubd84" }, - { "field.second", "\ucd08" }, - { "field.zone", "\uc2dc\uac04\ub300" }, + { "japanese.DatePatterns", + new String[] { + "GGGG y\ub144 M\uc6d4 d\uc77c EEEE", + "GGGG y\ub144 M\uc6d4 d\uc77c", + "GGGG y. M. d", + "GGGG y. M. d", + } + }, + { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko_KR.java b/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko_KR.java index 4108fec6640..809f58466ba 100644 --- a/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko_KR.java +++ b/jdk/src/share/classes/sun/text/resources/ko/FormatData_ko_KR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.ko; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ko_KR extends ListResourceBundle { +public class FormatData_ko_KR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/ko/JavaTimeSupplementary_ko.java b/jdk/src/share/classes/sun/text/resources/ko/JavaTimeSupplementary_ko.java new file mode 100644 index 00000000000..7435b6d7213 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/ko/JavaTimeSupplementary_ko.java @@ -0,0 +1,214 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ko; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ko extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1\ubd84\uae30", + "2\ubd84\uae30", + "3\ubd84\uae30", + "4\ubd84\uae30", + } + }, + { "QuarterNames", + new String[] { + "\uc81c 1/4\ubd84\uae30", + "\uc81c 2/4\ubd84\uae30", + "\uc81c 3/4\ubd84\uae30", + "\uc81c 4/4\ubd84\uae30", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\ubd88\uad50\ub825" }, + { "calendarname.gregorian", + "\ud0dc\uc591\ub825" }, + { "calendarname.gregory", + "\ud0dc\uc591\ub825" }, + { "calendarname.islamic", + "\uc774\uc2ac\ub78c\ub825" }, + { "calendarname.islamic-civil", + "\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825" }, + { "calendarname.islamicc", + "\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825" }, + { "calendarname.japanese", + "\uc77c\ubcf8\ub825" }, + { "calendarname.roc", + "\ub300\ub9cc\ub825" }, + { "field.dayperiod", + "\uc624\uc804/\uc624\ud6c4" }, + { "field.era", + "\uc5f0\ud638" }, + { "field.hour", + "\uc2dc" }, + { "field.minute", + "\ubd84" }, + { "field.month", + "\uc6d4" }, + { "field.second", + "\ucd08" }, + { "field.week", + "\uc8fc" }, + { "field.weekday", + "\uc694\uc77c" }, + { "field.year", + "\ub144" }, + { "field.zone", + "\uc2dc\uac04\ub300" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "G y\ub144 M\uc6d4 d\uc77c EEEE", + "G y\ub144 M\uc6d4 d\uc77c", + "G y. M. d", + "G y. M. d", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\ubd88\uae30", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "G y\ub144 M\uc6d4 d\uc77c EEEE", + "G y\ub144 M\uc6d4 d\uc77c", + "G y. M. d", + "G y. M. d", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\uc11c\uae30", + "\uba54\uc774\uc9c0", + "\ub2e4\uc774\uc1fc", + "\uc1fc\uc640", + "\ud5e4\uc774\uc138\uc774", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\uc11c\uae30", + "\uba54\uc774\uc9c0", + "\ub2e4\uc774\uc1fc", + "\uc1fc\uc640", + "\ud5e4\uc774\uc138\uc774", + } + }, + { "java.time.long.Eras", + new String[] { + "\uc11c\ub825\uae30\uc6d0\uc804", + "\uc11c\ub825\uae30\uc6d0", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "G y\ub144 M\uc6d4 d\uc77c EEEE", + "G y\ub144 M\uc6d4 d\uc77c", + "G y. M. d", + "G y. M. d", + } + }, + { "java.time.short.Eras", + new String[] { + "\uae30\uc6d0\uc804", + "\uc11c\uae30", + } + }, + { "roc.DatePatterns", + new String[] { + "GGGG y\ub144 M\uc6d4 d\uc77c EEEE", + "GGGG y\ub144 M\uc6d4 d\uc77c", + "GGGG y. M. d", + "GGGG y. M. d", + } + }, + { "roc.Eras", + new String[] { + "\uc911\ud654\ubbfc\uad6d\uc804", + "\uc911\ud654\ubbfc\uad6d", + } + }, + { "roc.short.Eras", + new String[] { + "\uc911\ud654\ubbfc\uad6d\uc804", + "\uc911\ud654\ubbfc\uad6d", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt.java b/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt.java index 90b740cd2e0..20a61db41e3 100644 --- a/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt.java +++ b/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt.java @@ -76,11 +76,11 @@ package sun.text.resources.lt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_lt extends ListResourceBundle { +public class FormatData_lt extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,40 @@ public class FormatData_lt extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "Saus.", + "Vas.", + "Kov.", + "Bal.", + "Geg.", + "Bir.", + "Liep.", + "Rugp.", + "Rugs.", + "Spal.", + "Lapkr.", + "Gruod.", + "", + } + }, + { "MonthNarrows", + new String[] { + "S", + "V", + "K", + "B", + "G", + "B", + "L", + "R", + "R", + "S", + "L", + "G", + "", + } + }, { "standalone.MonthNarrows", new String[] { "S", @@ -163,6 +197,17 @@ public class FormatData_lt extends ListResourceBundle { "\u0160e\u0161tadienis" // Saturday } }, + { "standalone.DayNames", + new String[] { + "sekmadienis", + "pirmadienis", + "antradienis", + "tre\u010diadienis", + "ketvirtadienis", + "penktadienis", + "\u0161e\u0161tadienis", + } + }, { "DayAbbreviations", new String[] { "Sk", // abb Sunday @@ -174,6 +219,17 @@ public class FormatData_lt extends ListResourceBundle { "\u0160t" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "Sk", + "Pr", + "An", + "Tr", + "Kt", + "Pn", + "\u0160t", + } + }, { "DayNarrows", new String[] { "S", @@ -202,6 +258,12 @@ public class FormatData_lt extends ListResourceBundle { "po.Kr." } }, + { "short.Eras", + new String[] { + "pr. Kr.", + "po Kr.", + } + }, { "NumberElements", new String[] { ",", // decimal separator @@ -239,32 +301,6 @@ public class FormatData_lt extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "y G, MMMM d, EEEE", - "G y MMMM d", - "G y MMM d", - "GGGGG yyyy-MM-dd", - } - }, - { "calendarname.islamic-civil", "Pilietinis islamo kalendorius" }, - { "calendarname.islamicc", "Pilietinis islamo kalendorius" }, - { "calendarname.islamic", "Islamo kalendorius" }, - { "calendarname.japanese", "Japon\u0173 kalendorius" }, - { "calendarname.gregorian", "Grigaliaus kalendorius" }, - { "calendarname.gregory", "Grigaliaus kalendorius" }, - { "calendarname.roc", "Kinijos Respublikos kalendorius" }, - { "calendarname.buddhist", "Budist\u0173 kalendorius" }, - { "field.era", "era" }, - { "field.year", "metai" }, - { "field.month", "m\u0117nuo" }, - { "field.week", "savait\u0117" }, - { "field.weekday", "savait\u0117s diena" }, - { "field.dayperiod", "dienos metas" }, - { "field.hour", "valanda" }, - { "field.minute", "minut\u0117" }, - { "field.second", "sekund\u0117" }, - { "field.zone", "laiko juosta" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt_LT.java b/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt_LT.java index a30db3fdc20..5127cac5032 100644 --- a/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt_LT.java +++ b/jdk/src/share/classes/sun/text/resources/lt/FormatData_lt_LT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.lt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_lt_LT extends ListResourceBundle { +public class FormatData_lt_LT extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/lt/JavaTimeSupplementary_lt.java b/jdk/src/share/classes/sun/text/resources/lt/JavaTimeSupplementary_lt.java new file mode 100644 index 00000000000..bebc6b13c37 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/lt/JavaTimeSupplementary_lt.java @@ -0,0 +1,154 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.lt; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_lt extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "I k.", + "II k.", + "III k.", + "IV ketv.", + } + }, + { "QuarterNames", + new String[] { + "I ketvirtis", + "II ketvirtis", + "III ketvirtis", + "IV ketvirtis", + } + }, + { "QuarterNarrows", + new String[] { + "I", + "II", + "3", + "IV", + } + }, + { "calendarname.buddhist", + "Budist\u0173 kalendorius" }, + { "calendarname.gregorian", + "Grigaliaus kalendorius" }, + { "calendarname.gregory", + "Grigaliaus kalendorius" }, + { "calendarname.islamic", + "Islamo kalendorius" }, + { "calendarname.islamic-civil", + "Pilietinis islamo kalendorius" }, + { "calendarname.islamicc", + "Pilietinis islamo kalendorius" }, + { "calendarname.japanese", + "Japon\u0173 kalendorius" }, + { "calendarname.roc", + "Kinijos Respublikos kalendorius" }, + { "field.dayperiod", + "dienos metas" }, + { "field.era", + "era" }, + { "field.hour", + "valanda" }, + { "field.minute", + "minut\u0117" }, + { "field.month", + "m\u0117nuo" }, + { "field.second", + "sekund\u0117" }, + { "field.week", + "savait\u0117" }, + { "field.weekday", + "savait\u0117s diena" }, + { "field.year", + "metai" }, + { "field.zone", + "laiko juosta" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "y G, MMMM d, EEEE", + "G y MMMM d", + "G y MMM d", + "GGGGG yyyy-MM-dd", + } + }, + { "java.time.long.Eras", + new String[] { + "prie\u0161 Krist\u0173", + "po Kristaus", + } + }, + { "java.time.short.Eras", + new String[] { + "pr.Kr.", + "po.Kr.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv.java b/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv.java index 208257a7638..fbba0219f58 100644 --- a/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv.java +++ b/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv.java @@ -76,11 +76,11 @@ package sun.text.resources.lv; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_lv extends ListResourceBundle { +public class FormatData_lv extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,23 @@ public class FormatData_lv extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "sv\u0113tdiena", // Sunday @@ -211,41 +228,6 @@ public class FormatData_lv extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "islamic.MonthNames", - new String[] { - "muharams", - "safars", - "1. rab\u012b", - "2. rab\u012b", - "1. d\u017eum\u0101d\u0101", - "2. d\u017eum\u0101d\u0101", - "rad\u017eabs", - "\u0161abans", - "ramad\u0101ns", - "\u0161auvals", - "du al-kid\u0101", - "du al-hid\u017e\u0101", - "", - } - }, - { "calendarname.islamic-civil", "isl\u0101ma pilso\u0146u kalend\u0101rs" }, - { "calendarname.islamicc", "isl\u0101ma pilso\u0146u kalend\u0101rs" }, - { "calendarname.islamic", "isl\u0101ma kalend\u0101rs" }, - { "calendarname.japanese", "jap\u0101\u0146u kalend\u0101rs" }, - { "calendarname.gregorian", "Gregora kalend\u0101rs" }, - { "calendarname.gregory", "Gregora kalend\u0101rs" }, - { "calendarname.roc", "\u0136\u012bnas Republikas kalend\u0101rs" }, - { "calendarname.buddhist", "budistu kalend\u0101rs" }, - { "field.era", "\u0113ra" }, - { "field.year", "Gads" }, - { "field.month", "M\u0113nesis" }, - { "field.week", "Ned\u0113\u013ca" }, - { "field.weekday", "Ned\u0113\u013cas diena" }, - { "field.dayperiod", "Dayperiod" }, - { "field.hour", "Stundas" }, - { "field.minute", "Min\u016btes" }, - { "field.second", "Sekundes" }, - { "field.zone", "Josla" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv_LV.java b/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv_LV.java index f9940bb39c4..bffe5b8cd3e 100644 --- a/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv_LV.java +++ b/jdk/src/share/classes/sun/text/resources/lv/FormatData_lv_LV.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.lv; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_lv_LV extends ListResourceBundle { +public class FormatData_lv_LV extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/lv/JavaTimeSupplementary_lv.java b/jdk/src/share/classes/sun/text/resources/lv/JavaTimeSupplementary_lv.java new file mode 100644 index 00000000000..f721b73553b --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/lv/JavaTimeSupplementary_lv.java @@ -0,0 +1,163 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.lv; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_lv extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "C1", + "C2", + "C3", + "C4", + } + }, + { "QuarterNames", + new String[] { + "1. ceturksnis", + "2. ceturksnis", + "3. ceturksnis", + "4. ceturksnis", + } + }, + { "QuarterNarrows", + new String[] { + "1.", + "2.", + "3.", + "4.", + } + }, + { "calendarname.buddhist", + "budistu kalend\u0101rs" }, + { "calendarname.gregorian", + "Gregora kalend\u0101rs" }, + { "calendarname.gregory", + "Gregora kalend\u0101rs" }, + { "calendarname.islamic", + "isl\u0101ma kalend\u0101rs" }, + { "calendarname.islamic-civil", + "isl\u0101ma pilso\u0146u kalend\u0101rs" }, + { "calendarname.islamicc", + "isl\u0101ma pilso\u0146u kalend\u0101rs" }, + { "calendarname.japanese", + "jap\u0101\u0146u kalend\u0101rs" }, + { "calendarname.roc", + "\u0136\u012bnas Republikas kalend\u0101rs" }, + { "field.dayperiod", + "Dayperiod" }, + { "field.era", + "\u0113ra" }, + { "field.hour", + "Stundas" }, + { "field.minute", + "Min\u016btes" }, + { "field.month", + "M\u0113nesis" }, + { "field.second", + "Sekundes" }, + { "field.week", + "Ned\u0113\u013ca" }, + { "field.weekday", + "Ned\u0113\u013cas diena" }, + { "field.year", + "Gads" }, + { "field.zone", + "Josla" }, + { "islamic.MonthNames", + new String[] { + "muharams", + "safars", + "1. rab\u012b", + "2. rab\u012b", + "1. d\u017eum\u0101d\u0101", + "2. d\u017eum\u0101d\u0101", + "rad\u017eabs", + "\u0161abans", + "ramad\u0101ns", + "\u0161auvals", + "du al-kid\u0101", + "du al-hid\u017e\u0101", + "", + } + }, + { "java.time.long.Eras", + new String[] { + "pirms m\u016bsu \u0113ras", + "m\u016bsu \u0113r\u0101", + } + }, + { "java.time.short.Eras", + new String[] { + "pm\u0113", + "m\u0113", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk.java b/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk.java index 1c7b8e0d9d4..cb2d06df46c 100644 --- a/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk.java +++ b/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk.java @@ -76,11 +76,11 @@ package sun.text.resources.mk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_mk extends ListResourceBundle { +public class FormatData_mk extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ public class FormatData_mk extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u0458", + "\u0444", + "\u043c", + "\u0430", + "\u043c", + "\u0458", + "\u0458", + "\u0430", + "\u0441", + "\u043e", + "\u043d", + "\u0434", + "", + } + }, { "DayNames", new String[] { "\u043d\u0435\u0434\u0435\u043b\u0430", // Sunday @@ -194,24 +211,6 @@ public class FormatData_mk extends ListResourceBundle { } }, { "DateTimePatternChars", "GuMtkHmsSEDFwWahKzZ" }, - { "calendarname.islamic-civil", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamicc", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.roc", "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u043d\u0430" }, - { "calendarname.islamic", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.buddhist", "\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.japanese", "\u0408\u0430\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregorian", "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregory", "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "field.era", "\u0415\u0440\u0430" }, - { "field.year", "\u0433\u043e\u0434\u0438\u043d\u0430" }, - { "field.month", "\u041c\u0435\u0441\u0435\u0446" }, - { "field.week", "\u041d\u0435\u0434\u0435\u043b\u0430" }, - { "field.weekday", "\u0414\u0435\u043d \u0432\u043e \u043d\u0435\u0434\u0435\u043b\u0430\u0442\u0430" }, - { "field.dayperiod", "\u043f\u0440\u0435\u0442\u043f\u043b\u0430\u0434\u043d\u0435/\u043f\u043e\u043f\u043b\u0430\u0434\u043d\u0435" }, - { "field.hour", "\u0427\u0430\u0441" }, - { "field.minute", "\u041c\u0438\u043d\u0443\u0442\u0430" }, - { "field.second", "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, - { "field.zone", "\u0437\u043e\u043d\u0430" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk_MK.java b/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk_MK.java index c6a281764f8..a27812beea6 100644 --- a/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk_MK.java +++ b/jdk/src/share/classes/sun/text/resources/mk/FormatData_mk_MK.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.mk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_mk_MK extends ListResourceBundle { +public class FormatData_mk_MK extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/mk/JavaTimeSupplementary_mk.java b/jdk/src/share/classes/sun/text/resources/mk/JavaTimeSupplementary_mk.java new file mode 100644 index 00000000000..b70bf87e435 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/mk/JavaTimeSupplementary_mk.java @@ -0,0 +1,132 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.mk; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_mk extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "\u043f\u0440\u0432\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0432\u0442\u043e\u0440\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0442\u0440\u0435\u0442\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0447\u0435\u0442\u0432\u0440\u0442\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + } + }, + { "calendarname.buddhist", + "\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregorian", + "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregory", + "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic-civil", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamicc", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.japanese", + "\u0408\u0430\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.roc", + "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u043d\u0430" }, + { "field.dayperiod", + "\u043f\u0440\u0435\u0442\u043f\u043b\u0430\u0434\u043d\u0435/\u043f\u043e\u043f\u043b\u0430\u0434\u043d\u0435" }, + { "field.era", + "\u0415\u0440\u0430" }, + { "field.hour", + "\u0427\u0430\u0441" }, + { "field.minute", + "\u041c\u0438\u043d\u0443\u0442\u0430" }, + { "field.month", + "\u041c\u0435\u0441\u0435\u0446" }, + { "field.second", + "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, + { "field.week", + "\u041d\u0435\u0434\u0435\u043b\u0430" }, + { "field.weekday", + "\u0414\u0435\u043d \u0432\u043e \u043d\u0435\u0434\u0435\u043b\u0430\u0442\u0430" }, + { "field.year", + "\u0433\u043e\u0434\u0438\u043d\u0430" }, + { "field.zone", + "\u0437\u043e\u043d\u0430" }, + { "java.time.short.Eras", + new String[] { + "\u043f\u0440.\u043d.\u0435.", + "\u0430\u0435.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms.java b/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms.java index 78d0cb03dc6..4470069d9c6 100644 --- a/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms.java +++ b/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms.java @@ -40,9 +40,9 @@ package sun.text.resources.ms; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ms extends ListResourceBundle { +public class FormatData_ms extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", @@ -79,6 +79,40 @@ public class FormatData_ms extends ListResourceBundle { "", } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "O", + "S", + "O", + "N", + "D", + "", + } + }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "O", + "S", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthNarrows", new String[] { "J", @@ -189,71 +223,6 @@ public class FormatData_ms extends ListResourceBundle { "{1} {0}", } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d MMMM y G", - "d MMMM y G", - "dd/MM/y G", - "d/MM/y G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d MMMM y G", - "d MMMM y G", - "dd/MM/y G", - "d/MM/y G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d MMMM y G", - "d MMMM y G", - "dd/MM/y G", - "d/MM/y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d MMMM y GGGG", - "d MMMM y GGGG", - "dd/MM/y GGGG", - "d/MM/y GGGG", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, d MMMM y G", - "d MMMM y G", - "dd/MM/y G", - "d/MM/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, d MMMM y GGGG", - "d MMMM y GGGG", - "dd/MM/y GGGG", - "d/MM/y GGGG", - } - }, - { "calendarname.islamic-civil", "Kalendar Sivil Islam" }, - { "calendarname.islamicc", "Kalendar Sivil Islam" }, - { "calendarname.islamic", "Kalendar Islam" }, - { "calendarname.buddhist", "Kalendar Buddha" }, - { "calendarname.japanese", "Kalendar Jepun" }, - { "calendarname.roc", "Kalendar Minguo" }, - { "calendarname.gregorian", "Kalendar Gregory" }, - { "calendarname.gregory", "Kalendar Gregory" }, - { "field.year", "Tahun" }, - { "field.month", "Bulan" }, - { "field.week", "Minggu" }, - { "field.weekday", "Hari dalam Minggu" }, - { "field.dayperiod", "PG/PTG" }, - { "field.hour", "Jam" }, - { "field.minute", "Minit" }, - { "field.second", "Kedua" }, - { "field.zone", "Zon Waktu" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms_MY.java b/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms_MY.java index 27a9b6fd9d8..0a6181e3395 100644 --- a/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms_MY.java +++ b/jdk/src/share/classes/sun/text/resources/ms/FormatData_ms_MY.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.ms; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ms_MY extends ListResourceBundle { +public class FormatData_ms_MY extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", diff --git a/jdk/src/share/classes/sun/text/resources/ms/JavaTimeSupplementary_ms.java b/jdk/src/share/classes/sun/text/resources/ms/JavaTimeSupplementary_ms.java new file mode 100644 index 00000000000..85b3f18e8ba --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/ms/JavaTimeSupplementary_ms.java @@ -0,0 +1,186 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ms; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ms extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Suku 1", + "Suku Ke-2", + "Suku Ke-3", + "Suku Ke-4", + } + }, + { "QuarterNames", + new String[] { + "Suku pertama", + "Suku Ke-2", + "Suku Ke-3", + "Suku Ke-4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Kalendar Buddha" }, + { "calendarname.gregorian", + "Kalendar Gregory" }, + { "calendarname.gregory", + "Kalendar Gregory" }, + { "calendarname.islamic", + "Kalendar Islam" }, + { "calendarname.islamic-civil", + "Kalendar Sivil Islam" }, + { "calendarname.islamicc", + "Kalendar Sivil Islam" }, + { "calendarname.japanese", + "Kalendar Jepun" }, + { "calendarname.roc", + "Kalendar Minguo" }, + { "field.dayperiod", + "PG/PTG" }, + { "field.hour", + "Jam" }, + { "field.minute", + "Minit" }, + { "field.month", + "Bulan" }, + { "field.second", + "Kedua" }, + { "field.week", + "Minggu" }, + { "field.weekday", + "Hari dalam Minggu" }, + { "field.year", + "Tahun" }, + { "field.zone", + "Zon Waktu" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y GGGG", + "d MMMM y GGGG", + "dd/MM/y GGGG", + "d/MM/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "dd/MM/y G", + "d/MM/y G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "dd/MM/y G", + "d/MM/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "dd/MM/y G", + "d/MM/y G", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d MMMM y G", + "dd/MM/y G", + "d/MM/y G", + } + }, + { "java.time.short.Eras", + new String[] { + "BCE", + "CE", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM y GGGG", + "d MMMM y GGGG", + "dd/MM/y GGGG", + "d/MM/y GGGG", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt.java b/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt.java index c702b6cdc9e..056762fff14 100644 --- a/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt.java +++ b/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt.java @@ -40,9 +40,9 @@ package sun.text.resources.mt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_mt extends ListResourceBundle { +public class FormatData_mt extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", @@ -79,6 +79,23 @@ public class FormatData_mt extends ListResourceBundle { "", } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "\u0120", + "L", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "Il-\u0126add", @@ -167,22 +184,6 @@ public class FormatData_mt extends ListResourceBundle { "{1} {0}", } }, - { "calendarname.islamic-civil", "Kalendarju Islamiku-\u010aivili" }, - { "calendarname.islamicc", "Kalendarju Islamiku-\u010aivili" }, - { "calendarname.islamic", "Kalendarju Islamiku" }, - { "calendarname.buddhist", "Kalendarju Buddist" }, - { "calendarname.japanese", "Kalendarju \u0120appuni\u017c" }, - { "calendarname.gregorian", "Kalendarju Gregorjan" }, - { "calendarname.gregory", "Kalendarju Gregorjan" }, - { "field.era", "Epoka" }, - { "field.year", "Sena" }, - { "field.month", "Xahar" }, - { "field.week", "\u0120img\u0127a" }, - { "field.weekday", "Jum tal-\u0120img\u0127a" }, - { "field.hour", "Sieg\u0127a" }, - { "field.minute", "Minuta" }, - { "field.second", "Sekonda" }, - { "field.zone", "\u017bona" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt_MT.java b/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt_MT.java index 0671cf2f89b..d060d5cd638 100644 --- a/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt_MT.java +++ b/jdk/src/share/classes/sun/text/resources/mt/FormatData_mt_MT.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.mt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_mt_MT extends ListResourceBundle { +public class FormatData_mt_MT extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "NumberPatterns", diff --git a/jdk/src/share/classes/sun/text/resources/mt/JavaTimeSupplementary_mt.java b/jdk/src/share/classes/sun/text/resources/mt/JavaTimeSupplementary_mt.java new file mode 100644 index 00000000000..2e895e7e7fc --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/mt/JavaTimeSupplementary_mt.java @@ -0,0 +1,134 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.mt; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_mt extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "calendarname.buddhist", + "Kalendarju Buddist" }, + { "calendarname.gregorian", + "Kalendarju Gregorjan" }, + { "calendarname.gregory", + "Kalendarju Gregorjan" }, + { "calendarname.islamic", + "Kalendarju Islamiku" }, + { "calendarname.islamic-civil", + "Kalendarju Islamiku-\u010aivili" }, + { "calendarname.islamicc", + "Kalendarju Islamiku-\u010aivili" }, + { "calendarname.japanese", + "Kalendarju \u0120appuni\u017c" }, + { "field.era", + "Epoka" }, + { "field.hour", + "Sieg\u0127a" }, + { "field.minute", + "Minuta" }, + { "field.month", + "Xahar" }, + { "field.second", + "Sekonda" }, + { "field.week", + "\u0120img\u0127a" }, + { "field.weekday", + "Jum tal-\u0120img\u0127a" }, + { "field.year", + "Sena" }, + { "field.zone", + "\u017bona" }, + { "java.time.long.Eras", + new String[] { + "Qabel Kristu", + "Wara Kristu", + } + }, + { "java.time.short.Eras", + new String[] { + "QK", + "WK", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl.java b/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl.java index 5bc3964525c..461e40fbb5a 100644 --- a/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl.java +++ b/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl.java @@ -76,11 +76,11 @@ package sun.text.resources.nl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_nl extends ListResourceBundle { +public class FormatData_nl extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ public class FormatData_nl extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "zondag", // Sunday @@ -194,111 +211,6 @@ public class FormatData_nl extends ListResourceBundle { } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "dd-MM-yy G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "dd-MM-yy GGGGG", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "dd-MM-yy GGGGG", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM y GGGG", - "dd-MM-yy G", - } - }, - { "islamic.MonthNames", - new String[] { - "Moeharram", - "Safar", - "Rabi\u02bba al awal", - "Rabi\u02bba al thani", - "Joemad\u02bbal awal", - "Joemad\u02bbal thani", - "Rajab", - "Sja\u02bbaban", - "Ramadan", - "Sjawal", - "Doe al ka\u02bbaba", - "Doe al hizja", - "", - } - }, - { "islamic.MonthAbbreviations", - new String[] { - "Moeh.", - "Saf.", - "Rab. I", - "Rab. II", - "Joem. I", - "Joem. II", - "Raj.", - "Sja.", - "Ram.", - "Sjaw.", - "Doe al k.", - "Doe al h.", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "Sa\u02bbna Hizjria", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "dd-MM-yy G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM y GGGG", - "dd-MM-yy GGGG", - } - }, - { "calendarname.islamic-civil", "Islamitische kalender (cyclisch)" }, - { "calendarname.islamicc", "Islamitische kalender (cyclisch)" }, - { "calendarname.roc", "Kalender van de Chinese Republiek" }, - { "calendarname.islamic", "Islamitische kalender" }, - { "calendarname.buddhist", "Boeddhistische kalender" }, - { "calendarname.japanese", "Japanse kalender" }, - { "calendarname.gregorian", "Gregoriaanse kalender" }, - { "calendarname.gregory", "Gregoriaanse kalender" }, - { "field.era", "Tijdperk" }, - { "field.year", "Jaar" }, - { "field.month", "Maand" }, - { "field.weekday", "Dag van de week" }, - { "field.dayperiod", "AM/PM" }, - { "field.hour", "Uur" }, - { "field.minute", "Minuut" }, - { "field.second", "Seconde" }, - { "field.zone", "Zone" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl_BE.java b/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl_BE.java index 3d5ec076a64..444b23db00e 100644 --- a/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl_BE.java +++ b/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl_BE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -40,11 +40,11 @@ package sun.text.resources.nl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_nl_BE extends ListResourceBundle { +public class FormatData_nl_BE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl_NL.java b/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl_NL.java index 94c06b5f5c8..0643a56ffc3 100644 --- a/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl_NL.java +++ b/jdk/src/share/classes/sun/text/resources/nl/FormatData_nl_NL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.nl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_nl_NL extends ListResourceBundle { +public class FormatData_nl_NL extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/nl/JavaTimeSupplementary_nl.java b/jdk/src/share/classes/sun/text/resources/nl/JavaTimeSupplementary_nl.java new file mode 100644 index 00000000000..8b111fa4a5a --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/nl/JavaTimeSupplementary_nl.java @@ -0,0 +1,240 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.nl; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_nl extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "1e kwartaal", + "2e kwartaal", + "3e kwartaal", + "4e kwartaal", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Boeddhistische kalender" }, + { "calendarname.gregorian", + "Gregoriaanse kalender" }, + { "calendarname.gregory", + "Gregoriaanse kalender" }, + { "calendarname.islamic", + "Islamitische kalender" }, + { "calendarname.islamic-civil", + "Islamitische kalender (cyclisch)" }, + { "calendarname.islamicc", + "Islamitische kalender (cyclisch)" }, + { "calendarname.japanese", + "Japanse kalender" }, + { "calendarname.roc", + "Kalender van de Chinese Republiek" }, + { "field.dayperiod", + "AM/PM" }, + { "field.era", + "Tijdperk" }, + { "field.hour", + "Uur" }, + { "field.minute", + "Minuut" }, + { "field.month", + "Maand" }, + { "field.second", + "Seconde" }, + { "field.week", + "week" }, + { "field.weekday", + "Dag van de week" }, + { "field.year", + "Jaar" }, + { "field.zone", + "Zone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "dd-MM-yy GGGG", + } + }, + { "islamic.Eras", + new String[] { + "", + "Sa\u02bbna Hizjria", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "Moeh.", + "Saf.", + "Rab. I", + "Rab. II", + "Joem. I", + "Joem. II", + "Raj.", + "Sja.", + "Ram.", + "Sjaw.", + "Doe al k.", + "Doe al h.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Moeharram", + "Safar", + "Rabi\u02bba al awal", + "Rabi\u02bba al thani", + "Joemad\u02bbal awal", + "Joemad\u02bbal thani", + "Rajab", + "Sja\u02bbaban", + "Ramadan", + "Sjawal", + "Doe al ka\u02bbaba", + "Doe al hizja", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "Sa\u02bbna Hizjria", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd-MM-yy G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd-MM-yy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd-MM-yy GGGGG", + } + }, + { "java.time.long.Eras", + new String[] { + "Voor Christus", + "na Christus", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "dd-MM-yy GGGGG", + } + }, + { "java.time.short.Eras", + new String[] { + "v. Chr.", + "n. Chr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "dd-MM-yy G", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/no/FormatData_no.java b/jdk/src/share/classes/sun/text/resources/no/FormatData_no.java index d84b057f501..3e24ebc515e 100644 --- a/jdk/src/share/classes/sun/text/resources/no/FormatData_no.java +++ b/jdk/src/share/classes/sun/text/resources/no/FormatData_no.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -40,11 +40,11 @@ package sun.text.resources.no; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_no extends ListResourceBundle { +public class FormatData_no extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -65,6 +65,23 @@ public class FormatData_no extends ListResourceBundle { "" // month 13 if applicable } }, + { "standalone.MonthNames", + new String[] { + "januar", + "februar", + "mars", + "april", + "mai", + "juni", + "juli", + "august", + "september", + "oktober", + "november", + "desember", + "", + } + }, { "MonthAbbreviations", new String[] { "jan", // abb january @@ -82,6 +99,57 @@ public class FormatData_no extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "jan", + "feb", + "mar", + "apr", + "mai", + "jun", + "jul", + "aug", + "sep", + "okt", + "nov", + "des", + "", + } + }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "s\u00f8ndag", // Sunday @@ -93,6 +161,17 @@ public class FormatData_no extends ListResourceBundle { "l\u00f8rdag" // Saturday } }, + { "standalone.DayNames", + new String[] { + "s\u00f8ndag", + "mandag", + "tirsdag", + "onsdag", + "torsdag", + "fredag", + "l\u00f8rdag", + } + }, { "DayAbbreviations", new String[] { "s\u00f8", // abb Sunday @@ -104,6 +183,39 @@ public class FormatData_no extends ListResourceBundle { "l\u00f8" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "s\u00f8.", + "ma.", + "ti.", + "on.", + "to.", + "fr.", + "l\u00f8.", + } + }, + { "DayNarrows", + new String[] { + "S", + "M", + "T", + "O", + "T", + "F", + "L", + } + }, + { "standalone.DayNarrows", + new String[] { + "S", + "M", + "T", + "O", + "T", + "F", + "L", + } + }, { "NumberElements", new String[] { ",", // decimal separator diff --git a/jdk/src/share/classes/sun/text/resources/no/FormatData_no_NO.java b/jdk/src/share/classes/sun/text/resources/no/FormatData_no_NO.java index 7c71ee5b41c..9275a12c09f 100644 --- a/jdk/src/share/classes/sun/text/resources/no/FormatData_no_NO.java +++ b/jdk/src/share/classes/sun/text/resources/no/FormatData_no_NO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.no; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_no_NO extends ListResourceBundle { +public class FormatData_no_NO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/no/FormatData_no_NO_NY.java b/jdk/src/share/classes/sun/text/resources/no/FormatData_no_NO_NY.java index 4ec2bbde88d..3cf98aeb763 100644 --- a/jdk/src/share/classes/sun/text/resources/no/FormatData_no_NO_NY.java +++ b/jdk/src/share/classes/sun/text/resources/no/FormatData_no_NO_NY.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.no; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_no_NO_NY extends ListResourceBundle { +public class FormatData_no_NO_NY extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/no/JavaTimeSupplementary_no.java b/jdk/src/share/classes/sun/text/resources/no/JavaTimeSupplementary_no.java new file mode 100644 index 00000000000..2ed407fcaf3 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/no/JavaTimeSupplementary_no.java @@ -0,0 +1,194 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.no; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_no extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "1. kvartal", + "2. kvartal", + "3. kvartal", + "4. kvartal", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "buddhistisk kalender" }, + { "calendarname.gregorian", + "gregoriansk kalender" }, + { "calendarname.gregory", + "gregoriansk kalender" }, + { "calendarname.islamic", + "islamsk kalender" }, + { "calendarname.islamic-civil", + "islamsk sivil kalender" }, + { "calendarname.islamicc", + "islamsk sivil kalender" }, + { "calendarname.japanese", + "japansk kalender" }, + { "calendarname.roc", + "kalender for Republikken Kina" }, + { "field.dayperiod", + "AM/PM" }, + { "field.era", + "tidsalder" }, + { "field.hour", + "time" }, + { "field.minute", + "minutt" }, + { "field.month", + "m\u00e5ned" }, + { "field.second", + "sekund" }, + { "field.week", + "uke" }, + { "field.weekday", + "ukedag" }, + { "field.year", + "\u00e5r" }, + { "field.zone", + "sone" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d.M y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M yyyy", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M y G", + } + }, + { "java.time.long.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d. MMMM y G", + "d. MMMM y G", + "d. MMM y G", + "d.M y G", + } + }, + { "java.time.short.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d. MMMM y GGGG", + "d. MMMM y GGGG", + "d. MMM y GGGG", + "d.M y GGGG", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl.java b/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl.java index 630337d60fa..0df28fd4850 100644 --- a/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl.java +++ b/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl.java @@ -76,11 +76,11 @@ package sun.text.resources.pl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_pl extends ListResourceBundle { +public class FormatData_pl extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,57 @@ public class FormatData_pl extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "sty", + "lut", + "mar", + "kwi", + "maj", + "cze", + "lip", + "sie", + "wrz", + "pa\u017a", + "lis", + "gru", + "", + } + }, + { "MonthNarrows", + new String[] { + "s", + "l", + "m", + "k", + "m", + "c", + "l", + "s", + "w", + "p", + "l", + "g", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "s", + "l", + "m", + "k", + "m", + "c", + "l", + "s", + "w", + "p", + "l", + "g", + "", + } + }, { "DayNames", new String[] { "niedziela", // Sunday @@ -146,6 +197,17 @@ public class FormatData_pl extends ListResourceBundle { "sobota" // Saturday } }, + { "standalone.DayNames", + new String[] { + "niedziela", + "poniedzia\u0142ek", + "wtorek", + "\u015broda", + "czwartek", + "pi\u0105tek", + "sobota", + } + }, { "DayAbbreviations", new String[] { "N", // abb Sunday @@ -157,6 +219,17 @@ public class FormatData_pl extends ListResourceBundle { "So" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "niedz.", + "pon.", + "wt.", + "\u015br.", + "czw.", + "pt.", + "sob.", + } + }, { "DayNarrows", new String[] { "N", @@ -168,6 +241,17 @@ public class FormatData_pl extends ListResourceBundle { "S", } }, + { "standalone.DayNarrows", + new String[] { + "N", + "P", + "W", + "\u015a", + "C", + "P", + "S", + } + }, { "Eras", new String[] { // era strings "p.n.e.", @@ -211,71 +295,6 @@ public class FormatData_pl extends ListResourceBundle { } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "G y MMMM d", - "d MMM y G", - "dd.MM.yyyy G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM y G", - "dd.MM.yyyy G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM y G", - "dd.MM.yyyy G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d MMMM, y GGGG", - "d MMMM, y GGGG", - "d MMM y GGGG", - "dd.MM.yyyy GGGG", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, d MMMM, y G", - "d MMMM, y G", - "d MMM y G", - "dd.MM.yyyy G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, d MMMM, y GGGG", - "d MMMM, y GGGG", - "d MMM y GGGG", - "dd.MM.yyyy GGGG", - } - }, - { "calendarname.islamic-civil", "kalendarz islamski (metoda obliczeniowa)" }, - { "calendarname.islamicc", "kalendarz islamski (metoda obliczeniowa)" }, - { "calendarname.islamic", "kalendarz islamski (metoda wzrokowa)" }, - { "calendarname.japanese", "kalendarz japo\u0144ski" }, - { "calendarname.gregorian", "kalendarz gregoria\u0144ski" }, - { "calendarname.gregory", "kalendarz gregoria\u0144ski" }, - { "calendarname.roc", "kalendarz Republiki Chi\u0144skiej" }, - { "calendarname.buddhist", "kalendarz buddyjski" }, - { "field.era", "Era" }, - { "field.year", "Rok" }, - { "field.month", "Miesi\u0105c" }, - { "field.week", "Tydzie\u0144" }, - { "field.weekday", "Dzie\u0144 tygodnia" }, - { "field.hour", "Godzina" }, - { "field.minute", "Minuta" }, - { "field.second", "Sekunda" }, - { "field.zone", "Strefa" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl_PL.java b/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl_PL.java index bf3f3381efd..36a002c4337 100644 --- a/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl_PL.java +++ b/jdk/src/share/classes/sun/text/resources/pl/FormatData_pl_PL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.pl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_pl_PL extends ListResourceBundle { +public class FormatData_pl_PL extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/pl/JavaTimeSupplementary_pl.java b/jdk/src/share/classes/sun/text/resources/pl/JavaTimeSupplementary_pl.java new file mode 100644 index 00000000000..21105070537 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/pl/JavaTimeSupplementary_pl.java @@ -0,0 +1,257 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.pl; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_pl extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "I kwarta\u0142", + "II kwarta\u0142", + "III kwarta\u0142", + "IV kwarta\u0142", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "kalendarz buddyjski" }, + { "calendarname.gregorian", + "kalendarz gregoria\u0144ski" }, + { "calendarname.gregory", + "kalendarz gregoria\u0144ski" }, + { "calendarname.islamic", + "kalendarz islamski (metoda wzrokowa)" }, + { "calendarname.islamic-civil", + "kalendarz islamski (metoda obliczeniowa)" }, + { "calendarname.islamicc", + "kalendarz islamski (metoda obliczeniowa)" }, + { "calendarname.japanese", + "kalendarz japo\u0144ski" }, + { "calendarname.roc", + "kalendarz Republiki Chi\u0144skiej" }, + { "field.dayperiod", + "Dayperiod" }, + { "field.era", + "Era" }, + { "field.hour", + "Godzina" }, + { "field.minute", + "Minuta" }, + { "field.month", + "Miesi\u0105c" }, + { "field.second", + "Sekunda" }, + { "field.week", + "Tydzie\u0144" }, + { "field.weekday", + "Dzie\u0144 tygodnia" }, + { "field.year", + "Rok" }, + { "field.zone", + "Strefa" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d MMMM, y GGGG", + "d MMMM, y GGGG", + "d MMM y GGGG", + "dd.MM.yyyy GGGG", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "Muh.", + "Saf.", + "Rab. I", + "Rab. II", + "D\u017cu. I", + "D\u017cu. II", + "Ra.", + "Sza.", + "Ram.", + "Szaw.", + "Zu al-k.", + "Zu al-h.", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "Muharram", + "Safar", + "Rabi I", + "Rabi II", + "D\u017cumada I", + "D\u017cumada II", + "Rad\u017cab", + "Szaban", + "Ramadan", + "Szawwal", + "Zu al-kada", + "Zu al-hid\u017cd\u017ca", + "", + } + }, + { "islamic.MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.long.Eras", + new String[] { + "p.n.e.", + "n.e.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM, y G", + "d MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.short.Eras", + new String[] { + "p.n.e.", + "n.e.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM, y GGGG", + "d MMMM, y GGGG", + "d MMM y GGGG", + "dd.MM.yyyy GGGG", + } + }, + { "roc.Eras", + new String[] { + "Przed ROC", + "ROC", + } + }, + { "roc.short.Eras", + new String[] { + "Przed ROC", + "ROC", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java b/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java index a9eae050312..ec36c0c7045 100644 --- a/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java +++ b/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt.java @@ -76,11 +76,11 @@ package sun.text.resources.pt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_pt extends ListResourceBundle { +public class FormatData_pt extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -118,6 +118,23 @@ public class FormatData_pt extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "Domingo", // Sunday @@ -151,6 +168,18 @@ public class FormatData_pt extends ListResourceBundle { "S", } }, + { "long.Eras", + new String[] { + "Antes de Cristo", + "Ano do Senhor", + } + }, + { "Eras", + new String[] { + "a.C.", + "d.C.", + } + }, { "NumberElements", new String[] { ",", // decimal al separator @@ -188,64 +217,6 @@ public class FormatData_pt extends ListResourceBundle { } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "G y MMMM d", - "G y MMM d", - "d/M/yy", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/yyyy G", - "d/M/yyyy", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y GGGG", - "d 'de' MMMM 'de' y GGGG", - "dd/MM/yyyy GGGG", - "d/M/yyyy", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y G", - "d 'de' MMMM 'de' y G", - "dd/MM/yyyy G", - "d/M/yyyy", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, d 'de' MMMM 'de' y GGGG", - "d 'de' MMMM 'de' y GGGG", - "dd/MM/yyyy GGGG", - "d/M/yyyy", - } - }, - { "calendarname.islamic-civil", "Calend\u00e1rio Civil Isl\u00e2mico" }, - { "calendarname.islamicc", "Calend\u00e1rio Civil Isl\u00e2mico" }, - { "calendarname.islamic", "Calend\u00e1rio Isl\u00e2mico" }, - { "calendarname.japanese", "Calend\u00e1rio Japon\u00eas" }, - { "calendarname.gregorian", "Calend\u00e1rio Gregoriano" }, - { "calendarname.gregory", "Calend\u00e1rio Gregoriano" }, - { "calendarname.roc", "Calend\u00e1rio da Rep\u00fablica da China" }, - { "calendarname.buddhist", "Calend\u00e1rio Budista" }, - { "field.era", "Era" }, - { "field.year", "Ano" }, - { "field.month", "M\u00eas" }, - { "field.week", "Semana" }, - { "field.weekday", "Dia da semana" }, - { "field.dayperiod", "Per\u00edodo do dia" }, - { "field.hour", "Hora" }, - { "field.minute", "Minuto" }, - { "field.second", "Segundo" }, - { "field.zone", "Fuso" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt_BR.java b/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt_BR.java index 1d4ddf2b481..494b5abaa00 100644 --- a/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt_BR.java +++ b/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt_BR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.pt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_pt_BR extends ListResourceBundle { +public class FormatData_pt_BR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt_PT.java b/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt_PT.java index 13b4f2090e4..8ebff2e1ed0 100644 --- a/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt_PT.java +++ b/jdk/src/share/classes/sun/text/resources/pt/FormatData_pt_PT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.pt; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_pt_PT extends ListResourceBundle { +public class FormatData_pt_PT extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/pt/JavaTimeSupplementary_pt.java b/jdk/src/share/classes/sun/text/resources/pt/JavaTimeSupplementary_pt.java new file mode 100644 index 00000000000..6b8e73e5d2b --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/pt/JavaTimeSupplementary_pt.java @@ -0,0 +1,206 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.pt; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_pt extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "T1", + "T2", + "T3", + "T4", + } + }, + { "QuarterNames", + new String[] { + "1\u00ba trimestre", + "2\u00ba trimestre", + "3\u00ba trimestre", + "4\u00ba trimestre", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Calend\u00e1rio Budista" }, + { "calendarname.gregorian", + "Calend\u00e1rio Gregoriano" }, + { "calendarname.gregory", + "Calend\u00e1rio Gregoriano" }, + { "calendarname.islamic", + "Calend\u00e1rio Isl\u00e2mico" }, + { "calendarname.islamic-civil", + "Calend\u00e1rio Civil Isl\u00e2mico" }, + { "calendarname.islamicc", + "Calend\u00e1rio Civil Isl\u00e2mico" }, + { "calendarname.japanese", + "Calend\u00e1rio Japon\u00eas" }, + { "calendarname.roc", + "Calend\u00e1rio da Rep\u00fablica da China" }, + { "field.dayperiod", + "Per\u00edodo do dia" }, + { "field.era", + "Era" }, + { "field.hour", + "Hora" }, + { "field.minute", + "Minuto" }, + { "field.month", + "M\u00eas" }, + { "field.second", + "Segundo" }, + { "field.week", + "Semana" }, + { "field.weekday", + "Dia da semana" }, + { "field.year", + "Ano" }, + { "field.zone", + "Fuso" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/yyyy GGGG", + "d/M/yyyy", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/yyyy", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/yyyy", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM y G", + "d 'de' MMMM 'de' y G", + "d MMM y G", + "d/M/yy", + } + }, + { "java.time.long.Eras", + new String[] { + "Antes de Cristo", + "Ano do Senhor", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/yyyy", + } + }, + { "java.time.short.Eras", + new String[] { + "a.C.", + "d.C.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/yyyy GGGG", + "d/M/yyyy", + } + }, + { "roc.Eras", + new String[] { + "Antes de R.O.C.", + "R.O.C.", + } + }, + { "roc.short.Eras", + new String[] { + "Antes de R.O.C.", + "R.O.C.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/pt/JavaTimeSupplementary_pt_PT.java b/jdk/src/share/classes/sun/text/resources/pt/JavaTimeSupplementary_pt_PT.java new file mode 100644 index 00000000000..dedc886de7f --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/pt/JavaTimeSupplementary_pt_PT.java @@ -0,0 +1,134 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.pt; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_pt_PT extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "1.\u00ba trimestre", + "2.\u00ba trimestre", + "3.\u00ba trimestre", + "4.\u00ba trimestre", + } + }, + { "calendarname.islamic-civil", + "Calend\u00e1rio Isl\u00e2mico/Civil" }, + { "calendarname.islamicc", + "Calend\u00e1rio Isl\u00e2mico/Civil" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/yyyy GGGG", + "d/M/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/y G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/y G", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y G", + "d 'de' MMMM 'de' y G", + "dd/MM/yyyy G", + "d/M/y G", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d 'de' MMMM 'de' y GGGG", + "d 'de' MMMM 'de' y GGGG", + "dd/MM/yyyy GGGG", + "d/M/y GGGG", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro.java b/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro.java index d1ab35ce523..b8dee7c5500 100644 --- a/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro.java +++ b/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro.java @@ -76,11 +76,11 @@ package sun.text.resources.ro; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ro extends ListResourceBundle { +public class FormatData_ro extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -101,6 +101,23 @@ public class FormatData_ro extends ListResourceBundle { "" // month 13 if applicable } }, + { "standalone.MonthNames", + new String[] { + "ianuarie", + "februarie", + "martie", + "aprilie", + "mai", + "iunie", + "iulie", + "august", + "septembrie", + "octombrie", + "noiembrie", + "decembrie", + "", + } + }, { "MonthAbbreviations", new String[] { "Ian", // abb january @@ -118,6 +135,40 @@ public class FormatData_ro extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "ian.", + "feb.", + "mar.", + "apr.", + "mai", + "iun.", + "iul.", + "aug.", + "sept.", + "oct.", + "nov.", + "dec.", + "", + } + }, + { "MonthNarrows", + new String[] { + "I", + "F", + "M", + "A", + "M", + "I", + "I", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "standalone.MonthNarrows", new String[] { "I", @@ -146,6 +197,17 @@ public class FormatData_ro extends ListResourceBundle { "s\u00e2mb\u0103t\u0103" // Saturday } }, + { "standalone.DayNames", + new String[] { + "duminic\u0103", + "luni", + "mar\u021bi", + "miercuri", + "joi", + "vineri", + "s\u00e2mb\u0103t\u0103", + } + }, { "DayAbbreviations", new String[] { "D", // abb Sunday @@ -157,18 +219,28 @@ public class FormatData_ro extends ListResourceBundle { "S" // abb Saturday } }, - // commented out DayNarrows because most names are contributed. -// { "DayNarrows", -// new String[] { -// "D", -// "", -// "", -// "", -// "", -// "", -// "", -// } -// }, + { "standalone.DayAbbreviations", + new String[] { + "Du", + "Lu", + "Ma", + "Mi", + "Jo", + "Vi", + "S\u00e2", + } + }, + { "DayNarrows", + new String[] { + "D", + "L", + "M", + "M", + "J", + "V", + "S", + } + }, { "standalone.DayNarrows", new String[] { "D", @@ -223,32 +295,6 @@ public class FormatData_ro extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, G y MMMM dd", - "d MMMM y G", - "d MMM y G", - "d/M/yyyy", - } - }, - { "calendarname.islamic-civil", "calendar islamic civil" }, - { "calendarname.islamicc", "calendar islamic civil" }, - { "calendarname.roc", "calendar al Republicii Chineze" }, - { "calendarname.islamic", "calendar islamic" }, - { "calendarname.buddhist", "calendar budist" }, - { "calendarname.japanese", "calendar japonez" }, - { "calendarname.gregorian", "calendar gregorian" }, - { "calendarname.gregory", "calendar gregorian" }, - { "field.era", "er\u0103" }, - { "field.year", "an" }, - { "field.month", "lun\u0103" }, - { "field.week", "s\u0103pt\u0103m\u00e2n\u0103" }, - { "field.weekday", "zi a s\u0103pt\u0103m\u00e2nii" }, - { "field.dayperiod", "perioada zilei" }, - { "field.hour", "or\u0103" }, - { "field.minute", "minut" }, - { "field.second", "secund\u0103" }, - { "field.zone", "zon\u0103" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro_RO.java b/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro_RO.java index d6789ccd13e..c3ea414998d 100644 --- a/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro_RO.java +++ b/jdk/src/share/classes/sun/text/resources/ro/FormatData_ro_RO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.ro; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ro_RO extends ListResourceBundle { +public class FormatData_ro_RO extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/ro/JavaTimeSupplementary_ro.java b/jdk/src/share/classes/sun/text/resources/ro/JavaTimeSupplementary_ro.java new file mode 100644 index 00000000000..c2d24e08786 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/ro/JavaTimeSupplementary_ro.java @@ -0,0 +1,166 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ro; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ro extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "trim. I", + "trim. II", + "trim. III", + "trim. IV", + } + }, + { "QuarterNames", + new String[] { + "trimestrul I", + "trimestrul al II-lea", + "trimestrul al III-lea", + "trimestrul al IV-lea", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "T4", + } + }, + { "calendarname.buddhist", + "calendar budist" }, + { "calendarname.gregorian", + "calendar gregorian" }, + { "calendarname.gregory", + "calendar gregorian" }, + { "calendarname.islamic", + "calendar islamic" }, + { "calendarname.islamic-civil", + "calendar islamic civil" }, + { "calendarname.islamicc", + "calendar islamic civil" }, + { "calendarname.japanese", + "calendar japonez" }, + { "calendarname.roc", + "calendar al Republicii Chineze" }, + { "field.dayperiod", + "perioada zilei" }, + { "field.era", + "er\u0103" }, + { "field.hour", + "or\u0103" }, + { "field.minute", + "minut" }, + { "field.month", + "lun\u0103" }, + { "field.second", + "secund\u0103" }, + { "field.week", + "s\u0103pt\u0103m\u00e2n\u0103" }, + { "field.weekday", + "zi a s\u0103pt\u0103m\u00e2nii" }, + { "field.year", + "an" }, + { "field.zone", + "zon\u0103" }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM, y G", + "d MMMM y G", + "d MMM y G", + "d/M/yyyy", + } + }, + { "java.time.buddhist.long.Eras", + new String[] { + "BC", + "era budist\u0103", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "e.b.", + } + }, + { "java.time.long.Eras", + new String[] { + "\u00eenainte de Hristos", + "dup\u0103 Hristos", + } + }, + { "java.time.short.Eras", + new String[] { + "d.C.", + "\u00ee.d.C.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru.java b/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru.java index ba895954c0c..90b7df279c2 100644 --- a/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru.java +++ b/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru.java @@ -76,11 +76,11 @@ package sun.text.resources.ru; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ru extends ListResourceBundle { +public class FormatData_ru extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -152,6 +152,40 @@ public class FormatData_ru extends ListResourceBundle { "", // month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u042f", + "\u0424", + "\u041c", + "\u0410", + "\u041c", + "\u0418", + "\u0418", + "\u0410", + "\u0421", + "\u041e", + "\u041d", + "\u0414", + "", + } + }, + { "standalone.MonthNarrows", + new String[] { + "\u042f", + "\u0424", + "\u041c", + "\u0410", + "\u041c", + "\u0418", + "\u0418", + "\u0410", + "\u0421", + "\u041e", + "\u041d", + "\u0414", + "", + } + }, { "DayNames", new String[] { "\u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435", // Sunday @@ -163,6 +197,17 @@ public class FormatData_ru extends ListResourceBundle { "\u0441\u0443\u0431\u0431\u043e\u0442\u0430" // Saturday } }, + { "standalone.DayNames", + new String[] { + "\u0412\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435", + "\u041f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a", + "\u0412\u0442\u043e\u0440\u043d\u0438\u043a", + "\u0421\u0440\u0435\u0434\u0430", + "\u0427\u0435\u0442\u0432\u0435\u0440\u0433", + "\u041f\u044f\u0442\u043d\u0438\u0446\u0430", + "\u0421\u0443\u0431\u0431\u043e\u0442\u0430", + } + }, { "DayAbbreviations", new String[] { "\u0412\u0441", // abb Sunday @@ -174,6 +219,17 @@ public class FormatData_ru extends ListResourceBundle { "\u0421\u0431" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "\u0412\u0441", + "\u041f\u043d", + "\u0412\u0442", + "\u0421\u0440", + "\u0427\u0442", + "\u041f\u0442", + "\u0421\u0431", + } + }, { "DayNarrows", new String[] { "\u0412", @@ -239,88 +295,6 @@ public class FormatData_ru extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. G", - "d MMMM y\u00a0'\u0433'. G", - "dd.MM.yyyy G", - "dd.MM.yy G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. G", - "d MMMM y\u00a0'\u0433'. G", - "dd.MM.yyyy G", - "dd.MM.yy G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. G", - "d MMMM y\u00a0'\u0433'. G", - "dd.MM.yyyy G", - "dd.MM.yy G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. GGGG", - "d MMMM y\u00a0'\u0433'. GGGG", - "dd.MM.yyyy GGGG", - "dd.MM.yy GGGG", - } - }, - { "islamic.MonthNames", - new String[] { - "\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c", - "\u0421\u0430\u0444\u0430\u0440", - "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", - "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", - "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", - "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", - "\u0420\u0430\u0434\u0436\u0430\u0431", - "\u0428\u0430\u0430\u0431\u0430\u043d", - "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", - "\u0428\u0430\u0432\u0432\u0430\u043b\u044c", - "\u0417\u0443\u043b\u044c-\u041a\u0430\u0430\u0434\u0430", - "\u0417\u0443\u043b\u044c-\u0425\u0438\u0434\u0436\u0436\u0430", - "", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. G", - "d MMMM y\u00a0'\u0433'. G", - "dd.MM.yyyy G", - "dd.MM.yy G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, d MMMM y\u00a0'\u0433'. GGGG", - "d MMMM y\u00a0'\u0433'. GGGG", - "dd.MM.yyyy GGGG", - "dd.MM.yy GGGG", - } - }, - { "calendarname.islamic-civil", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.islamicc", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.islamic", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.japanese", "\u042f\u043f\u043e\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.gregorian", "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.gregory", "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.roc", "\u041a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "calendarname.buddhist", "\u0411\u0443\u0434\u0434\u0438\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, - { "field.era", "\u042d\u0440\u0430" }, - { "field.year", "\u0413\u043e\u0434" }, - { "field.month", "\u041c\u0435\u0441\u044f\u0446" }, - { "field.week", "\u041d\u0435\u0434\u0435\u043b\u044f" }, - { "field.weekday", "\u0414\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438" }, - { "field.hour", "\u0427\u0430\u0441" }, - { "field.minute", "\u041c\u0438\u043d\u0443\u0442\u0430" }, - { "field.second", "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, - { "field.zone", "\u0427\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru_RU.java b/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru_RU.java index 8663de86e8b..6efab5416b5 100644 --- a/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru_RU.java +++ b/jdk/src/share/classes/sun/text/resources/ru/FormatData_ru_RU.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.ru; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_ru_RU extends ListResourceBundle { +public class FormatData_ru_RU extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/ru/JavaTimeSupplementary_ru.java b/jdk/src/share/classes/sun/text/resources/ru/JavaTimeSupplementary_ru.java new file mode 100644 index 00000000000..54b74f0f0c6 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/ru/JavaTimeSupplementary_ru.java @@ -0,0 +1,263 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.ru; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_ru extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1-\u0439 \u043a\u0432.", + "2-\u0439 \u043a\u0432.", + "3-\u0439 \u043a\u0432.", + "4-\u0439 \u043a\u0432.", + } + }, + { "QuarterNames", + new String[] { + "1-\u0439 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "2-\u0439 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "3-\u0439 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "4-\u0439 \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u0411\u0443\u0434\u0434\u0438\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.gregorian", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.gregory", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.islamic", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.islamic-civil", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.islamicc", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.japanese", + "\u042f\u043f\u043e\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "calendarname.roc", + "\u041a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c" }, + { "field.dayperiod", + "\u0414\u041f/\u041f\u041f" }, + { "field.era", + "\u042d\u0440\u0430" }, + { "field.hour", + "\u0427\u0430\u0441" }, + { "field.minute", + "\u041c\u0438\u043d\u0443\u0442\u0430" }, + { "field.month", + "\u041c\u0435\u0441\u044f\u0446" }, + { "field.second", + "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, + { "field.week", + "\u041d\u0435\u0434\u0435\u043b\u044f" }, + { "field.weekday", + "\u0414\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438" }, + { "field.year", + "\u0413\u043e\u0434" }, + { "field.zone", + "\u0427\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. GGGG", + "d MMMM y\u00a0'\u0433'. GGGG", + "dd.MM.yyyy GGGG", + "dd.MM.yy GGGG", + } + }, + { "islamic.MonthAbbreviations", + new String[] { + "\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c", + "\u0421\u0430\u0444\u0430\u0440", + "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", + "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", + "\u0420\u0430\u0434\u0436\u0430\u0431", + "\u0428\u0430\u0430\u0431\u0430\u043d", + "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", + "\u0428\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0417\u0443\u043b\u044c-\u041a\u0430\u0430\u0434\u0430", + "\u0417\u0443\u043b\u044c-\u0425\u0438\u0434\u0436\u0436\u0430", + "", + } + }, + { "islamic.MonthNames", + new String[] { + "\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c", + "\u0421\u0430\u0444\u0430\u0440", + "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", + "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440", + "\u0420\u0430\u0434\u0436\u0430\u0431", + "\u0428\u0430\u0430\u0431\u0430\u043d", + "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", + "\u0428\u0430\u0432\u0432\u0430\u043b\u044c", + "\u0417\u0443\u043b\u044c-\u041a\u0430\u0430\u0434\u0430", + "\u0417\u0443\u043b\u044c-\u0425\u0438\u0434\u0436\u0436\u0430", + "", + } + }, + { "islamic.MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. G", + "d MMMM y\u00a0'\u0433'. G", + "dd.MM.yyyy G", + "dd.MM.yy G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. G", + "d MMMM y\u00a0'\u0433'. G", + "dd.MM.yyyy G", + "dd.MM.yy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. G", + "d MMMM y\u00a0'\u0433'. G", + "dd.MM.yyyy G", + "dd.MM.yy G", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u043d.\u044d.", + "\u042d\u043f\u043e\u0445\u0430 \u041c\u044d\u0439\u0434\u0437\u0438", + "\u042d\u043f\u043e\u0445\u0430 \u0422\u0430\u0439\u0441\u044c\u043e", + "\u0421\u044c\u043e\u0432\u0430", + "\u042d\u043f\u043e\u0445\u0430 \u0425\u044d\u0439\u0441\u044d\u0439", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u043d.\u044d.", + "\u042d\u043f\u043e\u0445\u0430 \u041c\u044d\u0439\u0434\u0437\u0438", + "\u042d\u043f\u043e\u0445\u0430 \u0422\u0430\u0439\u0441\u044c\u043e", + "\u0421\u044c\u043e\u0432\u0430", + "\u042d\u043f\u043e\u0445\u0430 \u0425\u044d\u0439\u0441\u044d\u0439", + } + }, + { "java.time.long.Eras", + new String[] { + "\u0434\u043e \u043d.\u044d.", + "\u043d.\u044d.", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. G", + "d MMMM y\u00a0'\u0433'. G", + "dd.MM.yyyy G", + "dd.MM.yy G", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0434\u043e \u043d.\u044d.", + "\u043d.\u044d.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, d MMMM y\u00a0'\u0433'. GGGG", + "d MMMM y\u00a0'\u0433'. GGGG", + "dd.MM.yyyy GGGG", + "dd.MM.yy GGGG", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk.java b/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk.java index 04f46e650ae..b55517fbb68 100644 --- a/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk.java +++ b/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk.java @@ -76,11 +76,11 @@ package sun.text.resources.sk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sk extends ListResourceBundle { +public class FormatData_sk extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -152,6 +152,23 @@ public class FormatData_sk extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "j", + "f", + "m", + "a", + "m", + "j", + "j", + "a", + "s", + "o", + "n", + "d", + "", + } + }, { "DayNames", new String[] { "Nede\u013ea", // Sunday @@ -163,6 +180,17 @@ public class FormatData_sk extends ListResourceBundle { "Sobota" // Saturday } }, + { "standalone.DayNames", + new String[] { + "nede\u013ea", + "pondelok", + "utorok", + "streda", + "\u0161tvrtok", + "piatok", + "sobota", + } + }, { "DayAbbreviations", new String[] { "Ne", // abb Sunday @@ -174,6 +202,17 @@ public class FormatData_sk extends ListResourceBundle { "So" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "ne", + "po", + "ut", + "st", + "\u0161t", + "pi", + "so", + } + }, { "DayNarrows", new String[] { "N", @@ -185,6 +224,17 @@ public class FormatData_sk extends ListResourceBundle { "S", } }, + { "standalone.DayNarrows", + new String[] { + "N", + "P", + "U", + "S", + "\u0160", + "P", + "S", + } + }, { "Eras", new String[] { // era strings "pred n.l.", @@ -228,23 +278,6 @@ public class FormatData_sk extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "calendarname.islamic-civil", "Islamsk\u00fd ob\u010diansky kalend\u00e1r" }, - { "calendarname.islamicc", "Islamsk\u00fd ob\u010diansky kalend\u00e1r" }, - { "calendarname.islamic", "Islamsk\u00fd kalend\u00e1r" }, - { "calendarname.buddhist", "Buddhistick\u00fd kalend\u00e1r" }, - { "calendarname.japanese", "Japonsk\u00fd kalend\u00e1r" }, - { "calendarname.gregorian", "Gregori\u00e1nsky kalend\u00e1r" }, - { "calendarname.gregory", "Gregori\u00e1nsky kalend\u00e1r" }, - { "field.era", "\u00c9ra" }, - { "field.year", "Rok" }, - { "field.month", "Mesiac" }, - { "field.week", "T\u00fd\u017ede\u0148" }, - { "field.weekday", "De\u0148 v t\u00fd\u017edni" }, - { "field.dayperiod", "\u010cas\u0165 d\u0148a" }, - { "field.hour", "Hodina" }, - { "field.minute", "Min\u00fata" }, - { "field.second", "Sekunda" }, - { "field.zone", "P\u00e1smo" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk_SK.java b/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk_SK.java index 9fbc6c11bee..5217cd1f9ae 100644 --- a/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk_SK.java +++ b/jdk/src/share/classes/sun/text/resources/sk/FormatData_sk_SK.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.sk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sk_SK extends ListResourceBundle { +public class FormatData_sk_SK extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/sk/JavaTimeSupplementary_sk.java b/jdk/src/share/classes/sun/text/resources/sk/JavaTimeSupplementary_sk.java new file mode 100644 index 00000000000..ac3e63833ff --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/sk/JavaTimeSupplementary_sk.java @@ -0,0 +1,140 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sk; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sk extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1. \u0161tvr\u0165rok", + "2. \u0161tvr\u0165rok", + "3. \u0161tvr\u0165rok", + "4. \u0161tvr\u0165rok", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Buddhistick\u00fd kalend\u00e1r" }, + { "calendarname.gregorian", + "Gregori\u00e1nsky kalend\u00e1r" }, + { "calendarname.gregory", + "Gregori\u00e1nsky kalend\u00e1r" }, + { "calendarname.islamic", + "Islamsk\u00fd kalend\u00e1r" }, + { "calendarname.islamic-civil", + "Islamsk\u00fd ob\u010diansky kalend\u00e1r" }, + { "calendarname.islamicc", + "Islamsk\u00fd ob\u010diansky kalend\u00e1r" }, + { "calendarname.japanese", + "Japonsk\u00fd kalend\u00e1r" }, + { "calendarname.roc", + "Kalend\u00e1r \u010c\u00ednskej republiky" }, + { "field.dayperiod", + "\u010cas\u0165 d\u0148a" }, + { "field.era", + "\u00c9ra" }, + { "field.hour", + "Hodina" }, + { "field.minute", + "Min\u00fata" }, + { "field.month", + "Mesiac" }, + { "field.second", + "Sekunda" }, + { "field.week", + "T\u00fd\u017ede\u0148" }, + { "field.weekday", + "De\u0148 v t\u00fd\u017edni" }, + { "field.year", + "Rok" }, + { "field.zone", + "P\u00e1smo" }, + { "java.time.short.Eras", + new String[] { + "pred n.l.", + "n.l.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl.java b/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl.java index 864da47c77e..cdc2a596b62 100644 --- a/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl.java +++ b/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl.java @@ -76,11 +76,11 @@ package sun.text.resources.sl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sl extends ListResourceBundle { +public class FormatData_sl extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -135,6 +135,23 @@ public class FormatData_sl extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "j", + "f", + "m", + "a", + "m", + "j", + "j", + "a", + "s", + "o", + "n", + "d", + "", + } + }, { "DayNames", new String[] { "Nedelja", // Sunday @@ -157,6 +174,17 @@ public class FormatData_sl extends ListResourceBundle { "Sob" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "ned", + "pon", + "tor", + "sre", + "\u010det", + "pet", + "sob", + } + }, { "DayNarrows", new String[] { "n", @@ -211,24 +239,6 @@ public class FormatData_sl extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "calendarname.islamic-civil", "islamski civilni koledar" }, - { "calendarname.islamicc", "islamski civilni koledar" }, - { "calendarname.roc", "kitajski dr\u017eavni koledar" }, - { "calendarname.islamic", "islamski koledar" }, - { "calendarname.buddhist", "budisti\u010dni koledar" }, - { "calendarname.japanese", "japonski koledar" }, - { "calendarname.gregorian", "gregorijanski koledar" }, - { "calendarname.gregory", "gregorijanski koledar" }, - { "field.era", "Doba" }, - { "field.year", "Leto" }, - { "field.month", "Mesec" }, - { "field.week", "Teden" }, - { "field.weekday", "Dan v tednu" }, - { "field.dayperiod", "\u010cas dneva" }, - { "field.hour", "Ura" }, - { "field.minute", "Minuta" }, - { "field.second", "Sekunda" }, - { "field.zone", "Obmo\u010dje" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl_SI.java b/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl_SI.java index 198150a1652..3588c733ee3 100644 --- a/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl_SI.java +++ b/jdk/src/share/classes/sun/text/resources/sl/FormatData_sl_SI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.sl; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sl_SI extends ListResourceBundle { +public class FormatData_sl_SI extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/sl/JavaTimeSupplementary_sl.java b/jdk/src/share/classes/sun/text/resources/sl/JavaTimeSupplementary_sl.java new file mode 100644 index 00000000000..85a09a44b48 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/sl/JavaTimeSupplementary_sl.java @@ -0,0 +1,146 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sl; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sl extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1. \u010detrtletje", + "2. \u010detrtletje", + "3. \u010detrtletje", + "4. \u010detrtletje", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "budisti\u010dni koledar" }, + { "calendarname.gregorian", + "gregorijanski koledar" }, + { "calendarname.gregory", + "gregorijanski koledar" }, + { "calendarname.islamic", + "islamski koledar" }, + { "calendarname.islamic-civil", + "islamski civilni koledar" }, + { "calendarname.islamicc", + "islamski civilni koledar" }, + { "calendarname.japanese", + "japonski koledar" }, + { "calendarname.roc", + "kitajski dr\u017eavni koledar" }, + { "field.dayperiod", + "\u010cas dneva" }, + { "field.era", + "Doba" }, + { "field.hour", + "Ura" }, + { "field.minute", + "Minuta" }, + { "field.month", + "Mesec" }, + { "field.second", + "Sekunda" }, + { "field.week", + "Teden" }, + { "field.weekday", + "Dan v tednu" }, + { "field.year", + "Leto" }, + { "field.zone", + "Obmo\u010dje" }, + { "java.time.long.Eras", + new String[] { + "pred na\u0161im \u0161tetjem", + "na\u0161e \u0161tetje", + } + }, + { "java.time.short.Eras", + new String[] { + "pr.n.\u0161.", + "po Kr.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq.java b/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq.java index 0984bb613b1..a6edf3bd1e0 100644 --- a/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq.java +++ b/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -40,11 +40,11 @@ package sun.text.resources.sq; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sq extends ListResourceBundle { +public class FormatData_sq extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -82,6 +82,23 @@ public class FormatData_sq extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "S", + "M", + "P", + "M", + "Q", + "K", + "G", + "S", + "T", + "N", + "D", + "", + } + }, { "DayNames", new String[] { "e diel", // Sunday diff --git a/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq_AL.java b/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq_AL.java index 58b5532b06b..b86ab7dfc2f 100644 --- a/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq_AL.java +++ b/jdk/src/share/classes/sun/text/resources/sq/FormatData_sq_AL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.sq; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sq_AL extends ListResourceBundle { +public class FormatData_sq_AL extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/sq/JavaTimeSupplementary_sq.java b/jdk/src/share/classes/sun/text/resources/sq/JavaTimeSupplementary_sq.java new file mode 100644 index 00000000000..e5aa49d1a18 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/sq/JavaTimeSupplementary_sq.java @@ -0,0 +1,80 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sq; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sq extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "java.time.short.Eras", + new String[] { + "p.e.r.", + "n.e.r.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr.java b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr.java index 793b00b2609..4d244073517 100644 --- a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr.java +++ b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr.java @@ -40,9 +40,9 @@ package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr extends ListResourceBundle { +public class FormatData_sr extends ParallelListResourceBundle { @Override protected final Object[][] getContents() { final String[] rocEras = { @@ -84,6 +84,40 @@ public class FormatData_sr extends ListResourceBundle { "", } }, + { "MonthNarrows", + new String[] { + "\u0458", + "\u0444", + "\u043c", + "\u0430", + "\u043c", + "\u0458", + "\u0458", + "\u0430", + "\u0441", + "\u043e", + "\u043d", + "\u0434", + "", + } + }, + { "MonthNarrows", + new String[] { + "\u0458", + "\u0444", + "\u043c", + "\u0430", + "\u043c", + "\u0458", + "\u0458", + "\u0430", + "\u0441", + "\u043e", + "\u043d", + "\u0434", + "", + } + }, { "DayNames", new String[] { "\u043d\u0435\u0434\u0435\u0459\u0430", @@ -179,57 +213,6 @@ public class FormatData_sr extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, MMMM d, y G", - "MMMM d, y G", - "MMM d, y G", - "M/d/yy G", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "islamic.MonthNames", - new String[] { - "\u041c\u0443\u0440\u0430\u0445\u0430\u043c", - "\u0421\u0430\u0444\u0430\u0440", - "\u0420\u0430\u0431\u0438\u02bb I", - "\u0420\u0430\u0431\u0438\u02bb II", - "\u0408\u0443\u043c\u0430\u0434\u0430 I", - "\u0408\u0443\u043c\u0430\u0434\u0430 II", - "\u0420\u0430\u0452\u0430\u0431", - "\u0428\u0430\u02bb\u0431\u0430\u043d", - "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", - "\u0428\u0430\u0432\u0430\u043b", - "\u0414\u0443\u02bb\u043b-\u041a\u0438\u02bb\u0434\u0430", - "\u0414\u0443\u02bb\u043b-\u0445\u0438\u0452\u0430", - "", - } - }, - { "islamic.Eras", - new String[] { - "", - "\u0410\u0425", - } - }, - { "calendarname.islamic-civil", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamicc", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamic", "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.japanese", "\u0408\u0430\u043f\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregorian", "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregory", "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.roc", "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0435 \u041a\u0438\u043d\u0435" }, - { "calendarname.buddhist", "\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "field.era", "\u0435\u0440\u0430" }, - { "field.year", "\u0433\u043e\u0434\u0438\u043d\u0430" }, - { "field.month", "\u043c\u0435\u0441\u0435\u0446" }, - { "field.week", "\u043d\u0435\u0434\u0435\u0459\u0430" }, - { "field.weekday", "\u0434\u0430\u043d \u0443 \u043d\u0435\u0434\u0435\u0459\u0438" }, - { "field.dayperiod", "\u043f\u0440\u0435 \u043f\u043e\u0434\u043d\u0435/\u043f\u043e\u043f\u043e\u0434\u043d\u0435" }, - { "field.hour", "\u0447\u0430\u0441" }, - { "field.minute", "\u043c\u0438\u043d\u0443\u0442" }, - { "field.second", "\u0441\u0435\u043a\u0443\u043d\u0434" }, - { "field.zone", "\u0437\u043e\u043d\u0430" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_BA.java b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_BA.java index 71f17b2e1c7..2e28a11f50f 100644 --- a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_BA.java +++ b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_BA.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_BA extends ListResourceBundle { +public class FormatData_sr_BA extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", diff --git a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_CS.java b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_CS.java index bce03dc54d3..dd626ea1c04 100644 --- a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_CS.java +++ b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_CS.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_CS extends ListResourceBundle { +public class FormatData_sr_CS extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { }; diff --git a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn.java b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn.java index 13dd9a326f2..198b911eae9 100644 --- a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn.java +++ b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -61,12 +61,11 @@ * written authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_Latn extends ListResourceBundle { +public class FormatData_sr_Latn extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "MonthNames", @@ -103,6 +102,23 @@ public class FormatData_sr_Latn extends ListResourceBundle { "", } }, + { "MonthNarrows", + new String[] { + "j", + "f", + "m", + "a", + "m", + "j", + "j", + "a", + "s", + "o", + "n", + "d", + "", + } + }, { "DayNames", new String[] { "nedelja", @@ -125,6 +141,17 @@ public class FormatData_sr_Latn extends ListResourceBundle { "sub", } }, + { "DayNarrows", + new String[] { + "n", + "p", + "u", + "s", + "\u010d", + "p", + "s", + } + }, { "Eras", new String[] { "p. n. e.", diff --git a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn_ME.java b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn_ME.java index 732d4e0f6a3..d3a88d24f59 100644 --- a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn_ME.java +++ b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_Latn_ME.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -61,12 +61,11 @@ * written authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_Latn_ME extends ListResourceBundle { +public class FormatData_sr_Latn_ME extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "TimePatterns", diff --git a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_ME.java b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_ME.java index 9806497c746..d3be69705f2 100644 --- a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_ME.java +++ b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_ME.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_ME extends ListResourceBundle { +public class FormatData_sr_ME extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { }; diff --git a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_RS.java b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_RS.java index 346e0ddbe14..332daef69b1 100644 --- a/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_RS.java +++ b/jdk/src/share/classes/sun/text/resources/sr/FormatData_sr_RS.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.sr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sr_RS extends ListResourceBundle { +public class FormatData_sr_RS extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { }; diff --git a/jdk/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr.java b/jdk/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr.java new file mode 100644 index 00000000000..c25a26bab0a --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr.java @@ -0,0 +1,219 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sr; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sr extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "\u041a1", + "\u041a2", + "\u041a3", + "\u041a4", + } + }, + { "QuarterNames", + new String[] { + "\u041f\u0440\u0432\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0414\u0440\u0443\u0433\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0422\u0440\u0435\u045b\u0435 \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + "\u0427\u0435\u0442\u0432\u0440\u0442\u043e \u0442\u0440\u043e\u043c\u0435\u0441\u0435\u0447\u0458\u0435", + } + }, + { "QuarterNarrows", + new String[] { + "1.", + "2.", + "3.", + "4.", + } + }, + { "calendarname.buddhist", + "\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregorian", + "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregory", + "\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic-civil", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamicc", + "\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.japanese", + "\u0408\u0430\u043f\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.roc", + "\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0435 \u041a\u0438\u043d\u0435" }, + { "field.dayperiod", + "\u043f\u0440\u0435 \u043f\u043e\u0434\u043d\u0435/\u043f\u043e\u043f\u043e\u0434\u043d\u0435" }, + { "field.era", + "\u0435\u0440\u0430" }, + { "field.hour", + "\u0447\u0430\u0441" }, + { "field.minute", + "\u043c\u0438\u043d\u0443\u0442" }, + { "field.month", + "\u043c\u0435\u0441\u0435\u0446" }, + { "field.second", + "\u0441\u0435\u043a\u0443\u043d\u0434" }, + { "field.week", + "\u043d\u0435\u0434\u0435\u0459\u0430" }, + { "field.weekday", + "\u0434\u0430\u043d \u0443 \u043d\u0435\u0434\u0435\u0459\u0438" }, + { "field.year", + "\u0433\u043e\u0434\u0438\u043d\u0430" }, + { "field.zone", + "\u0437\u043e\u043d\u0430" }, + { "islamic.Eras", + new String[] { + "", + "\u0410\u0425", + } + }, + { "islamic.MonthNames", + new String[] { + "\u041c\u0443\u0440\u0430\u0445\u0430\u043c", + "\u0421\u0430\u0444\u0430\u0440", + "\u0420\u0430\u0431\u0438\u02bb I", + "\u0420\u0430\u0431\u0438\u02bb II", + "\u0408\u0443\u043c\u0430\u0434\u0430 I", + "\u0408\u0443\u043c\u0430\u0434\u0430 II", + "\u0420\u0430\u0452\u0430\u0431", + "\u0428\u0430\u02bb\u0431\u0430\u043d", + "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", + "\u0428\u0430\u0432\u0430\u043b", + "\u0414\u0443\u02bb\u043b-\u041a\u0438\u02bb\u0434\u0430", + "\u0414\u0443\u02bb\u043b-\u0445\u0438\u0452\u0430", + "", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u0410\u0425", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\u0411\u0415", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, MMMM d, y G", + "MMMM d, y G", + "MMM d, y G", + "M/d/yy G", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u043d. \u0435.", + "\u041c\u0435\u0438\u0452\u0438", + "\u0422\u0430\u0438\u0448\u043e", + "\u0428\u043e\u0432\u0430", + "\u0425\u0430\u0438\u0441\u0435\u0438", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u043d. \u0435.", + "\u041c\u0435\u0438\u0452\u0438", + "\u0422\u0430\u0438\u0448\u043e", + "\u0428\u043e\u0432\u0430", + "\u0425\u0430\u0438\u0441\u0435\u0438", + } + }, + { "java.time.long.Eras", + new String[] { + "\u041f\u0440\u0435 \u043d\u043e\u0432\u0435 \u0435\u0440\u0435", + "\u041d\u043e\u0432\u0435 \u0435\u0440\u0435", + } + }, + { "java.time.short.Eras", + new String[] { + "\u043f. \u043d. \u0435.", + "\u043d. \u0435", + } + }, + { "roc.Eras", + new String[] { + "\u041f\u0440\u0435 \u0420\u041a", + "\u0420\u041a", + } + }, + { "roc.short.Eras", + new String[] { + "\u041f\u0440\u0435 \u0420\u041a", + "\u0420\u041a", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr_Latn.java b/jdk/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr_Latn.java new file mode 100644 index 00000000000..2109447b27e --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/sr/JavaTimeSupplementary_sr_Latn.java @@ -0,0 +1,150 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sr; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sr_Latn extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "1. kvartal", + "2. kvartal", + "3. kvartal", + "4. kvartal", + } + }, + { "calendarname.buddhist", + "Budisti\u010dki kalendar" }, + { "calendarname.gregorian", + "Gregorijanski kalendar" }, + { "calendarname.gregory", + "Gregorijanski kalendar" }, + { "calendarname.islamic", + "Islamski kalendar" }, + { "calendarname.islamic-civil", + "Islamski civilni kalendar" }, + { "calendarname.islamicc", + "Islamski civilni kalendar" }, + { "calendarname.japanese", + "Japanski kalendar" }, + { "calendarname.roc", + "Kalendar Republike Kine" }, + { "field.dayperiod", + "pre podne/ popodne" }, + { "field.era", + "era" }, + { "field.hour", + "\u010das" }, + { "field.minute", + "minut" }, + { "field.month", + "mesec" }, + { "field.second", + "sekund" }, + { "field.week", + "nedelja" }, + { "field.weekday", + "dan u nedelji" }, + { "field.year", + "godina" }, + { "field.zone", + "zona" }, + { "java.time.long.Eras", + new String[] { + "Pre nove ere", + "Nove ere", + } + }, + { "java.time.short.Eras", + new String[] { + "p. n. e.", + "n. e", + } + }, + { "roc.Eras", + new String[] { + "Pre RK", + "RK", + } + }, + { "roc.short.Eras", + new String[] { + "Pre RK", + "RK", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv.java b/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv.java index b7ee4e78d57..8f7296bcee2 100644 --- a/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv.java +++ b/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv.java @@ -76,11 +76,11 @@ package sun.text.resources.sv; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sv extends ListResourceBundle { +public class FormatData_sv extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -106,6 +106,23 @@ public class FormatData_sv extends ListResourceBundle { "" // month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "J", + "F", + "M", + "A", + "M", + "J", + "J", + "A", + "S", + "O", + "N", + "D", + "", + } + }, { "MonthAbbreviations", new String[] { "jan", // abb january @@ -123,6 +140,23 @@ public class FormatData_sv extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "jan", + "feb", + "mar", + "apr", + "maj", + "jun", + "jul", + "aug", + "sep", + "okt", + "nov", + "dec", + "", + } + }, { "standalone.MonthNarrows", new String[] { "J", @@ -162,6 +196,17 @@ public class FormatData_sv extends ListResourceBundle { "l\u00f6" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "s\u00f6n", + "m\u00e5n", + "tis", + "ons", + "tor", + "fre", + "l\u00f6r", + } + }, { "DayNarrows", new String[] { "S", @@ -173,6 +218,17 @@ public class FormatData_sv extends ListResourceBundle { "L", } }, + { "standalone.DayNames", + new String[] { + "s\u00f6ndag", + "m\u00e5ndag", + "tisdag", + "onsdag", + "torsdag", + "fredag", + "l\u00f6rdag", + } + }, { "standalone.DayNarrows", new String[] { "S", @@ -184,6 +240,18 @@ public class FormatData_sv extends ListResourceBundle { "L", } }, + { "Eras", + new String[] { + "f\u00f6re Kristus", + "efter Kristus", + } + }, + { "short.Eras", + new String[] { + "f.Kr.", + "e.Kr.", + } + }, { "narrow.Eras", new String[] { "f.Kr.", @@ -239,74 +307,6 @@ public class FormatData_sv extends ListResourceBundle { } }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "G yyyy-MM-dd", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "G y-MM-dd", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "G y-MM-dd", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM y GGGG", - "GGGG y-MM-dd", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE d MMMM y G", - "d MMMM y G", - "d MMM y G", - "G y-MM-dd", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE d MMMM y GGGG", - "d MMMM y GGGG", - "d MMM y GGGG", - "GGGG y-MM-dd", - } - }, - { "calendarname.islamic-civil", "islamisk civil kalender" }, - { "calendarname.islamicc", "islamisk civil kalender" }, - { "calendarname.islamic", "islamisk kalender" }, - { "calendarname.japanese", "japansk kalender" }, - { "calendarname.gregorian", "gregoriansk kalender" }, - { "calendarname.gregory", "gregoriansk kalender" }, - { "calendarname.roc", "kinesiska republikens kalender" }, - { "calendarname.buddhist", "buddistisk kalender" }, - { "field.era", "era" }, - { "field.year", "\u00e5r" }, - { "field.month", "m\u00e5nad" }, - { "field.week", "vecka" }, - { "field.weekday", "veckodag" }, - { "field.dayperiod", "fm/em" }, - { "field.hour", "timme" }, - { "field.minute", "minut" }, - { "field.second", "sekund" }, - { "field.zone", "tidszon" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv_SE.java b/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv_SE.java index f7100c5daa3..a9a7881a607 100644 --- a/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv_SE.java +++ b/jdk/src/share/classes/sun/text/resources/sv/FormatData_sv_SE.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.sv; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_sv_SE extends ListResourceBundle { +public class FormatData_sv_SE extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/sv/JavaTimeSupplementary_sv.java b/jdk/src/share/classes/sun/text/resources/sv/JavaTimeSupplementary_sv.java new file mode 100644 index 00000000000..f54fbceaadd --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/sv/JavaTimeSupplementary_sv.java @@ -0,0 +1,215 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.sv; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_sv extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "K1", + "K2", + "K3", + "K4", + } + }, + { "QuarterNames", + new String[] { + "1:a kvartalet", + "2:a kvartalet", + "3:e kvartalet", + "4:e kvartalet", + } + }, + { "calendarname.buddhist", + "buddistisk kalender" }, + { "calendarname.gregorian", + "gregoriansk kalender" }, + { "calendarname.gregory", + "gregoriansk kalender" }, + { "calendarname.islamic", + "islamisk kalender" }, + { "calendarname.islamic-civil", + "islamisk civil kalender" }, + { "calendarname.islamicc", + "islamisk civil kalender" }, + { "calendarname.japanese", + "japansk kalender" }, + { "calendarname.roc", + "kinesiska republikens kalender" }, + { "field.dayperiod", + "fm/em" }, + { "field.era", + "era" }, + { "field.hour", + "timme" }, + { "field.minute", + "minut" }, + { "field.month", + "m\u00e5nad" }, + { "field.second", + "sekund" }, + { "field.week", + "vecka" }, + { "field.weekday", + "veckodag" }, + { "field.year", + "\u00e5r" }, + { "field.zone", + "tidszon" }, + { "islamic.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "GGGG y-MM-dd", + } + }, + { "islamic.MonthNames", + new String[] { + "muharram", + "safar", + "rabi\u2019 al-awwal", + "rabi\u2019 al-akhir", + "jumada-l-ula", + "jumada-l-akhira", + "rajab", + "sha\u2019ban", + "ramadan", + "shawwal", + "dhu-l-ga\u2019da", + "dhu-l-hijja", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "G yyyy-MM-dd", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "G y-MM-dd", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "G y-MM-dd", + } + }, + { "java.time.long.Eras", + new String[] { + "f\u00f6re Kristus", + "efter Kristus", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE d MMMM y G", + "d MMMM y G", + "d MMM y G", + "G y-MM-dd", + } + }, + { "java.time.short.Eras", + new String[] { + "f\u00f6re Kristus", + "efter Kristus", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE d MMMM y GGGG", + "d MMMM y GGGG", + "d MMM y GGGG", + "GGGG y-MM-dd", + } + }, + { "roc.Eras", + new String[] { + "f\u00f6re R.K.", + "R.K.", + } + }, + { "roc.short.Eras", + new String[] { + "f\u00f6re R.K.", + "R.K.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/th/FormatData_th.java b/jdk/src/share/classes/sun/text/resources/th/FormatData_th.java index aa6bd7fa10a..15c679a0d98 100644 --- a/jdk/src/share/classes/sun/text/resources/th/FormatData_th.java +++ b/jdk/src/share/classes/sun/text/resources/th/FormatData_th.java @@ -76,11 +76,11 @@ package sun.text.resources.th; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_th extends ListResourceBundle { +public class FormatData_th extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { String[] timePatterns = new String[] { @@ -135,6 +135,23 @@ public class FormatData_th extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u0e21.\u0e04.", + "\u0e01.\u0e1e.", + "\u0e21\u0e35.\u0e04.", + "\u0e40\u0e21.\u0e22.", + "\u0e1e.\u0e04.", + "\u0e21\u0e34.\u0e22", + "\u0e01.\u0e04.", + "\u0e2a.\u0e04.", + "\u0e01.\u0e22.", + "\u0e15.\u0e04.", + "\u0e1e.\u0e22.", + "\u0e18.\u0e04.", + "", + } + }, { "standalone.MonthNarrows", new String[] { "\u0e21.\u0e04.", @@ -209,23 +226,39 @@ public class FormatData_th extends ListResourceBundle { "\u0e04.\u0e28." } }, + { "short.Eras", + new String[] { + "\u0e01\u0e48\u0e2d\u0e19 \u0e04.\u0e28.", + "\u0e04.\u0e28.", + } + }, { "narrow.Eras", new String[] { "\u0e01\u0e48\u0e2d\u0e19 \u0e04.\u0e28.", "\u0e04.\u0e28.", } }, + { "japanese.Eras", + new String[] { + "\u0e04.\u0e28.", + "\u0e40\u0e21\u0e08\u0e34", + "\u0e17\u0e30\u0e2d\u0e34\u0e42\u0e0a", + "\u0e42\u0e0a\u0e27\u0e30", + "\u0e40\u0e2e\u0e40\u0e0b", + } + }, + { "japanese.short.Eras", + new String[] { + "\u0e04.\u0e28.", + "\u0e21", + "\u0e17", + "\u0e0a", + "\u0e2e", + } + }, { "buddhist.TimePatterns", timePatterns }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE\u0e17\u0e35\u0e48 d MMMM G y", - "d MMMM y", - "d MMM y", - "d/M/yyyy", - } - }, { "buddhist.DatePatterns", datePatterns }, @@ -242,77 +275,6 @@ public class FormatData_th extends ListResourceBundle { dateTimePatterns }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35G\u0e17\u0e35\u0e48 y", - "d MMMM \u0e1b\u0e35G y", - "d MMM G y", - "d/M/yy", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35G\u0e17\u0e35\u0e48 y", - "d MMMM \u0e1b\u0e35G y", - "d MMM G y", - "d/M/yy", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35GGGG\u0e17\u0e35\u0e48 y", - "d MMMM \u0e1b\u0e35GGGG y", - "d MMM GGGG y", - "d/M/yy", - } - }, - { "islamic.MonthNames", - new String[] { - "\u0e21\u0e38\u0e2e\u0e30\u0e23\u0e4c\u0e23\u0e2d\u0e21", - "\u0e0b\u0e2d\u0e1f\u0e32\u0e23\u0e4c", - "\u0e23\u0e2d\u0e1a\u0e35 I", - "\u0e23\u0e2d\u0e1a\u0e35 II", - "\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 I", - "\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 II", - "\u0e23\u0e2d\u0e08\u0e31\u0e1a", - "\u0e0a\u0e30\u0e2d\u0e30\u0e1a\u0e32\u0e19", - "\u0e23\u0e2d\u0e21\u0e30\u0e14\u0e2d\u0e19", - "\u0e40\u0e0a\u0e32\u0e27\u0e31\u0e25", - "\u0e14\u0e2e\u0e38\u0e38\u0e2d\u0e31\u0e25\u0e01\u0e34\u0e14\u0e30\u0e2b\u0e4c", - "\u0e14\u0e2e\u0e38\u0e2d\u0e31\u0e25\u0e2e\u0e34\u0e08\u0e08\u0e30\u0e2b\u0e4c", - "", - } - }, - { "islamic.long.Eras", - new String[] { - "", - "\u0e2e\u0e34\u0e08\u0e40\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a", - } - }, - { "islamic.Eras", - new String[] { - "", - "\u0e2e.\u0e28.", - } - }, - { "calendarname.islamic-civil", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25" }, - { "calendarname.islamicc", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25" }, - { "calendarname.islamic", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21" }, - { "calendarname.japanese", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e0d\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e19" }, - { "calendarname.gregorian", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19" }, - { "calendarname.gregory", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19" }, - { "calendarname.roc", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e44\u0e15\u0e49\u0e2b\u0e27\u0e31\u0e19" }, - { "calendarname.buddhist", "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e1e\u0e38\u0e17\u0e18" }, - { "field.era", "\u0e2a\u0e21\u0e31\u0e22" }, - { "field.year", "\u0e1b\u0e35" }, - { "field.month", "\u0e40\u0e14\u0e37\u0e2d\u0e19" }, - { "field.week", "\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c" }, - { "field.weekday", "\u0e27\u0e31\u0e19\u0e43\u0e19\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c" }, - { "field.dayperiod", "\u0e0a\u0e48\u0e27\u0e07\u0e27\u0e31\u0e19" }, - { "field.hour", "\u0e0a\u0e31\u0e48\u0e27\u0e42\u0e21\u0e07" }, - { "field.minute", "\u0e19\u0e32\u0e17\u0e35" }, - { "field.second", "\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35" }, - { "field.zone", "\u0e40\u0e02\u0e15" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/th/FormatData_th_TH.java b/jdk/src/share/classes/sun/text/resources/th/FormatData_th_TH.java index c2a095081d2..f41df1f7ecd 100644 --- a/jdk/src/share/classes/sun/text/resources/th/FormatData_th_TH.java +++ b/jdk/src/share/classes/sun/text/resources/th/FormatData_th_TH.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.th; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_th_TH extends ListResourceBundle { +public class FormatData_th_TH extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/th/JavaTimeSupplementary_th.java b/jdk/src/share/classes/sun/text/resources/th/JavaTimeSupplementary_th.java new file mode 100644 index 00000000000..b0f4bbcae7c --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/th/JavaTimeSupplementary_th.java @@ -0,0 +1,243 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.th; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_th extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "\u0e44\u0e15\u0e23\u0e21\u0e32\u0e2a 1", + "\u0e44\u0e15\u0e23\u0e21\u0e32\u0e2a 2", + "\u0e44\u0e15\u0e23\u0e21\u0e32\u0e2a 3", + "\u0e44\u0e15\u0e23\u0e21\u0e32\u0e2a 4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e1e\u0e38\u0e17\u0e18" }, + { "calendarname.gregorian", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19" }, + { "calendarname.gregory", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19" }, + { "calendarname.islamic", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21" }, + { "calendarname.islamic-civil", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25" }, + { "calendarname.islamicc", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25" }, + { "calendarname.japanese", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e0d\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e19" }, + { "calendarname.roc", + "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e44\u0e15\u0e49\u0e2b\u0e27\u0e31\u0e19" }, + { "field.dayperiod", + "\u0e0a\u0e48\u0e27\u0e07\u0e27\u0e31\u0e19" }, + { "field.era", + "\u0e2a\u0e21\u0e31\u0e22" }, + { "field.hour", + "\u0e0a\u0e31\u0e48\u0e27\u0e42\u0e21\u0e07" }, + { "field.minute", + "\u0e19\u0e32\u0e17\u0e35" }, + { "field.month", + "\u0e40\u0e14\u0e37\u0e2d\u0e19" }, + { "field.second", + "\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35" }, + { "field.week", + "\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c" }, + { "field.weekday", + "\u0e27\u0e31\u0e19\u0e43\u0e19\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c" }, + { "field.year", + "\u0e1b\u0e35" }, + { "field.zone", + "\u0e40\u0e02\u0e15" }, + { "islamic.Eras", + new String[] { + "", + "\u0e2e.\u0e28.", + } + }, + { "islamic.MonthNames", + new String[] { + "\u0e21\u0e38\u0e2e\u0e30\u0e23\u0e4c\u0e23\u0e2d\u0e21", + "\u0e0b\u0e2d\u0e1f\u0e32\u0e23\u0e4c", + "\u0e23\u0e2d\u0e1a\u0e35 I", + "\u0e23\u0e2d\u0e1a\u0e35 II", + "\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 I", + "\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 II", + "\u0e23\u0e2d\u0e08\u0e31\u0e1a", + "\u0e0a\u0e30\u0e2d\u0e30\u0e1a\u0e32\u0e19", + "\u0e23\u0e2d\u0e21\u0e30\u0e14\u0e2d\u0e19", + "\u0e40\u0e0a\u0e32\u0e27\u0e31\u0e25", + "\u0e14\u0e2e\u0e38\u0e38\u0e2d\u0e31\u0e25\u0e01\u0e34\u0e14\u0e30\u0e2b\u0e4c", + "\u0e14\u0e2e\u0e38\u0e2d\u0e31\u0e25\u0e2e\u0e34\u0e08\u0e08\u0e30\u0e2b\u0e4c", + "", + } + }, + { "islamic.long.Eras", + new String[] { + "", + "\u0e2e\u0e34\u0e08\u0e40\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u0e2e.\u0e28.", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE\u0e17\u0e35\u0e48 d MMMM G y", + "d MMMM y", + "d MMM y", + "d/M/yyyy", + } + }, + { "java.time.buddhist.long.Eras", + new String[] { + "BC", + "\u0e1e\u0e38\u0e17\u0e18\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "\u0e1b\u0e35\u0e01\u0e48\u0e2d\u0e19\u0e04\u0e23\u0e34\u0e2a\u0e15\u0e4c\u0e01\u0e32\u0e25\u0e17\u0e35\u0e48", + "\u0e1e.\u0e28.", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35G\u0e17\u0e35\u0e48 y", + "d MMMM \u0e1b\u0e35G y", + "d MMM G y", + "d/M/yy", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u0e04.\u0e28.", + "\u0e40\u0e21\u0e08\u0e34", + "\u0e17\u0e30\u0e2d\u0e34\u0e42\u0e0a", + "\u0e42\u0e0a\u0e27\u0e30", + "\u0e40\u0e2e\u0e40\u0e0b", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u0e04.\u0e28.", + "\u0e40\u0e21\u0e08\u0e34", + "\u0e17\u0e30\u0e2d\u0e34\u0e42\u0e0a", + "\u0e42\u0e0a\u0e27\u0e30", + "\u0e40\u0e2e\u0e40\u0e0b", + } + }, + { "java.time.long.Eras", + new String[] { + "\u0e1b\u0e35\u0e01\u0e48\u0e2d\u0e19\u0e04\u0e23\u0e34\u0e2a\u0e15\u0e4c\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a", + "\u0e04\u0e23\u0e34\u0e2a\u0e15\u0e4c\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35G\u0e17\u0e35\u0e48 y", + "d MMMM \u0e1b\u0e35G y", + "d MMM G y", + "d/M/yy", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0e1b\u0e35\u0e01\u0e48\u0e2d\u0e19\u0e04\u0e23\u0e34\u0e2a\u0e15\u0e4c\u0e01\u0e32\u0e25\u0e17\u0e35\u0e48", + "\u0e04.\u0e28.", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35GGGG\u0e17\u0e35\u0e48 y", + "d MMMM \u0e1b\u0e35GGGG y", + "d MMM GGGG y", + "d/M/yy", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr.java b/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr.java index c8fc0f540e9..8f37c6058bd 100644 --- a/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr.java +++ b/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr.java @@ -76,11 +76,11 @@ package sun.text.resources.tr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_tr extends ListResourceBundle { +public class FormatData_tr extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -101,6 +101,23 @@ public class FormatData_tr extends ListResourceBundle { "" // month 13 if applicable } }, + { "standalone.MonthNames", + new String[] { + "Ocak", + "\u015eubat", + "Mart", + "Nisan", + "May\u0131s", + "Haziran", + "Temmuz", + "A\u011fustos", + "Eyl\u00fcl", + "Ekim", + "Kas\u0131m", + "Aral\u0131k", + "", + } + }, { "MonthAbbreviations", new String[] { "Oca", // abb january @@ -118,6 +135,40 @@ public class FormatData_tr extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "Oca", + "\u015eub", + "Mar", + "Nis", + "May", + "Haz", + "Tem", + "A\u011fu", + "Eyl", + "Eki", + "Kas", + "Ara", + "", + } + }, + { "MonthNarrows", + new String[] { + "O", + "\u015e", + "M", + "N", + "M", + "H", + "T", + "A", + "E", + "E", + "K", + "A", + "", + } + }, { "standalone.MonthNarrows", new String[] { "O", @@ -146,6 +197,17 @@ public class FormatData_tr extends ListResourceBundle { "Cumartesi" // Saturday } }, + { "standalone.DayNames", + new String[] { + "Pazar", + "Pazartesi", + "Sal\u0131", + "\u00c7ar\u015famba", + "Per\u015fembe", + "Cuma", + "Cumartesi", + } + }, { "DayAbbreviations", new String[] { "Paz", // abb Sunday @@ -157,6 +219,17 @@ public class FormatData_tr extends ListResourceBundle { "Cmt" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "Paz", + "Pzt", + "Sal", + "\u00c7ar", + "Per", + "Cum", + "Cmt", + } + }, { "DayNarrows", new String[] { "P", @@ -168,6 +241,29 @@ public class FormatData_tr extends ListResourceBundle { "C", } }, + { "standalone.DayNarrows", + new String[] { + "P", + "P", + "S", + "\u00c7", + "P", + "C", + "C", + } + }, + { "long.Eras", + new String[] { + "Milattan \u00d6nce", + "Milattan Sonra", + } + }, + { "Eras", + new String[] { + "M\u00d6", + "MS", + } + }, { "NumberPatterns", new String[] { "#,##0.###;-#,##0.###", // decimal pattern @@ -212,89 +308,6 @@ public class FormatData_tr extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "dd MMMM y G EEEE", - "dd MMMM y G", - "dd MMM y G", - "dd.MM.yyyy G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "dd MMMM y G EEEE", - "dd MMMM y G", - "dd MMM y G", - "dd.MM.yyyy G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "dd MMMM y G EEEE", - "dd MMMM y G", - "dd MMM y G", - "dd.MM.yyyy G", - } - }, - { "roc.DatePatterns", - new String[] { - "dd MMMM y GGGG EEEE", - "dd MMMM y GGGG", - "dd MMM y GGGG", - "dd.MM.yyyy GGGG", - } - }, - { "islamic.MonthNames", - new String[] { - "Muharrem", - "Safer", - "Rebi\u00fclevvel", - "Rebi\u00fclahir", - "Cemaziyelevvel", - "Cemaziyelahir", - "Recep", - "\u015eaban", - "Ramazan", - "\u015eevval", - "Zilkade", - "Zilhicce", - "", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "dd MMMM y G EEEE", - "dd MMMM y G", - "dd MMM y G", - "dd.MM.yyyy G", - } - }, - { "islamic.DatePatterns", - new String[] { - "dd MMMM y GGGG EEEE", - "dd MMMM y GGGG", - "dd MMM y GGGG", - "dd.MM.yyyy GGGG", - } - }, - { "calendarname.islamic-civil", "Arap Takvimi" }, - { "calendarname.islamicc", "Arap Takvimi" }, - { "calendarname.islamic", "Hicri Takvim" }, - { "calendarname.japanese", "Japon Takvimi" }, - { "calendarname.gregorian", "Miladi Takvim" }, - { "calendarname.gregory", "Miladi Takvim" }, - { "calendarname.roc", "\u00c7in Cumhuriyeti Takvimi" }, - { "calendarname.buddhist", "Budist Takvimi" }, - { "field.era", "Miladi D\u00f6nem" }, - { "field.year", "Y\u0131l" }, - { "field.month", "Ay" }, - { "field.week", "Hafta" }, - { "field.weekday", "Haftan\u0131n G\u00fcn\u00fc" }, - { "field.dayperiod", "AM/PM" }, - { "field.hour", "Saat" }, - { "field.minute", "Dakika" }, - { "field.second", "Saniye" }, - { "field.zone", "Saat Dilimi" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr_TR.java b/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr_TR.java index 3e4c35160ea..7cff320324b 100644 --- a/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr_TR.java +++ b/jdk/src/share/classes/sun/text/resources/tr/FormatData_tr_TR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.tr; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_tr_TR extends ListResourceBundle { +public class FormatData_tr_TR extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/tr/JavaTimeSupplementary_tr.java b/jdk/src/share/classes/sun/text/resources/tr/JavaTimeSupplementary_tr.java new file mode 100644 index 00000000000..a26961f8f11 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/tr/JavaTimeSupplementary_tr.java @@ -0,0 +1,211 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.tr; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_tr extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "\u00c71", + "\u00c72", + "\u00c73", + "\u00c74", + } + }, + { "QuarterNames", + new String[] { + "1. \u00e7eyrek", + "2. \u00e7eyrek", + "3. \u00e7eyrek", + "4. \u00e7eyrek", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "Budist Takvimi" }, + { "calendarname.gregorian", + "Miladi Takvim" }, + { "calendarname.gregory", + "Miladi Takvim" }, + { "calendarname.islamic", + "Hicri Takvim" }, + { "calendarname.islamic-civil", + "Arap Takvimi" }, + { "calendarname.islamicc", + "Arap Takvimi" }, + { "calendarname.japanese", + "Japon Takvimi" }, + { "calendarname.roc", + "\u00c7in Cumhuriyeti Takvimi" }, + { "field.dayperiod", + "AM/PM" }, + { "field.era", + "Miladi D\u00f6nem" }, + { "field.hour", + "Saat" }, + { "field.minute", + "Dakika" }, + { "field.month", + "Ay" }, + { "field.second", + "Saniye" }, + { "field.week", + "Hafta" }, + { "field.weekday", + "Haftan\u0131n G\u00fcn\u00fc" }, + { "field.year", + "Y\u0131l" }, + { "field.zone", + "Saat Dilimi" }, + { "islamic.DatePatterns", + new String[] { + "dd MMMM y GGGG EEEE", + "dd MMMM y GGGG", + "dd MMM y GGGG", + "dd.MM.yyyy GGGG", + } + }, + { "islamic.MonthNames", + new String[] { + "Muharrem", + "Safer", + "Rebi\u00fclevvel", + "Rebi\u00fclahir", + "Cemaziyelevvel", + "Cemaziyelahir", + "Recep", + "\u015eaban", + "Ramazan", + "\u015eevval", + "Zilkade", + "Zilhicce", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "dd MMMM y G EEEE", + "dd MMMM y G", + "dd MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "dd MMMM y G EEEE", + "dd MMMM y G", + "dd MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "dd MMMM y G EEEE", + "dd MMMM y G", + "dd MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.long.Eras", + new String[] { + "Milattan \u00d6nce", + "Milattan Sonra", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "dd MMMM y G EEEE", + "dd MMMM y G", + "dd MMM y G", + "dd.MM.yyyy G", + } + }, + { "java.time.short.Eras", + new String[] { + "M\u00d6", + "MS", + } + }, + { "roc.DatePatterns", + new String[] { + "dd MMMM y GGGG EEEE", + "dd MMMM y GGGG", + "dd MMM y GGGG", + "dd.MM.yyyy GGGG", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk.java b/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk.java index 1d896f6dad4..6054f22fdf6 100644 --- a/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk.java +++ b/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk.java @@ -76,11 +76,11 @@ package sun.text.resources.uk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_uk extends ListResourceBundle { +public class FormatData_uk extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -152,6 +152,23 @@ public class FormatData_uk extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "\u0421", + "\u041b", + "\u0411", + "\u041a", + "\u0422", + "\u0427", + "\u041b", + "\u0421", + "\u0412", + "\u0416", + "\u041b", + "\u0413", + "", + } + }, { "DayNames", new String[] { "\u043d\u0435\u0434\u0456\u043b\u044f", // Sunday @@ -228,41 +245,6 @@ public class FormatData_uk extends ListResourceBundle { } }, { "DateTimePatternChars", "GanjkHmsSEDFwWxhKzZ" }, - { "islamic.MonthNames", - new String[] { - "\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c", - "\u0421\u0430\u0444\u0430\u0440", - "\u0420\u0430\u0431\u0456 I", - "\u0420\u0430\u0431\u0456 II", - "\u0414\u0436\u0443\u043c\u0430\u0434\u0430 I", - "\u0414\u0436\u0443\u043c\u0430\u0434\u0430 II", - "\u0420\u0430\u0434\u0436\u0430\u0431", - "\u0428\u0430\u0430\u0431\u0430\u043d", - "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", - "\u0414\u0430\u0432\u0432\u0430\u043b", - "\u0417\u0443-\u043b\u044c-\u043a\u0430\u0430\u0434\u0430", - "\u0417\u0443-\u043b\u044c-\u0445\u0456\u0434\u0436\u0430", - "", - } - }, - { "calendarname.islamic-civil", "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamicc", "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.islamic", "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.japanese", "\u042f\u043f\u043e\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregorian", "\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.gregory", "\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "calendarname.roc", "\u041a\u0438\u0442\u0430\u0439\u0441\u044c\u043a\u0438\u0439 \u0433\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439" }, - { "calendarname.buddhist", "\u0411\u0443\u0434\u0434\u0456\u0439\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, - { "field.era", "\u0415\u0440\u0430" }, - { "field.year", "\u0420\u0456\u043a" }, - { "field.month", "\u041c\u0456\u0441\u044f\u0446\u044c" }, - { "field.week", "\u0422\u0438\u0436\u0434\u0435\u043d\u044c" }, - { "field.weekday", "\u0414\u0435\u043d\u044c \u0442\u0438\u0436\u043d\u044f" }, - { "field.dayperiod", "\u0427\u0430\u0441\u0442\u0438\u043d\u0430 \u0434\u043e\u0431\u0438" }, - { "field.hour", "\u0413\u043e\u0434\u0438\u043d\u0430" }, - { "field.minute", "\u0425\u0432\u0438\u043b\u0438\u043d\u0430" }, - { "field.second", "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, - { "field.zone", "\u0417\u043e\u043d\u0430" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk_UA.java b/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk_UA.java index 2b48731f8fe..b04732e6a91 100644 --- a/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk_UA.java +++ b/jdk/src/share/classes/sun/text/resources/uk/FormatData_uk_UA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.uk; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_uk_UA extends ListResourceBundle { +public class FormatData_uk_UA extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/uk/JavaTimeSupplementary_uk.java b/jdk/src/share/classes/sun/text/resources/uk/JavaTimeSupplementary_uk.java new file mode 100644 index 00000000000..7a239203ec2 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/uk/JavaTimeSupplementary_uk.java @@ -0,0 +1,163 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.uk; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_uk extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "I \u043a\u0432.", + "II \u043a\u0432.", + "III \u043a\u0432.", + "IV \u043a\u0432.", + } + }, + { "QuarterNames", + new String[] { + "I \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "II \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "III \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + "IV \u043a\u0432\u0430\u0440\u0442\u0430\u043b", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u0411\u0443\u0434\u0434\u0456\u0439\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregorian", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.gregory", + "\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic", + "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamic-civil", + "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.islamicc", + "\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.japanese", + "\u042f\u043f\u043e\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440" }, + { "calendarname.roc", + "\u041a\u0438\u0442\u0430\u0439\u0441\u044c\u043a\u0438\u0439 \u0433\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439" }, + { "field.dayperiod", + "\u0427\u0430\u0441\u0442\u0438\u043d\u0430 \u0434\u043e\u0431\u0438" }, + { "field.era", + "\u0415\u0440\u0430" }, + { "field.hour", + "\u0413\u043e\u0434\u0438\u043d\u0430" }, + { "field.minute", + "\u0425\u0432\u0438\u043b\u0438\u043d\u0430" }, + { "field.month", + "\u041c\u0456\u0441\u044f\u0446\u044c" }, + { "field.second", + "\u0421\u0435\u043a\u0443\u043d\u0434\u0430" }, + { "field.week", + "\u0422\u0438\u0436\u0434\u0435\u043d\u044c" }, + { "field.weekday", + "\u0414\u0435\u043d\u044c \u0442\u0438\u0436\u043d\u044f" }, + { "field.year", + "\u0420\u0456\u043a" }, + { "field.zone", + "\u0417\u043e\u043d\u0430" }, + { "islamic.MonthNames", + new String[] { + "\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c", + "\u0421\u0430\u0444\u0430\u0440", + "\u0420\u0430\u0431\u0456 I", + "\u0420\u0430\u0431\u0456 II", + "\u0414\u0436\u0443\u043c\u0430\u0434\u0430 I", + "\u0414\u0436\u0443\u043c\u0430\u0434\u0430 II", + "\u0420\u0430\u0434\u0436\u0430\u0431", + "\u0428\u0430\u0430\u0431\u0430\u043d", + "\u0420\u0430\u043c\u0430\u0434\u0430\u043d", + "\u0414\u0430\u0432\u0432\u0430\u043b", + "\u0417\u0443-\u043b\u044c-\u043a\u0430\u0430\u0434\u0430", + "\u0417\u0443-\u043b\u044c-\u0445\u0456\u0434\u0436\u0430", + "", + } + }, + { "java.time.long.Eras", + new String[] { + "\u0434\u043e \u043d\u0430\u0448\u043e\u0457 \u0435\u0440\u0438", + "\u043d\u0430\u0448\u043e\u0457 \u0435\u0440\u0438", + } + }, + { "java.time.short.Eras", + new String[] { + "\u0434\u043e \u043d.\u0435.", + "\u043f\u0456\u0441\u043b\u044f \u043d.\u0435.", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi.java b/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi.java index c0d1f2dd250..55c5e3ebc75 100644 --- a/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi.java +++ b/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi.java @@ -78,11 +78,11 @@ package sun.text.resources.vi; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_vi extends ListResourceBundle { +public class FormatData_vi extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { @@ -120,6 +120,23 @@ public class FormatData_vi extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, { "DayNames", new String[] { "Ch\u1ee7 nh\u1eadt", // Sunday @@ -153,6 +170,17 @@ public class FormatData_vi extends ListResourceBundle { "T7", } }, + { "standalone.DayNarrows", + new String[] { + "CN", + "T2", + "T3", + "T4", + "T5", + "T6", + "T7", + } + }, { "AmPmMarkers", new String[] { "SA", // am marker @@ -201,72 +229,6 @@ public class FormatData_vi extends ListResourceBundle { "{0} {1}" // date-time pattern } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", - "dd-MM-yyyy G", - "dd/MM/yyyy G", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", - "dd-MM-y G", - "dd/MM/y G", - } - }, - { "cldr.roc.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", - "dd-MM-y G", - "dd/MM/y G", - } - }, - { "roc.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG", - "dd-MM-y GGGG", - "dd/MM/y GGGG", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", - "dd-MM-y G", - "dd/MM/y G", - } - }, - { "islamic.DatePatterns", - new String[] { - "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG", - "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG", - "dd-MM-y GGGG", - "dd/MM/y GGGG", - } - }, - { "calendarname.islamic-civil", "L\u1ecbch Islamic-Civil" }, - { "calendarname.islamicc", "L\u1ecbch Islamic-Civil" }, - { "calendarname.islamic", "L\u1ecbch Islamic" }, - { "calendarname.buddhist", "L\u1ecbch Ph\u1eadt Gi\u00e1o" }, - { "calendarname.japanese", "L\u1ecbch Nh\u1eadt B\u1ea3n" }, - { "calendarname.roc", "L\u1ecbch Trung Hoa D\u00e2n Qu\u1ed1c" }, - { "calendarname.gregorian", "L\u1ecbch Gregory" }, - { "calendarname.gregory", "L\u1ecbch Gregory" }, - { "field.era", "Th\u1eddi \u0111\u1ea1i" }, - { "field.year", "N\u0103m" }, - { "field.month", "Th\u00e1ng" }, - { "field.week", "Tu\u1ea7n" }, - { "field.weekday", "Ng\u00e0y trong tu\u1ea7n" }, - { "field.dayperiod", "SA/CH" }, - { "field.hour", "Gi\u1edd" }, - { "field.minute", "Ph\u00fat" }, - { "field.second", "Gi\u00e2y" }, - { "field.zone", "M\u00fai gi\u1edd" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi_VN.java b/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi_VN.java index 5667c8b9d17..0255674eede 100644 --- a/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi_VN.java +++ b/jdk/src/share/classes/sun/text/resources/vi/FormatData_vi_VN.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -42,11 +42,11 @@ package sun.text.resources.vi; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_vi_VN extends ListResourceBundle { +public class FormatData_vi_VN extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/vi/JavaTimeSupplementary_vi.java b/jdk/src/share/classes/sun/text/resources/vi/JavaTimeSupplementary_vi.java new file mode 100644 index 00000000000..ef8294ce309 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/vi/JavaTimeSupplementary_vi.java @@ -0,0 +1,200 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.vi; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_vi extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "Q1", + "Q2", + "Q3", + "Q4", + } + }, + { "QuarterNames", + new String[] { + "Qu\u00fd 1", + "Qu\u00fd 2", + "Qu\u00fd 3", + "Qu\u00fd 4", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "L\u1ecbch Ph\u1eadt Gi\u00e1o" }, + { "calendarname.gregorian", + "L\u1ecbch Gregory" }, + { "calendarname.gregory", + "L\u1ecbch Gregory" }, + { "calendarname.islamic", + "L\u1ecbch Islamic" }, + { "calendarname.islamic-civil", + "L\u1ecbch Islamic-Civil" }, + { "calendarname.islamicc", + "L\u1ecbch Islamic-Civil" }, + { "calendarname.japanese", + "L\u1ecbch Nh\u1eadt B\u1ea3n" }, + { "calendarname.roc", + "L\u1ecbch Trung Hoa D\u00e2n Qu\u1ed1c" }, + { "field.dayperiod", + "SA/CH" }, + { "field.era", + "Th\u1eddi \u0111\u1ea1i" }, + { "field.hour", + "Gi\u1edd" }, + { "field.minute", + "Ph\u00fat" }, + { "field.month", + "Th\u00e1ng" }, + { "field.second", + "Gi\u00e2y" }, + { "field.week", + "Tu\u1ea7n" }, + { "field.weekday", + "Ng\u00e0y trong tu\u1ea7n" }, + { "field.year", + "N\u0103m" }, + { "field.zone", + "M\u00fai gi\u1edd" }, + { "islamic.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG", + "dd-MM-y GGGG", + "dd/MM/y GGGG", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", + "dd-MM-yyyy G", + "dd/MM/yyyy G", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", + "dd-MM-y G", + "dd/MM/y G", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", + "dd-MM-y G", + "dd/MM/y G", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y G", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y G", + "dd-MM-y G", + "dd/MM/y G", + } + }, + { "java.time.short.Eras", + new String[] { + "tr. CN", + "sau CN", + } + }, + { "roc.DatePatterns", + new String[] { + "EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG", + "'Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG", + "dd-MM-y GGGG", + "dd/MM/y GGGG", + } + }, + { "roc.Eras", + new String[] { + "Tr\u01b0\u1edbc R.O.C", + "", + } + }, + { "roc.short.Eras", + new String[] { + "Tr\u01b0\u1edbc R.O.C", + "", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh.java b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh.java index 83e0d7871ef..1f8f7cb31ff 100644 --- a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh.java +++ b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh.java @@ -76,11 +76,11 @@ package sun.text.resources.zh; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_zh extends ListResourceBundle { +public class FormatData_zh extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -106,6 +106,23 @@ public class FormatData_zh extends ListResourceBundle { "" // month 13 if applicable } }, + { "standalone.MonthNames", + new String[] { + "\u4e00\u6708", + "\u4e8c\u6708", + "\u4e09\u6708", + "\u56db\u6708", + "\u4e94\u6708", + "\u516d\u6708", + "\u4e03\u6708", + "\u516b\u6708", + "\u4e5d\u6708", + "\u5341\u6708", + "\u5341\u4e00\u6708", + "\u5341\u4e8c\u6708", + "", + } + }, { "MonthAbbreviations", new String[] { "\u4e00\u6708", // abb january @@ -123,6 +140,40 @@ public class FormatData_zh extends ListResourceBundle { "" // abb month 13 if applicable } }, + { "standalone.MonthAbbreviations", + new String[] { + "\u4e00\u6708", + "\u4e8c\u6708", + "\u4e09\u6708", + "\u56db\u6708", + "\u4e94\u6708", + "\u516d\u6708", + "\u4e03\u6708", + "\u516b\u6708", + "\u4e5d\u6708", + "\u5341\u6708", + "\u5341\u4e00\u6708", + "\u5341\u4e8c\u6708", + "", + } + }, + { "MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, { "standalone.MonthNarrows", new String[] { "1\u6708", @@ -151,6 +202,17 @@ public class FormatData_zh extends ListResourceBundle { "\u661f\u671f\u516d" // Saturday } }, + { "standalone.DayNames", + new String[] { + "\u661f\u671f\u65e5", + "\u661f\u671f\u4e00", + "\u661f\u671f\u4e8c", + "\u661f\u671f\u4e09", + "\u661f\u671f\u56db", + "\u661f\u671f\u4e94", + "\u661f\u671f\u516d", + } + }, { "DayAbbreviations", new String[] { "\u661f\u671f\u65e5", // abb Sunday @@ -162,6 +224,17 @@ public class FormatData_zh extends ListResourceBundle { "\u661f\u671f\u516d" // abb Saturday } }, + { "standalone.DayAbbreviations", + new String[] { + "\u5468\u65e5", + "\u5468\u4e00", + "\u5468\u4e8c", + "\u5468\u4e09", + "\u5468\u56db", + "\u5468\u4e94", + "\u5468\u516d", + } + }, { "DayNarrows", new String[] { "\u65e5", @@ -173,6 +246,17 @@ public class FormatData_zh extends ListResourceBundle { "\u516d", } }, + { "standalone.DayNarrows", + new String[] { + "\u65e5", + "\u4e00", + "\u4e8c", + "\u4e09", + "\u56db", + "\u4e94", + "\u516d", + } + }, { "AmPmMarkers", new String[] { "\u4e0a\u5348", // am marker @@ -185,6 +269,21 @@ public class FormatData_zh extends ListResourceBundle { "\u516c\u5143" } }, + { "buddhist.Eras", + new String[] { + "BC", + "\u4f5b\u5386", + } + }, + { "japanese.Eras", + new String[] { + "\u516c\u5143", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, { "TimePatterns", new String[] { "ahh'\u65f6'mm'\u5206'ss'\u79d2' z", // full time pattern @@ -206,49 +305,15 @@ public class FormatData_zh extends ListResourceBundle { "{1} {0}" // date-time pattern } }, - { "cldr.buddhist.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gyyyy-M-d", - "Gy-M-d", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy\u5e74M\u6708d\u65e5", - "Gyy-MM-dd", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy-M-d", - "Gy-M-d", - } - }, - { "roc.DatePatterns", + { "buddhist.DatePatterns", new String[] { "GGGGy\u5e74M\u6708d\u65e5EEEE", "GGGGy\u5e74M\u6708d\u65e5", - "GGGGy-M-d", + "GGGGyyyy-M-d", "GGGGy-M-d", } }, - { "cldr.islamic.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy\u5e74M\u6708d\u65e5", - "Gyy-MM-dd", - } - }, - { "islamic.DatePatterns", + { "japanese.DatePatterns", new String[] { "GGGGy\u5e74M\u6708d\u65e5EEEE", "GGGGy\u5e74M\u6708d\u65e5", @@ -256,24 +321,6 @@ public class FormatData_zh extends ListResourceBundle { "GGGGyy-MM-dd", } }, - { "calendarname.islamic-civil", "\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386" }, - { "calendarname.islamicc", "\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386" }, - { "calendarname.islamic", "\u4f0a\u65af\u5170\u65e5\u5386" }, - { "calendarname.japanese", "\u65e5\u672c\u65e5\u5386" }, - { "calendarname.gregorian", "\u516c\u5386" }, - { "calendarname.gregory", "\u516c\u5386" }, - { "calendarname.roc", "\u6c11\u56fd\u65e5\u5386" }, - { "calendarname.buddhist", "\u4f5b\u6559\u65e5\u5386" }, - { "field.era", "\u65f6\u671f" }, - { "field.year", "\u5e74" }, - { "field.month", "\u6708" }, - { "field.week", "\u5468" }, - { "field.weekday", "\u5468\u5929" }, - { "field.dayperiod", "\u4e0a\u5348/\u4e0b\u5348" }, - { "field.hour", "\u5c0f\u65f6" }, - { "field.minute", "\u5206\u949f" }, - { "field.second", "\u79d2\u949f" }, - { "field.zone", "\u533a\u57df" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_CN.java b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_CN.java index 4aea955c015..24734a0756e 100644 --- a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_CN.java +++ b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_CN.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,11 +40,11 @@ package sun.text.resources.zh; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_zh_CN extends ListResourceBundle { +public class FormatData_zh_CN extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ protected final Object[][] getContents() { return new Object[][] { diff --git a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_HK.java b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_HK.java index 23c3f6e43fe..a81d2043849 100644 --- a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_HK.java +++ b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_HK.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,13 +40,13 @@ package sun.text.resources.zh; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; import java.util.Locale; import java.util.ResourceBundle; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.ResourceBundleBasedAdapter; -public class FormatData_zh_HK extends ListResourceBundle { +public class FormatData_zh_HK extends ParallelListResourceBundle { // reparent to zh_TW for traditional Chinese names public FormatData_zh_HK() { @@ -56,7 +56,7 @@ public class FormatData_zh_HK extends ListResourceBundle { } /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { diff --git a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_SG.java b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_SG.java index d1eb53aced4..4ca1468d293 100644 --- a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_SG.java +++ b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_SG.java @@ -1,5 +1,26 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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. */ /* @@ -38,13 +59,11 @@ * authorization of the copyright holder. */ -// Generated automatically from the Common Locale Data Repository. DO NOT EDIT! - package sun.text.resources.zh; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_zh_SG extends ListResourceBundle { +public class FormatData_zh_SG extends ParallelListResourceBundle { protected final Object[][] getContents() { return new Object[][] { { "DayAbbreviations", diff --git a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_TW.java b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_TW.java index 7171bd9b166..83b9cca5c33 100644 --- a/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_TW.java +++ b/jdk/src/share/classes/sun/text/resources/zh/FormatData_zh_TW.java @@ -76,11 +76,11 @@ package sun.text.resources.zh; -import java.util.ListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; -public class FormatData_zh_TW extends ListResourceBundle { +public class FormatData_zh_TW extends ParallelListResourceBundle { /** - * Overrides ListResourceBundle + * Overrides ParallelListResourceBundle */ @Override protected final Object[][] getContents() { @@ -95,6 +95,40 @@ public class FormatData_zh_TW extends ListResourceBundle { "\u897f\u5143" } }, + { "standalone.MonthAbbreviations", + new String[] { + "1\u6708", + "2\u6708", + "3\u6708", + "4\u6708", + "5\u6708", + "6\u6708", + "7\u6708", + "8\u6708", + "9\u6708", + "10\u6708", + "11\u6708", + "12\u6708", + "", + } + }, + { "MonthNarrows", + new String[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "", + } + }, { "NumberPatterns", new String[] { "#,##0.###;-#,##0.###", // decimal pattern @@ -123,74 +157,23 @@ public class FormatData_zh_TW extends ListResourceBundle { "{1} {0}" // date-time pattern } }, + { "buddhist.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy/M/d", + "GGGGy/M/d", + } + }, + { "japanese.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy/M/d", + "GGGGy/M/d", + } + }, { "DateTimePatternChars", "GyMdkHmsSEDFwWahKzZ" }, - { "cldr.buddhist.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy/M/d", - "Gy/M/d", - } - }, - { "cldr.japanese.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy/M/d", - "Gy/M/d", - } - }, - { "roc.Eras", rocEras }, - { "roc.short.Eras", rocEras }, - { "cldr.roc.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy/M/d", - "Gy/M/d", - } - }, - { "roc.DatePatterns", - new String[] { - "GGGGy\u5e74M\u6708d\u65e5EEEE", - "GGGGy\u5e74M\u6708d\u65e5", - "GGGGy/M/d", - "GGGGy/M/d", - } - }, - { "cldr.islamic.DatePatterns", - new String[] { - "Gy\u5e74M\u6708d\u65e5EEEE", - "Gy\u5e74M\u6708d\u65e5", - "Gy/M/d", - "Gy/M/d", - } - }, - { "islamic.DatePatterns", - new String[] { - "GGGGy\u5e74M\u6708d\u65e5EEEE", - "GGGGy\u5e74M\u6708d\u65e5", - "GGGGy/M/d", - "GGGGy/M/d", - } - }, - { "calendarname.islamic-civil", "\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5" }, - { "calendarname.islamicc", "\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5" }, - { "calendarname.islamic", "\u4f0a\u65af\u862d\u66c6\u6cd5" }, - { "calendarname.japanese", "\u65e5\u672c\u66c6\u6cd5" }, - { "calendarname.gregorian", "\u516c\u66c6" }, - { "calendarname.gregory", "\u516c\u66c6" }, - { "calendarname.roc", "\u6c11\u570b\u66c6" }, - { "calendarname.buddhist", "\u4f5b\u6559\u66c6\u6cd5" }, - { "field.era", "\u5e74\u4ee3" }, - { "field.year", "\u5e74" }, - { "field.month", "\u6708" }, - { "field.week", "\u9031" }, - { "field.weekday", "\u9031\u5929" }, - { "field.dayperiod", "\u4e0a\u5348/\u4e0b\u5348" }, - { "field.hour", "\u5c0f\u6642" }, - { "field.minute", "\u5206\u9418" }, - { "field.second", "\u79d2" }, }; } } diff --git a/jdk/src/share/classes/sun/text/resources/zh/JavaTimeSupplementary_zh.java b/jdk/src/share/classes/sun/text/resources/zh/JavaTimeSupplementary_zh.java new file mode 100644 index 00000000000..e5f44fd71c7 --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/zh/JavaTimeSupplementary_zh.java @@ -0,0 +1,236 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.zh; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_zh extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterAbbreviations", + new String[] { + "1\u5b63", + "2\u5b63", + "3\u5b63", + "4\u5b63", + } + }, + { "QuarterNames", + new String[] { + "\u7b2c1\u5b63\u5ea6", + "\u7b2c2\u5b63\u5ea6", + "\u7b2c3\u5b63\u5ea6", + "\u7b2c4\u5b63\u5ea6", + } + }, + { "QuarterNarrows", + new String[] { + "1", + "2", + "3", + "4", + } + }, + { "calendarname.buddhist", + "\u4f5b\u6559\u65e5\u5386" }, + { "calendarname.gregorian", + "\u516c\u5386" }, + { "calendarname.gregory", + "\u516c\u5386" }, + { "calendarname.islamic", + "\u4f0a\u65af\u5170\u65e5\u5386" }, + { "calendarname.islamic-civil", + "\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386" }, + { "calendarname.islamicc", + "\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386" }, + { "calendarname.japanese", + "\u65e5\u672c\u65e5\u5386" }, + { "calendarname.roc", + "\u6c11\u56fd\u65e5\u5386" }, + { "field.dayperiod", + "\u4e0a\u5348/\u4e0b\u5348" }, + { "field.era", + "\u65f6\u671f" }, + { "field.hour", + "\u5c0f\u65f6" }, + { "field.minute", + "\u5206\u949f" }, + { "field.month", + "\u6708" }, + { "field.second", + "\u79d2\u949f" }, + { "field.week", + "\u5468" }, + { "field.weekday", + "\u5468\u5929" }, + { "field.year", + "\u5e74" }, + { "field.zone", + "\u533a\u57df" }, + { "islamic.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGyy-MM-dd", + } + }, + { "islamic.Eras", + new String[] { + "", + "\u56de\u5386", + } + }, + { "islamic.short.Eras", + new String[] { + "", + "\u56de\u5386", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gyyyy-M-d", + "Gy-M-d", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\u4f5b\u5386", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy\u5e74M\u6708d\u65e5", + "Gyy-MM-dd", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy\u5e74M\u6708d\u65e5", + "Gyy-MM-dd", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u516c\u5143", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u516c\u5143", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy-M-d", + "Gy-M-d", + } + }, + { "java.time.short.Eras", + new String[] { + "\u516c\u5143\u524d", + "\u516c\u5143", + } + }, + { "roc.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy-M-d", + "GGGGy-M-d", + } + }, + { "roc.Eras", + new String[] { + "\u6c11\u56fd\u524d", + "\u6c11\u56fd", + } + }, + { "roc.short.Eras", + new String[] { + "\u6c11\u56fd\u524d", + "\u6c11\u56fd", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/text/resources/zh/JavaTimeSupplementary_zh_TW.java b/jdk/src/share/classes/sun/text/resources/zh/JavaTimeSupplementary_zh_TW.java new file mode 100644 index 00000000000..7359b8eeafc --- /dev/null +++ b/jdk/src/share/classes/sun/text/resources/zh/JavaTimeSupplementary_zh_TW.java @@ -0,0 +1,225 @@ +/* + * 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. 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. + */ + +/* + * COPYRIGHT AND PERMISSION NOTICE + * + * Copyright (C) 1991-2012 Unicode, Inc. All rights reserved. Distributed under + * the Terms of Use in http://www.unicode.org/copyright.html. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of the Unicode data files and any associated documentation (the "Data + * Files") or Unicode software and any associated documentation (the + * "Software") to deal in the Data Files or Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, and/or sell copies of the Data Files or Software, and + * to permit persons to whom the Data Files or Software are furnished to do so, + * provided that (a) the above copyright notice(s) and this permission notice + * appear with all copies of the Data Files or Software, (b) both the above + * copyright notice(s) and this permission notice appear in associated + * documentation, and (c) there is clear notice in each modified Data File or + * in the Software as well as in the documentation associated with the Data + * File(s) or Software that the data or software has been modified. + * + * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY + * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR + * CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THE DATA FILES OR SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in these Data Files or Software without prior written authorization + * of the copyright holder. + */ + +// Note: this file has been generated by a tool. + +package sun.text.resources.zh; + +import sun.util.resources.OpenListResourceBundle; + +public class JavaTimeSupplementary_zh_TW extends OpenListResourceBundle { + @Override + protected final Object[][] getContents() { + return new Object[][] { + { "QuarterNames", + new String[] { + "\u7b2c1\u5b63", + "\u7b2c2\u5b63", + "\u7b2c3\u5b63", + "\u7b2c4\u5b63", + } + }, + { "calendarname.buddhist", + "\u4f5b\u6559\u66c6\u6cd5" }, + { "calendarname.gregorian", + "\u516c\u66c6" }, + { "calendarname.gregory", + "\u516c\u66c6" }, + { "calendarname.islamic", + "\u4f0a\u65af\u862d\u66c6\u6cd5" }, + { "calendarname.islamic-civil", + "\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5" }, + { "calendarname.islamicc", + "\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5" }, + { "calendarname.japanese", + "\u65e5\u672c\u66c6\u6cd5" }, + { "calendarname.roc", + "\u6c11\u570b\u66c6" }, + { "field.dayperiod", + "\u4e0a\u5348/\u4e0b\u5348" }, + { "field.era", + "\u5e74\u4ee3" }, + { "field.hour", + "\u5c0f\u6642" }, + { "field.minute", + "\u5206\u9418" }, + { "field.month", + "\u6708" }, + { "field.second", + "\u79d2" }, + { "field.week", + "\u9031" }, + { "field.weekday", + "\u9031\u5929" }, + { "field.year", + "\u5e74" }, + { "field.zone", + "\u6642\u5340" }, + { "islamic.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy/M/d", + "GGGGy/M/d", + } + }, + { "islamic.MonthNames", + new String[] { + "\u7a46\u54c8\u862d\u59c6\u6708", + "\u8272\u6cd5\u723e\u6708", + "\u8cf4\u6bd4\u6708 I", + "\u8cf4\u6bd4\u6708 II", + "\u4e3b\u99ac\u9054\u6708 I", + "\u4e3b\u99ac\u9054\u6708 II", + "\u8cf4\u54f2\u535c\u6708", + "\u820d\u723e\u90a6\u6708", + "\u8cf4\u8cb7\u4e39\u6708", + "\u9583\u74e6\u9b6f\u6708", + "\u90fd\u723e\u5580\u723e\u5fb7\u6708", + "\u90fd\u723e\u9ed1\u54f2\u6708", + "", + } + }, + { "java.time.buddhist.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy/M/d", + "Gy/M/d", + } + }, + { "java.time.buddhist.short.Eras", + new String[] { + "BC", + "\u4f5b\u66c6", + } + }, + { "java.time.islamic.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy/M/d", + "Gy/M/d", + } + }, + { "java.time.japanese.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy/M/d", + "Gy/M/d", + } + }, + { "java.time.japanese.long.Eras", + new String[] { + "\u897f\u5143", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.japanese.short.Eras", + new String[] { + "\u897f\u5143", + "\u660e\u6cbb", + "\u5927\u6b63", + "\u662d\u548c", + "\u5e73\u6210", + } + }, + { "java.time.roc.DatePatterns", + new String[] { + "Gy\u5e74M\u6708d\u65e5EEEE", + "Gy\u5e74M\u6708d\u65e5", + "Gy/M/d", + "Gy/M/d", + } + }, + { "java.time.short.Eras", + new String[] { + "\u897f\u5143\u524d", + "\u897f\u5143", + } + }, + { "roc.DatePatterns", + new String[] { + "GGGGy\u5e74M\u6708d\u65e5EEEE", + "GGGGy\u5e74M\u6708d\u65e5", + "GGGGy/M/d", + "GGGGy/M/d", + } + }, + { "roc.Eras", + new String[] { + "\u6c11\u570b\u524d", + "\u6c11\u570b", + } + }, + { "roc.short.Eras", + new String[] { + "\u6c11\u570b\u524d", + "\u6c11\u570b", + } + }, + }; + } +} diff --git a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java index 995ec45fcc7..c781dedf363 100644 --- a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java +++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java @@ -561,8 +561,7 @@ public class ZoneInfo extends TimeZone { * @return an array of time zone IDs. */ public static String[] getAvailableIDs() { - Set idSet = ZoneInfoFile.getZoneIds(); - return idSet.toArray(new String[idSet.size()]); + return ZoneInfoFile.getZoneIds(); } /** diff --git a/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java b/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java index 2bddab21f2d..b003c2eead0 100644 --- a/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java +++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java @@ -29,21 +29,13 @@ import java.io.ByteArrayInputStream; import java.io.DataInput; import java.io.DataInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.StreamCorruptedException; import java.security.AccessController; import java.security.PrivilegedAction; -import java.time.DayOfWeek; import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.Month; -import java.time.OffsetDateTime; import java.time.ZoneOffset; -import java.time.zone.ZoneRules; -import java.time.zone.ZoneOffsetTransition; -import java.time.zone.ZoneOffsetTransitionRule; -import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; - import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -58,7 +50,7 @@ import java.util.Set; import java.util.SimpleTimeZone; import java.util.concurrent.ConcurrentHashMap; import java.util.zip.CRC32; -import java.util.zip.ZipFile; +import sun.security.action.GetPropertyAction; /** * Loads TZDB time-zone rules for j.u.TimeZone @@ -72,8 +64,13 @@ public final class ZoneInfoFile { * * @return a set of time zone IDs. */ - public static Set getZoneIds() { - return zones.keySet(); + public static String[] getZoneIds() { + String[] ids = Arrays.copyOf(regions, regions.length + oldMappings.length); + int i = regions.length; + for (int j = 0; j < oldMappings.length; j++) { + ids[i++] = oldMappings[j][0]; + } + return ids; } /** @@ -86,8 +83,8 @@ public final class ZoneInfoFile { */ public static String[] getZoneIds(int rawOffset) { List ids = new ArrayList<>(); - for (String id : zones.keySet()) { - ZoneInfo zi = getZoneInfo0(id); + for (String id : getZoneIds()) { + ZoneInfo zi = getZoneInfo(id); if (zi.getRawOffset() == rawOffset) { ids.add(id); } @@ -102,17 +99,42 @@ public final class ZoneInfoFile { } public static ZoneInfo getZoneInfo(String zoneId) { - if (!zones.containsKey(zoneId)) { + if (zoneId == null) { return null; } - // ZoneInfo is mutable, return the copy - ZoneInfo zi = getZoneInfo0(zoneId); - zi = (ZoneInfo)zi.clone(); - zi.setID(zoneId); + if (zi != null) { + zi = (ZoneInfo)zi.clone(); + zi.setID(zoneId); + } return zi; } + private static ZoneInfo getZoneInfo0(String zoneId) { + try { + ZoneInfo zi = zones.get(zoneId); + if (zi != null) { + return zi; + } + String zid = zoneId; + if (aliases.containsKey(zoneId)) { + zid = aliases.get(zoneId); + } + int index = Arrays.binarySearch(regions, zid); + if (index < 0) { + return null; + } + byte[] bytes = ruleArray[indices[index]]; + DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bytes)); + zi = getZoneInfo(dis, zid); + zones.put(zoneId, zi); + return zi; + } catch (Exception ex) { + throw new RuntimeException("Invalid binary time-zone data: TZDB:" + + zoneId + ", version: " + versionId, ex); + } + } + /** * Returns a Map from alias time zone IDs to their standard * time zone IDs. @@ -120,7 +142,7 @@ public final class ZoneInfoFile { * @return an unmodified alias mapping */ public static Map getAliasMap() { - return aliases; + return Collections.unmodifiableMap(aliases); } /** @@ -143,23 +165,11 @@ public final class ZoneInfoFile { public static ZoneInfo getCustomTimeZone(String originalId, int gmtOffset) { String id = toCustomID(gmtOffset); return new ZoneInfo(id, gmtOffset); -/* - ZoneInfo zi = getFromCache(id); - if (zi == null) { - zi = new ZoneInfo(id, gmtOffset); - zi = addToCache(id, zi); - if (!id.equals(originalId)) { - zi = addToCache(originalId, zi); - } - } - return (ZoneInfo) zi.clone(); -*/ } public static String toCustomID(int gmtOffset) { char sign; int offset = gmtOffset / 60000; - if (offset >= 0) { sign = '+'; } else { @@ -181,49 +191,59 @@ public final class ZoneInfoFile { return new String(buf); } - /////////////////////////////////////////////////////////// - - private static ZoneInfo getZoneInfo0(String zoneId) { - try { - - Object obj = zones.get(zoneId); - if (obj instanceof byte[]) { - byte[] bytes = (byte[]) obj; - DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bytes)); - obj = getZoneInfo(dis, zoneId); - zones.put(zoneId, obj); - } - return (ZoneInfo)obj; - } catch (Exception ex) { - throw new RuntimeException("Invalid binary time-zone data: TZDB:" + - zoneId + ", version: " + versionId, ex); - } - } - private ZoneInfoFile() { } private static String versionId; - private final static Map zones = new ConcurrentHashMap<>(); + private final static Map zones = new ConcurrentHashMap<>(); private static Map aliases = new HashMap<>(); + private static byte[][] ruleArray; + private static String[] regions; + private static int[] indices; + // Flag for supporting JDK backward compatible IDs, such as "EST". private static final boolean USE_OLDMAPPING; + private static String[][] oldMappings = new String[][] { + { "ACT", "Australia/Darwin" }, + { "AET", "Australia/Sydney" }, + { "AGT", "America/Argentina/Buenos_Aires" }, + { "ART", "Africa/Cairo" }, + { "AST", "America/Anchorage" }, + { "BET", "America/Sao_Paulo" }, + { "BST", "Asia/Dhaka" }, + { "CAT", "Africa/Harare" }, + { "CNT", "America/St_Johns" }, + { "CST", "America/Chicago" }, + { "CTT", "Asia/Shanghai" }, + { "EAT", "Africa/Addis_Ababa" }, + { "ECT", "Europe/Paris" }, + { "IET", "America/Indiana/Indianapolis" }, + { "IST", "Asia/Kolkata" }, + { "JST", "Asia/Tokyo" }, + { "MIT", "Pacific/Apia" }, + { "NET", "Asia/Yerevan" }, + { "NST", "Pacific/Auckland" }, + { "PLT", "Asia/Karachi" }, + { "PNT", "America/Phoenix" }, + { "PRT", "America/Puerto_Rico" }, + { "PST", "America/Los_Angeles" }, + { "SST", "Pacific/Guadalcanal" }, + { "VST", "Asia/Ho_Chi_Minh" }, + }; + static { String oldmapping = AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("sun.timezone.ids.oldmapping", "false")).toLowerCase(Locale.ROOT); + new GetPropertyAction("sun.timezone.ids.oldmapping", "false")).toLowerCase(Locale.ROOT); USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true")); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { - String libDir = System.getProperty("java.home") + File.separator + "lib"; - File tzdbJar = new File(libDir, "tzdb.jar"); - try (ZipFile zf = new ZipFile(tzdbJar); - DataInputStream dis = new DataInputStream( - zf.getInputStream(zf.getEntry("TZDB.dat")))) { + try (DataInputStream dis = new DataInputStream( + new FileInputStream(new File(libDir, "tzdb.dat")))) { load(dis); } } catch (Exception x) { @@ -234,56 +254,14 @@ public final class ZoneInfoFile { }); } - // Must be invoked after loading in all data private static void addOldMapping() { - String[][] oldMappings = new String[][] { - { "ACT", "Australia/Darwin" }, - { "AET", "Australia/Sydney" }, - { "AGT", "America/Argentina/Buenos_Aires" }, - { "ART", "Africa/Cairo" }, - { "AST", "America/Anchorage" }, - { "BET", "America/Sao_Paulo" }, - { "BST", "Asia/Dhaka" }, - { "CAT", "Africa/Harare" }, - { "CNT", "America/St_Johns" }, - { "CST", "America/Chicago" }, - { "CTT", "Asia/Shanghai" }, - { "EAT", "Africa/Addis_Ababa" }, - { "ECT", "Europe/Paris" }, - { "IET", "America/Indiana/Indianapolis" }, - { "IST", "Asia/Kolkata" }, - { "JST", "Asia/Tokyo" }, - { "MIT", "Pacific/Apia" }, - { "NET", "Asia/Yerevan" }, - { "NST", "Pacific/Auckland" }, - { "PLT", "Asia/Karachi" }, - { "PNT", "America/Phoenix" }, - { "PRT", "America/Puerto_Rico" }, - { "PST", "America/Los_Angeles" }, - { "SST", "Pacific/Guadalcanal" }, - { "VST", "Asia/Ho_Chi_Minh" }, - }; for (String[] alias : oldMappings) { - String k = alias[0]; - String v = alias[1]; - if (zones.containsKey(v)) { // make sure we do have the data - aliases.put(k, v); - zones.put(k, zones.get(v)); - } + aliases.put(alias[0], alias[1]); } if (USE_OLDMAPPING) { - if (zones.containsKey("America/New_York")) { - aliases.put("EST", "America/New_York"); - zones.put("EST", zones.get("America/New_York")); - } - if (zones.containsKey("America/Denver")) { - aliases.put("MST", "America/Denver"); - zones.put("MST", zones.get("America/Denver")); - } - if (zones.containsKey("Pacific/Honolulu")) { - aliases.put("HST", "Pacific/Honolulu"); - zones.put("HST", zones.get("Pacific/Honolulu")); - } + aliases.put("EST", "America/New_York"); + aliases.put("MST", "America/Denver"); + aliases.put("HST", "Pacific/Honolulu"); } } @@ -316,7 +294,7 @@ public final class ZoneInfoFile { } // rules int ruleCount = dis.readShort(); - Object[] ruleArray = new Object[ruleCount]; + ruleArray = new byte[ruleCount][]; for (int i = 0; i < ruleCount; i++) { byte[] bytes = new byte[dis.readShort()]; dis.readFully(bytes); @@ -325,11 +303,11 @@ public final class ZoneInfoFile { // link version-region-rules, only keep the last version, if more than one for (int i = 0; i < versionCount; i++) { regionCount = dis.readShort(); - zones.clear(); + regions = new String[regionCount]; + indices = new int[regionCount]; for (int j = 0; j < regionCount; j++) { - String region = regionArray[dis.readShort()]; - Object rule = ruleArray[dis.readShort() & 0xffff]; - zones.put(region, rule); + regions[j] = regionArray[dis.readShort()]; + indices[j] = dis.readShort(); } } // remove the following ids from the map, they @@ -346,7 +324,6 @@ public final class ZoneInfoFile { } // old us time-zone names addOldMapping(); - aliases = Collections.unmodifiableMap(aliases); } /////////////////////////Ser///////////////////////////////// @@ -374,7 +351,7 @@ public final class ZoneInfoFile { int ruleSize = in.readByte(); ZoneOffsetTransitionRule[] rules = new ZoneOffsetTransitionRule[ruleSize]; for (int i = 0; i < ruleSize; i++) { - rules[i] = readZOTRule(in); + rules[i] = new ZoneOffsetTransitionRule(in); } return getZoneInfo(zoneId, stdTrans, stdOffsets, savTrans, savOffsets, rules); } @@ -396,31 +373,19 @@ public final class ZoneInfoFile { } } - static ZoneOffsetTransitionRule readZOTRule(DataInput in) throws IOException { - int data = in.readInt(); - Month month = Month.of(data >>> 28); - int dom = ((data & (63 << 22)) >>> 22) - 32; - int dowByte = (data & (7 << 19)) >>> 19; - DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte); - int timeByte = (data & (31 << 14)) >>> 14; - TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12]; - int stdByte = (data & (255 << 4)) >>> 4; - int beforeByte = (data & (3 << 2)) >>> 2; - int afterByte = (data & 3); - LocalTime time = (timeByte == 31 ? LocalTime.ofSecondOfDay(in.readInt()) : LocalTime.of(timeByte % 24, 0)); - ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900)); - ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800)); - ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800)); - return ZoneOffsetTransitionRule.of(month, dom, dow, time, timeByte == 24, defn, std, before, after); - } - /////////////////////////ZoneRules --> ZoneInfo///////////////////////////////// // ZoneInfo starts with UTC1900 private static final long UTC1900 = -2208988800L; + // ZoneInfo ends with UTC2037 - private static final long UTC2037 = - LocalDateTime.of(2038, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1; + // LocalDateTime.of(2038, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1; + private static final long UTC2037 = 2145916799L; + + // ZoneInfo has an ending entry for 2037, this need to be offset by + // a "rawOffset" + // LocalDateTime.of(2037, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC)); + private static final long LDT2037 = 2114380800L; /* Get a ZoneInfo instance. * @@ -460,15 +425,12 @@ public final class ZoneInfoFile { // offsets.length > 16 (4-bit index limit) // last year in trans table // It should not matter to use before or after offset for year - int lastyear = LocalDateTime.ofEpochSecond( - savingsInstantTransitions[savingsInstantTransitions.length - 1], 0, - ZoneOffset.ofTotalSeconds(wallOffsets[savingsInstantTransitions.length - 1])).getYear(); - // int lastyear = savingsLocalTransitions[savingsLocalTransitions.length - 1].getYear(); - + int lastyear = getYear(savingsInstantTransitions[savingsInstantTransitions.length - 1], + wallOffsets[savingsInstantTransitions.length - 1]); int i = 0, k = 1; while (i < savingsInstantTransitions.length && savingsInstantTransitions[i] < UTC1900) { - i++; // skip any date before UTC1900 + i++; // skip any date before UTC1900 } if (i < savingsInstantTransitions.length) { // javazic writes the last GMT offset into index 0! @@ -478,26 +440,27 @@ public final class ZoneInfoFile { } // ZoneInfo has a beginning entry for 1900. // Only add it if this is not the only one in table - nOffsets = addTrans(transitions, nTrans++, offsets, nOffsets, + nOffsets = addTrans(transitions, nTrans++, + offsets, nOffsets, UTC1900, wallOffsets[i], getStandardOffset(standardTransitions, standardOffsets, UTC1900)); } + for (; i < savingsInstantTransitions.length; i++) { - //if (savingsLocalTransitions[i * 2].getYear() > LASTYEAR) { - if (savingsInstantTransitions[i] > UTC2037) { + long trans = savingsInstantTransitions[i]; + if (trans > UTC2037) { // no trans beyond LASTYEAR lastyear = LASTYEAR; break; } - long trans = savingsInstantTransitions[i]; while (k < standardTransitions.length) { // some standard offset transitions don't exist in // savingInstantTrans, if the offset "change" doesn't // really change the "effectiveWallOffset". For example // the 1999/2000 pair in Zone Arg/Buenos_Aires, in which // the daylightsaving "happened" but it actually does - // not result in the timezone switch. ZoneInfo however + // not result in the timezone switch. ZoneInfo however // needs them in its transitions table long trans_s = standardTransitions[k]; if (trans_s >= UTC1900) { @@ -514,6 +477,7 @@ public final class ZoneInfoFile { trans_s, wallOffsets[i], standardOffsets[k+1]); + } } k++; @@ -528,6 +492,7 @@ public final class ZoneInfoFile { trans, wallOffsets[i + 1], getStandardOffset(standardTransitions, standardOffsets, trans)); + } // append any leftover standard trans while (k < standardTransitions.length) { @@ -546,38 +511,35 @@ public final class ZoneInfoFile { // fill the gap between the last trans until LASTYEAR while (lastyear++ < LASTYEAR) { for (ZoneOffsetTransitionRule zotr : lastRules) { - ZoneOffsetTransition zot = zotr.createTransition(lastyear); - //long trans = zot.getDateTimeBefore().toEpochSecond(); - long trans = zot.toEpochSecond(); + long trans = zotr.getTransitionEpochSecond(lastyear); if (nOffsets + 2 >= offsets.length) { offsets = Arrays.copyOf(offsets, offsets.length + 100); } if (nTrans + 1 >= transitions.length) { transitions = Arrays.copyOf(transitions, transitions.length + 100); } - nOffsets = addTrans(transitions, nTrans++, offsets, nOffsets, + nOffsets = addTrans(transitions, nTrans++, + offsets, nOffsets, trans, - zot.getOffsetAfter().getTotalSeconds(), - getStandardOffset(standardTransitions, standardOffsets, trans)); + zotr.offsetAfter, + zotr.standardOffset); } } ZoneOffsetTransitionRule startRule = lastRules[lastRules.length - 2]; ZoneOffsetTransitionRule endRule = lastRules[lastRules.length - 1]; params = new int[10]; - if (startRule.getOffsetBefore().compareTo(startRule.getOffsetAfter()) < 0 && - endRule.getOffsetBefore().compareTo(endRule.getOffsetAfter()) > 0) { + if (startRule.offsetAfter - startRule.offsetBefore < 0 && + endRule.offsetAfter - endRule.offsetBefore > 0) { ZoneOffsetTransitionRule tmp; tmp = startRule; startRule = endRule; endRule = tmp; } - params[0] = startRule.getMonth().getValue() - 1; - // params[1] = startRule.getDayOfMonthIndicator(); - // params[2] = toCalendarDOW[startRule.getDayOfWeek().getValue()]; - int dom = startRule.getDayOfMonthIndicator(); - DayOfWeek dow = startRule.getDayOfWeek(); - if (dow == null) { - params[1] = startRule.getDayOfMonthIndicator(); + params[0] = startRule.month - 1; + int dom = startRule.dom; + int dow = startRule.dow; + if (dow == -1) { + params[1] = dom; params[2] = 0; } else { // ZoneRulesBuilder adjusts < 0 case (-1, for last, don't have @@ -590,41 +552,38 @@ public final class ZoneInfoFile { // "last", it works for now. if (dom < 0 || dom >= 24) { params[1] = -1; - params[2] = toCalendarDOW[dow.getValue()]; + params[2] = toCalendarDOW[dow]; } else { params[1] = dom; // To specify a day of week on or after an exact day of month, // set the month to an exact month value, day-of-month to the // day on or after which the rule is applied, and day-of-week // to a negative Calendar.DAY_OF_WEEK DAY_OF_WEEK field value. - params[2] = -toCalendarDOW[dow.getValue()]; + params[2] = -toCalendarDOW[dow]; } } - params[3] = startRule.getLocalTime().toSecondOfDay() * 1000; - params[4] = toSTZTime[startRule.getTimeDefinition().ordinal()]; - - params[5] = endRule.getMonth().getValue() - 1; - // params[6] = endRule.getDayOfMonthIndicator(); - // params[7] = toCalendarDOW[endRule.getDayOfWeek().getValue()]; - dom = endRule.getDayOfMonthIndicator(); - dow = endRule.getDayOfWeek(); - if (dow == null) { + params[3] = startRule.secondOfDay * 1000; + params[4] = toSTZTime[startRule.timeDefinition]; + params[5] = endRule.month - 1; + dom = endRule.dom; + dow = endRule.dow; + if (dow == -1) { params[6] = dom; params[7] = 0; } else { // hacking: see comment above if (dom < 0 || dom >= 24) { params[6] = -1; - params[7] = toCalendarDOW[dow.getValue()]; + params[7] = toCalendarDOW[dow]; } else { params[6] = dom; - params[7] = -toCalendarDOW[dow.getValue()]; + params[7] = -toCalendarDOW[dow]; } } - params[8] = endRule.getLocalTime().toSecondOfDay() * 1000; - params[9] = toSTZTime[endRule.getTimeDefinition().ordinal()]; - dstSavings = (startRule.getOffsetAfter().getTotalSeconds() - - startRule.getOffsetBefore().getTotalSeconds()) * 1000; + params[8] = endRule.secondOfDay * 1000; + params[9] = toSTZTime[endRule.timeDefinition]; + dstSavings = (startRule.offsetAfter - startRule.offsetBefore) * 1000; + // Note: known mismatching -> Asia/Amman // ZoneInfo : startDayOfWeek=5 <= Thursday // startTime=86400000 <= 24 hours @@ -638,14 +597,17 @@ public final class ZoneInfoFile { } else if (nTrans > 0) { // only do this if there is something in table already if (lastyear < LASTYEAR) { // ZoneInfo has an ending entry for 2037 - long trans = OffsetDateTime.of(LASTYEAR, Month.JANUARY.getValue(), 1, 0, 0, 0, 0, - ZoneOffset.ofTotalSeconds(rawOffset/1000)) - .toEpochSecond(); + //long trans = OffsetDateTime.of(LASTYEAR, 1, 1, 0, 0, 0, 0, + // ZoneOffset.ofTotalSeconds(rawOffset/1000)) + // .toEpochSecond(); + long trans = LDT2037 - rawOffset/1000; + int offsetIndex = indexOf(offsets, 0, nOffsets, rawOffset/1000); if (offsetIndex == nOffsets) nOffsets++; transitions[nTrans++] = (trans * 1000) << TRANSITION_NSHIFT | (offsetIndex & OFFSET_MASK); + } else if (savingsInstantTransitions.length > 2) { // Workaround: create the params based on the last pair for // zones like Israel and Iran which have trans defined @@ -670,40 +632,28 @@ public final class ZoneInfoFile { long endTrans = savingsInstantTransitions[m - 1]; int endOffset = wallOffsets[m - 1 + 1]; int endStd = getStandardOffset(standardTransitions, standardOffsets, endTrans); - if (startOffset > startStd && endOffset == endStd) { - /* - m = savingsLocalTransitions.length; - LocalDateTime startLDT = savingsLocalTransitions[m -4]; //gap - LocalDateTime endLDT = savingsLocalTransitions[m - 1]; //over - */ // last - 1 trans m = savingsInstantTransitions.length - 2; ZoneOffset before = ZoneOffset.ofTotalSeconds(wallOffsets[m]); ZoneOffset after = ZoneOffset.ofTotalSeconds(wallOffsets[m + 1]); - ZoneOffsetTransition trans = ZoneOffsetTransition.of( - LocalDateTime.ofEpochSecond(savingsInstantTransitions[m], 0, before), - before, - after); + LocalDateTime ldt = LocalDateTime.ofEpochSecond(savingsInstantTransitions[m], 0, before); LocalDateTime startLDT; - if (trans.isGap()) { - startLDT = trans.getDateTimeBefore(); + if (after.getTotalSeconds() > before.getTotalSeconds()) { // isGap() + startLDT = ldt; } else { - startLDT = trans.getDateTimeAfter(); + startLDT = ldt.plusSeconds(wallOffsets[m + 1] - wallOffsets[m]); } // last trans m = savingsInstantTransitions.length - 1; before = ZoneOffset.ofTotalSeconds(wallOffsets[m]); after = ZoneOffset.ofTotalSeconds(wallOffsets[m + 1]); - trans = ZoneOffsetTransition.of( - LocalDateTime.ofEpochSecond(savingsInstantTransitions[m], 0, before), - before, - after); + ldt = LocalDateTime.ofEpochSecond(savingsInstantTransitions[m], 0, before); LocalDateTime endLDT; - if (trans.isGap()) { - endLDT = trans.getDateTimeAfter(); + if (after.getTotalSeconds() > before.getTotalSeconds()) { // isGap() + endLDT = ldt.plusSeconds(wallOffsets[m + 1] - wallOffsets[m]); } else { - endLDT = trans.getDateTimeBefore(); + endLDT = ldt; } params = new int[10]; params[0] = startLDT.getMonthValue() - 1; @@ -722,14 +672,14 @@ public final class ZoneInfoFile { } if (transitions != null && transitions.length != nTrans) { if (nTrans == 0) { - transitions = null; + transitions = null; } else { transitions = Arrays.copyOf(transitions, nTrans); } } if (offsets != null && offsets.length != nOffsets) { if (nOffsets == 0) { - offsets = null; + offsets = null; } else { offsets = Arrays.copyOf(offsets, nOffsets); } @@ -762,15 +712,59 @@ public final class ZoneInfoFile { private static int getStandardOffset(long[] standardTransitions, int[] standardOffsets, long epochSec) { - int index = Arrays.binarySearch(standardTransitions, epochSec); - if (index < 0) { - // switch negative insert position to start of matched range - index = -index - 2; + // The size of stdOffsets is [0..9], with most are + // [1..4] entries , simple loop search is faster + // + // int index = Arrays.binarySearch(standardTransitions, epochSec); + // if (index < 0) { + // // switch negative insert position to start of matched range + // index = -index - 2; + // } + // return standardOffsets[index + 1]; + int index = 0; + for (; index < standardTransitions.length; index++) { + if (epochSec < standardTransitions[index]) { + break; + } } - return standardOffsets[index + 1]; + return standardOffsets[index]; } - private static int toCalendarDOW[] = new int[] { + static final int SECONDS_PER_DAY = 86400; + static final int DAYS_PER_CYCLE = 146097; + static final long DAYS_0000_TO_1970 = (DAYS_PER_CYCLE * 5L) - (30L * 365L + 7L); + + private static int getYear(long epochSecond, int offset) { + long second = epochSecond + offset; // overflow caught later + long epochDay = Math.floorDiv(second, SECONDS_PER_DAY); + long zeroDay = epochDay + DAYS_0000_TO_1970; + // find the march-based year + zeroDay -= 60; // adjust to 0000-03-01 so leap day is at end of four year cycle + long adjust = 0; + if (zeroDay < 0) { + // adjust negative years to positive for calculation + long adjustCycles = (zeroDay + 1) / DAYS_PER_CYCLE - 1; + adjust = adjustCycles * 400; + zeroDay += -adjustCycles * DAYS_PER_CYCLE; + } + long yearEst = (400 * zeroDay + 591) / DAYS_PER_CYCLE; + long doyEst = zeroDay - (365 * yearEst + yearEst / 4 - yearEst / 100 + yearEst / 400); + if (doyEst < 0) { + // fix estimate + yearEst--; + doyEst = zeroDay - (365 * yearEst + yearEst / 4 - yearEst / 100 + yearEst / 400); + } + yearEst += adjust; // reset any negative year + int marchDoy0 = (int) doyEst; + // convert march-based values back to january-based + int marchMonth0 = (marchDoy0 * 5 + 2) / 153; + int month = (marchMonth0 + 2) % 12 + 1; + int dom = marchDoy0 - (marchMonth0 * 306 + 5) / 10 + 1; + yearEst += marchMonth0 / 10; + return (int)yearEst; + } + + private static final int toCalendarDOW[] = new int[] { -1, Calendar.MONDAY, Calendar.TUESDAY, @@ -781,7 +775,7 @@ public final class ZoneInfoFile { Calendar.SUNDAY }; - private static int toSTZTime[] = new int[] { + private static final int toSTZTime[] = new int[] { SimpleTimeZone.UTC_TIME, SimpleTimeZone.WALL_TIME, SimpleTimeZone.STANDARD_TIME, @@ -823,28 +817,152 @@ public final class ZoneInfoFile { return nOffsets; } - ///////////////////////////////////////////////////////////// // ZoneInfo checksum, copy/pasted from javazic private static class Checksum extends CRC32 { public void update(int val) { byte[] b = new byte[4]; - b[0] = (byte)((val >>> 24) & 0xff); - b[1] = (byte)((val >>> 16) & 0xff); - b[2] = (byte)((val >>> 8) & 0xff); - b[3] = (byte)(val & 0xff); + b[0] = (byte)(val >>> 24); + b[1] = (byte)(val >>> 16); + b[2] = (byte)(val >>> 8); + b[3] = (byte)(val); update(b); } void update(long val) { byte[] b = new byte[8]; - b[0] = (byte)((val >>> 56) & 0xff); - b[1] = (byte)((val >>> 48) & 0xff); - b[2] = (byte)((val >>> 40) & 0xff); - b[3] = (byte)((val >>> 32) & 0xff); - b[4] = (byte)((val >>> 24) & 0xff); - b[5] = (byte)((val >>> 16) & 0xff); - b[6] = (byte)((val >>> 8) & 0xff); - b[7] = (byte)(val & 0xff); + b[0] = (byte)(val >>> 56); + b[1] = (byte)(val >>> 48); + b[2] = (byte)(val >>> 40); + b[3] = (byte)(val >>> 32); + b[4] = (byte)(val >>> 24); + b[5] = (byte)(val >>> 16); + b[6] = (byte)(val >>> 8); + b[7] = (byte)(val); update(b); } } + + // A simple/raw version of j.t.ZoneOffsetTransitionRule + private static class ZoneOffsetTransitionRule { + private final int month; + private final byte dom; + private final int dow; + private final int secondOfDay; + private final boolean timeEndOfDay; + private final int timeDefinition; + private final int standardOffset; + private final int offsetBefore; + private final int offsetAfter; + + ZoneOffsetTransitionRule(DataInput in) throws IOException { + int data = in.readInt(); + int dowByte = (data & (7 << 19)) >>> 19; + int timeByte = (data & (31 << 14)) >>> 14; + int stdByte = (data & (255 << 4)) >>> 4; + int beforeByte = (data & (3 << 2)) >>> 2; + int afterByte = (data & 3); + + this.month = data >>> 28; + this.dom = (byte)(((data & (63 << 22)) >>> 22) - 32); + this.dow = dowByte == 0 ? -1 : dowByte; + this.secondOfDay = timeByte == 31 ? in.readInt() : timeByte * 3600; + this.timeEndOfDay = timeByte == 24; + this.timeDefinition = (data & (3 << 12)) >>> 12; + + this.standardOffset = stdByte == 255 ? in.readInt() : (stdByte - 128) * 900; + this.offsetBefore = beforeByte == 3 ? in.readInt() : standardOffset + beforeByte * 1800; + this.offsetAfter = afterByte == 3 ? in.readInt() : standardOffset + afterByte * 1800; + } + + long getTransitionEpochSecond(int year) { + long epochDay = 0; + if (dom < 0) { + epochDay = toEpochDay(year, month, lengthOfMonth(year, month) + 1 + dom); + if (dow != -1) { + epochDay = previousOrSame(epochDay, dow); + } + } else { + epochDay = toEpochDay(year, month, dom); + if (dow != -1) { + epochDay = nextOrSame(epochDay, dow); + } + } + if (timeEndOfDay) { + epochDay += 1; + } + int difference = 0; + switch (timeDefinition) { + case 0: // UTC + difference = 0; + break; + case 1: // WALL + difference = -offsetBefore; + break; + case 2: //STANDARD + difference = -standardOffset; + break; + } + return epochDay * 86400 + secondOfDay + difference; + } + + static final boolean isLeapYear(int year) { + return ((year & 3) == 0) && ((year % 100) != 0 || (year % 400) == 0); + } + + static final int lengthOfMonth(int year, int month) { + switch (month) { + case 2: //FEBRUARY: + return isLeapYear(year)? 29 : 28; + case 4: //APRIL: + case 6: //JUNE: + case 9: //SEPTEMBER: + case 11: //NOVEMBER: + return 30; + default: + return 31; + } + } + + static final long toEpochDay(int year, int month, int day) { + long y = year; + long m = month; + long total = 0; + total += 365 * y; + if (y >= 0) { + total += (y + 3) / 4 - (y + 99) / 100 + (y + 399) / 400; + } else { + total -= y / -4 - y / -100 + y / -400; + } + total += ((367 * m - 362) / 12); + total += day - 1; + if (m > 2) { + total--; + if (!isLeapYear(year)) { + total--; + } + } + return total - DAYS_0000_TO_1970; + } + + static final long previousOrSame(long epochDay, int dayOfWeek) { + return adjust(epochDay, dayOfWeek, 1); + } + + static final long nextOrSame(long epochDay, int dayOfWeek) { + return adjust(epochDay, dayOfWeek, 0); + } + + static final long adjust(long epochDay, int dow, int relative) { + int calDow = (int)Math.floorMod(epochDay + 3, 7L) + 1; + if (relative < 2 && calDow == dow) { + return epochDay; + } + if ((relative & 1) == 0) { + int daysDiff = calDow - dow; + return epochDay + (daysDiff >= 0 ? 7 - daysDiff : -daysDiff); + } else { + int daysDiff = dow - calDow; + return epochDay - (daysDiff >= 0 ? 7 - daysDiff : -daysDiff); + } + } + } } diff --git a/jdk/src/share/classes/sun/util/locale/provider/CalendarDataUtility.java b/jdk/src/share/classes/sun/util/locale/provider/CalendarDataUtility.java index 656b6958bc6..09d77cee0c1 100644 --- a/jdk/src/share/classes/sun/util/locale/provider/CalendarDataUtility.java +++ b/jdk/src/share/classes/sun/util/locale/provider/CalendarDataUtility.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -69,7 +69,7 @@ public class CalendarDataUtility { field, value, style, false); } - public static String retrieveCldrFieldValueName(String id, int field, int value, int style, Locale locale) { + public static String retrieveJavaTimeFieldValueName(String id, int field, int value, int style, Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarNameProvider.class); String name; @@ -89,7 +89,7 @@ public class CalendarDataUtility { normalizeCalendarType(id), field, style, false); } - public static Map retrieveCldrFieldValueNames(String id, int field, int style, Locale locale) { + public static Map retrieveJavaTimeFieldValueNames(String id, int field, int style, Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarNameProvider.class); Map map; @@ -133,14 +133,14 @@ public class CalendarDataUtility { int field = (int) params[0]; int value = (int) params[1]; int style = (int) params[2]; - boolean cldr = (boolean) params[3]; + boolean javatime = (boolean) params[3]; - // If cldr is true, resources from CLDR have precedence over JRE + // If javatime is true, resources from CLDR have precedence over JRE // native resources. - if (cldr && calendarNameProvider instanceof CalendarNameProviderImpl) { + if (javatime && calendarNameProvider instanceof CalendarNameProviderImpl) { String name; name = ((CalendarNameProviderImpl)calendarNameProvider) - .getCldrDisplayName(requestID, field, value, style, locale); + .getJavaTimeDisplayName(requestID, field, value, style, locale); return name; } return calendarNameProvider.getDisplayName(requestID, field, value, style, locale); @@ -165,14 +165,14 @@ public class CalendarDataUtility { assert params.length == 3; int field = (int) params[0]; int style = (int) params[1]; - boolean cldr = (boolean) params[2]; + boolean javatime = (boolean) params[2]; - // If cldr is true, resources from CLDR have precedence over JRE + // If javatime is true, resources from CLDR have precedence over JRE // native resources. - if (cldr && calendarNameProvider instanceof CalendarNameProviderImpl) { + if (javatime && calendarNameProvider instanceof CalendarNameProviderImpl) { Map map; map = ((CalendarNameProviderImpl)calendarNameProvider) - .getCldrDisplayNames(requestID, field, style, locale); + .getJavaTimeDisplayNames(requestID, field, style, locale); return map; } return calendarNameProvider.getDisplayNames(requestID, field, style, locale); diff --git a/jdk/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java b/jdk/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java index afdfd072b8d..edbcc44454d 100644 --- a/jdk/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java +++ b/jdk/src/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java @@ -53,15 +53,16 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av return getDisplayNameImpl(calendarType, field, value, style, locale, false); } - public String getCldrDisplayName(String calendarType, int field, int value, int style, Locale locale) { + public String getJavaTimeDisplayName(String calendarType, int field, int value, int style, Locale locale) { return getDisplayNameImpl(calendarType, field, value, style, locale, true); } - public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean cldr) { + public String getDisplayNameImpl(String calendarType, int field, int value, int style, Locale locale, boolean javatime) { String name = null; - String key = getResourceKey(calendarType, field, style, cldr); + String key = getResourceKey(calendarType, field, style, javatime); if (key != null) { - String[] strings = LocaleProviderAdapter.forType(type).getLocaleResources(locale).getCalendarNames(key); + LocaleResources lr = LocaleProviderAdapter.forType(type).getLocaleResources(locale); + String[] strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); if (strings != null && strings.length > 0) { if (field == DAY_OF_WEEK || field == YEAR) { --value; @@ -104,18 +105,19 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av } // NOTE: This method should be used ONLY BY JSR 310 classes. - public Map getCldrDisplayNames(String calendarType, int field, int style, Locale locale) { + public Map getJavaTimeDisplayNames(String calendarType, int field, int style, Locale locale) { Map names; names = getDisplayNamesImpl(calendarType, field, style, locale, true); return names.isEmpty() ? null : names; } private Map getDisplayNamesImpl(String calendarType, int field, - int style, Locale locale, boolean cldr) { - String key = getResourceKey(calendarType, field, style, cldr); + int style, Locale locale, boolean javatime) { + String key = getResourceKey(calendarType, field, style, javatime); Map map = new TreeMap<>(LengthBasedComparator.INSTANCE); if (key != null) { - String[] strings = LocaleProviderAdapter.forType(type).getLocaleResources(locale).getCalendarNames(key); + LocaleResources lr = LocaleProviderAdapter.forType(type).getLocaleResources(locale); + String[] strings = javatime ? lr.getJavaTimeNames(key) : lr.getCalendarNames(key); if (strings != null) { if (!hasDuplicates(strings)) { if (field == YEAR) { @@ -220,7 +222,7 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av return false; } - private String getResourceKey(String type, int field, int style, boolean cldr) { + private String getResourceKey(String type, int field, int style, boolean javatime) { int baseStyle = getBaseStyle(style); boolean isStandalone = (style != baseStyle); @@ -229,9 +231,9 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av } boolean isNarrow = (baseStyle == NARROW_FORMAT); StringBuilder key = new StringBuilder(); - // If cldr is true, use prefix "cldr.". - if (cldr) { - key.append("cldr."); + // If javatime is true, use prefix "java.time.". + if (javatime) { + key.append("java.time."); } switch (field) { case ERA: @@ -245,7 +247,7 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av // due to historical reasons. (JRE DateFormatSymbols.getEras returns // abbreviations while other getShort*() return abbreviations.) if (this.type == LocaleProviderAdapter.Type.JRE) { - if (cldr) { + if (javatime) { if (baseStyle == LONG) { key.append("long."); } @@ -253,7 +255,7 @@ public class CalendarNameProviderImpl extends CalendarNameProvider implements Av if (baseStyle == SHORT) { key.append("short."); } - } else { // CLDR + } else { // this.type == LocaleProviderAdapter.Type.CLDR if (baseStyle == LONG) { key.append("long."); } diff --git a/jdk/src/share/classes/sun/util/locale/provider/LocaleResources.java b/jdk/src/share/classes/sun/util/locale/provider/LocaleResources.java index dafa74e2ab1..d41395f3767 100644 --- a/jdk/src/share/classes/sun/util/locale/provider/LocaleResources.java +++ b/jdk/src/share/classes/sun/util/locale/provider/LocaleResources.java @@ -54,6 +54,7 @@ import java.util.concurrent.ConcurrentMap; import sun.util.calendar.ZoneInfo; import sun.util.resources.LocaleData; import sun.util.resources.OpenListResourceBundle; +import sun.util.resources.ParallelListResourceBundle; import sun.util.resources.TimeZoneNamesBundle; /** @@ -331,6 +332,25 @@ public class LocaleResources { return names; } + String[] getJavaTimeNames(String key) { + String[] names = null; + String cacheKey = CALENDAR_NAMES + key; + + removeEmptyReferences(); + ResourceReference data = cache.get(cacheKey); + + if (data == null || ((names = (String[]) data.get()) == null)) { + ResourceBundle rb = getJavaTimeFormatData(); + if (rb.containsKey(key)) { + names = rb.getStringArray(key); + cache.put(cacheKey, + new ResourceReference(cacheKey, (Object) names, referenceQueue)); + } + } + + return names; + } + public String getDateTimePattern(int timeStyle, int dateStyle, Calendar cal) { if (cal == null) { cal = Calendar.getInstance(locale); @@ -347,10 +367,10 @@ public class LocaleResources { * @param calType the calendar type for the pattern * @return the pattern string */ - public String getCldrDateTimePattern(int timeStyle, int dateStyle, String calType) { + public String getJavaTimeDateTimePattern(int timeStyle, int dateStyle, String calType) { calType = CalendarDataUtility.normalizeCalendarType(calType); String pattern; - pattern = getDateTimePattern("cldr.", timeStyle, dateStyle, calType); + pattern = getDateTimePattern("java.time.", timeStyle, dateStyle, calType); if (pattern == null) { pattern = getDateTimePattern(null, timeStyle, dateStyle, calType); } @@ -430,8 +450,12 @@ public class LocaleResources { * The FormatData should be used only for accessing extra * resources required by JSR 310. */ - public ResourceBundle getFormatData() { - return localeData.getDateFormatData(locale); + public ResourceBundle getJavaTimeFormatData() { + ResourceBundle rb = localeData.getDateFormatData(locale); + if (rb instanceof ParallelListResourceBundle) { + localeData.setSupplementary((ParallelListResourceBundle) rb); + } + return rb; } private String getDateTimePattern(String prefix, String key, int styleIndex, String calendarType) { @@ -451,7 +475,7 @@ public class LocaleResources { Object value = NULLOBJECT; if (data == null || ((value = data.get()) == null)) { - ResourceBundle r = localeData.getDateFormatData(locale); + ResourceBundle r = (prefix != null) ? getJavaTimeFormatData() : localeData.getDateFormatData(locale); if (r.containsKey(resourceKey)) { value = r.getStringArray(resourceKey); } else { diff --git a/jdk/src/share/classes/sun/util/resources/LocaleData.java b/jdk/src/share/classes/sun/util/resources/LocaleData.java index fd9ab9e4ae5..00ba6dec959 100644 --- a/jdk/src/share/classes/sun/util/resources/LocaleData.java +++ b/jdk/src/share/classes/sun/util/resources/LocaleData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -42,9 +42,11 @@ package sun.util.resources; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Locale; +import java.util.MissingResourceException; import java.util.ResourceBundle; import sun.util.locale.provider.LocaleDataMetaInfo; import sun.util.locale.provider.LocaleProviderAdapter; @@ -122,6 +124,30 @@ public class LocaleData { return getBundle(type.getTextResourcesPackage() + ".FormatData", locale); } + public void setSupplementary(ParallelListResourceBundle formatData) { + if (!formatData.areParallelContentsComplete()) { + String suppName = type.getTextResourcesPackage() + ".JavaTimeSupplementary"; + setSupplementary(suppName, formatData); + } + } + + private boolean setSupplementary(String suppName, ParallelListResourceBundle formatData) { + ParallelListResourceBundle parent = (ParallelListResourceBundle) formatData.getParent(); + boolean resetKeySet = false; + if (parent != null) { + resetKeySet = setSupplementary(suppName, parent); + } + OpenListResourceBundle supp = getSupplementary(suppName, formatData.getLocale()); + formatData.setParallelContents(supp); + resetKeySet |= supp != null; + // If any parents or this bundle has parallel data, reset keyset to create + // a new keyset with the data. + if (resetKeySet) { + formatData.resetKeySet(); + } + return resetKeySet; + } + /** * Gets a number format data resource bundle, using privileges * to allow accessing a sun.* package. @@ -132,22 +158,37 @@ public class LocaleData { public static ResourceBundle getBundle(final String baseName, final Locale locale) { return AccessController.doPrivileged(new PrivilegedAction() { - @Override - public ResourceBundle run() { - return ResourceBundle. - getBundle(baseName, locale, - LocaleDataResourceBundleControl.getRBControlInstance()); - } - }); + @Override + public ResourceBundle run() { + return ResourceBundle + .getBundle(baseName, locale, LocaleDataResourceBundleControl.INSTANCE); + } + }); + } + + private static OpenListResourceBundle getSupplementary(final String baseName, final Locale locale) { + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public OpenListResourceBundle run() { + OpenListResourceBundle rb = null; + try { + rb = (OpenListResourceBundle) ResourceBundle.getBundle(baseName, + locale, SupplementaryResourceBundleControl.INSTANCE); + + } catch (MissingResourceException e) { + // return null if no supplementary is available + } + return rb; + } + }); } private static class LocaleDataResourceBundleControl extends ResourceBundle.Control { /* Singlton instance of ResourceBundle.Control. */ - private static LocaleDataResourceBundleControl rbControlInstance = + private static final LocaleDataResourceBundleControl INSTANCE = new LocaleDataResourceBundleControl(); - public static LocaleDataResourceBundleControl getRBControlInstance() { - return rbControlInstance; + private LocaleDataResourceBundleControl() { } /* @@ -243,6 +284,25 @@ public class LocaleData { } return super.toBundleName(newBaseName, locale); } + } + private static class SupplementaryResourceBundleControl extends LocaleDataResourceBundleControl { + private static final SupplementaryResourceBundleControl INSTANCE = + new SupplementaryResourceBundleControl(); + + private SupplementaryResourceBundleControl() { + } + + @Override + public List getCandidateLocales(String baseName, Locale locale) { + // Specifiy only the given locale + return Arrays.asList(locale); + } + + @Override + public long getTimeToLive(String baseName, Locale locale) { + assert baseName.contains("JavaTimeSupplementary"); + return TTL_DONT_CACHE; + } } } diff --git a/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java b/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java index 494e5c89c08..462b0a73411 100644 --- a/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java +++ b/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -68,7 +68,7 @@ public abstract class OpenListResourceBundle extends ResourceBundle { // Implements java.util.ResourceBundle.handleGetObject; inherits javadoc specification. @Override - public Object handleGetObject(String key) { + protected Object handleGetObject(String key) { if (key == null) { throw new NullPointerException(); } @@ -82,18 +82,18 @@ public abstract class OpenListResourceBundle extends ResourceBundle { */ @Override public Enumeration getKeys() { - ResourceBundle parent = this.parent; - return new ResourceBundleEnumeration(handleGetKeys(), - (parent != null) ? parent.getKeys() : null); - } + ResourceBundle parentBundle = this.parent; + return new ResourceBundleEnumeration(handleKeySet(), + (parentBundle != null) ? parentBundle.getKeys() : null); + } /** * Returns a set of keys provided in this resource bundle, * including no parents. */ - public Set handleGetKeys() { + @Override + protected Set handleKeySet() { loadLookupTablesIfNecessary(); - return lookup.keySet(); } @@ -103,7 +103,7 @@ public abstract class OpenListResourceBundle extends ResourceBundle { return keyset; } Set ks = createSet(); - ks.addAll(handleGetKeys()); + ks.addAll(handleKeySet()); if (parent != null) { ks.addAll(parent.keySet()); } diff --git a/jdk/src/share/classes/sun/util/resources/ParallelListResourceBundle.java b/jdk/src/share/classes/sun/util/resources/ParallelListResourceBundle.java new file mode 100644 index 00000000000..862143c9745 --- /dev/null +++ b/jdk/src/share/classes/sun/util/resources/ParallelListResourceBundle.java @@ -0,0 +1,259 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.util.resources; + +import java.util.AbstractSet; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.ResourceBundle; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicMarkableReference; + +/** + * ParallelListResourceBundle is another variant of ListResourceBundle + * supporting "parallel" contents provided by another resource bundle + * (OpenListResourceBundle). Parallel contents, if any, are added into this + * bundle on demand. + * + * @author Masayoshi Okutsu + */ +public abstract class ParallelListResourceBundle extends ResourceBundle { + private volatile ConcurrentMap lookup; + private volatile Set keyset; + private final AtomicMarkableReference parallelContents + = new AtomicMarkableReference<>(null, false); + + /** + * Sole constructor. (For invocation by subclass constructors, typically + * implicit.) + */ + protected ParallelListResourceBundle() { + } + + /** + * Returns an array in which each item is a pair of objects in an + * Object array. The first element of each pair is the key, which + * must be a String, and the second element is the value + * associated with that key. See the class description for + * details. + * + * @return an array of an Object array representing a key-value pair. + */ + protected abstract Object[][] getContents(); + + /** + * Returns the parent of this resource bundle or null if there's no parent. + * + * @return the parent or null if no parent + */ + ResourceBundle getParent() { + return parent; + } + + /** + * Sets the parallel contents to the data given by rb. If rb is null, this + * bundle will be marked as `complete'. + * + * @param rb an OpenResourceBundle for parallel contents, or null indicating + * there are no parallel contents for this bundle + */ + public void setParallelContents(OpenListResourceBundle rb) { + if (rb == null) { + parallelContents.compareAndSet(null, null, false, true); + } else { + parallelContents.compareAndSet(null, rb.getContents(), false, false); + } + } + + /** + * Returns true if any parallel contents have been set or if this bundle is + * marked as complete. + * + * @return true if any parallel contents have been processed + */ + boolean areParallelContentsComplete() { + // Quick check for `complete' + if (parallelContents.isMarked()) { + return true; + } + boolean[] done = new boolean[1]; + Object[][] data = parallelContents.get(done); + return data != null || done[0]; + } + + @Override + protected Object handleGetObject(String key) { + if (key == null) { + throw new NullPointerException(); + } + + loadLookupTablesIfNecessary(); + return lookup.get(key); + } + + @Override + public Enumeration getKeys() { + return Collections.enumeration(keySet()); + } + + @Override + public boolean containsKey(String key) { + return keySet().contains(key); + } + + @Override + protected Set handleKeySet() { + loadLookupTablesIfNecessary(); + return lookup.keySet(); + } + + @Override + @SuppressWarnings("UnusedAssignment") + public Set keySet() { + Set ks; + while ((ks = keyset) == null) { + ks = new KeySet(handleKeySet(), parent); + synchronized (this) { + if (keyset == null) { + keyset = ks; + } + } + } + return ks; + } + + /** + * Discards any cached keyset value. This method is called from + * LocaleData for re-creating a KeySet. + */ + synchronized void resetKeySet() { + keyset = null; + } + + /** + * Loads the lookup table if they haven't been loaded already. + */ + void loadLookupTablesIfNecessary() { + ConcurrentMap map = lookup; + if (map == null) { + map = new ConcurrentHashMap<>(); + for (Object[] item : getContents()) { + map.put((String) item[0], item[1]); + } + } + + // If there's any parallel contents data, merge the data into map. + Object[][] data = parallelContents.getReference(); + if (data != null) { + for (Object[] item : data) { + map.putIfAbsent((String) item[0], item[1]); + } + parallelContents.set(null, true); + } + if (lookup == null) { + synchronized (this) { + if (lookup == null) { + lookup = map; + } + } + } + } + + /** + * This class implements the Set interface for + * ParallelListResourceBundle methods. + */ + private static class KeySet extends AbstractSet { + private final Set set; + private final ResourceBundle parent; + + private KeySet(Set set, ResourceBundle parent) { + this.set = set; + this.parent = parent; + } + + @Override + public boolean contains(Object o) { + if (set.contains(o)) { + return true; + } + return (parent != null) ? parent.containsKey((String) o) : false; + } + + @Override + public Iterator iterator() { + if (parent == null) { + return set.iterator(); + } + return new Iterator() { + private Iterator itr = set.iterator(); + private boolean usingParent; + + @Override + public boolean hasNext() { + if (itr.hasNext()) { + return true; + } + if (!usingParent) { + Set nextset = new HashSet<>(parent.keySet()); + nextset.removeAll(set); + itr = nextset.iterator(); + usingParent = true; + } + return itr.hasNext(); + } + + @Override + public String next() { + if (hasNext()) { + return itr.next(); + } + throw new NoSuchElementException(); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + + @Override + public int size() { + if (parent == null) { + return set.size(); + } + Set allset = new HashSet<>(set); + allset.addAll(parent.keySet()); + return allset.size(); + } + } +} diff --git a/jdk/src/share/lib/calendars.properties b/jdk/src/share/lib/calendars.properties index 79ba4e14f11..ed8c2f627dc 100644 --- a/jdk/src/share/lib/calendars.properties +++ b/jdk/src/share/lib/calendars.properties @@ -52,3 +52,9 @@ calendar.thai-buddhist.eras: \ calendar.thai-buddhist.year-boundary: \ day1=4-1,since=-79302585600000; \ day1=1-1,since=-915148800000 + +# +# Hijrah calendars +# +calendar.hijrah.Hijrah-umalqura: hijrah-config-umalqura.properties +calendar.hijrah.Hijrah-umalqura.type: islamic-umalqura diff --git a/jdk/src/share/lib/hijrah-config-umalqura.properties b/jdk/src/share/lib/hijrah-config-umalqura.properties new file mode 100644 index 00000000000..ac16c7e222f --- /dev/null +++ b/jdk/src/share/lib/hijrah-config-umalqura.properties @@ -0,0 +1,58 @@ +# +# hijrah-config-umalqura.properties +# +# +# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# +# This properties file defines a Hijrah calendar variant. +# +# Fields: +# +# ::= 'version' '=' +# ::= 'id' '=' +# ::= 'type' '=' +# ::= 'iso-start' '=' +# ::= '=' +# +# version ... (Required) +# +# id ... (Required) +# Identifies the Java Chronology +# +# type ... (Required) +# Identifies the type of calendar in the standard calendar ID scheme +# iso-start ... (Required) +# Specifies the corresponding ISO date to the first Hijrah day +# in the defined range of dates +# +# year ... (Required) +# Number of days for each month of a Hijrah year +# * Each line defines a year. The years must be in the chronological +# order and no gap is allowed. +# * Each line is in the form indicated above. is a Hijrah year and +# nn is the number of days for a month listed in the order of the months. +# * Each year must have 12 months. +# * Each month should be 29 or 30 days long. +# * There must be one or more space characters between the months. +# + +# indicates the version of this definition +version=1.8.0_1 + +# Java chronology ID +id=Hijrah-umalqura + +# Standard calendar type specification +type=islamic-umalqura + +# defines the corresponding ISO date to the earliest Hijrah date +iso-start=2010-12-07 + +# +# the data section; defines the dates with the number of days for each month +# +# Placeholder data until full Umm alQura data can be validated +1432=29 30 30 30 29 30 29 30 29 30 29 29 +1433=30 29 30 30 29 30 30 29 30 29 30 29 +1434=29 30 29 30 29 30 30 29 30 30 29 29 +1435=30 29 30 29 30 29 30 29 30 30 29 30 diff --git a/jdk/test/java/time/tck/java/time/AbstractDateTimeTest.java b/jdk/test/java/time/tck/java/time/AbstractDateTimeTest.java index d44d2410f28..e7c6db6ef9d 100644 --- a/jdk/test/java/time/tck/java/time/AbstractDateTimeTest.java +++ b/jdk/test/java/time/tck/java/time/AbstractDateTimeTest.java @@ -59,19 +59,16 @@ */ package tck.java.time; -import java.time.*; - import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; +import java.time.DateTimeException; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import java.util.List; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalQuery; -import java.time.temporal.TemporalField; - import org.testng.annotations.Test; -import test.java.time.AbstractTest; import test.java.time.temporal.MockFieldNoValue; /** @@ -100,7 +97,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { //----------------------------------------------------------------------- // isSupported(TemporalField) //----------------------------------------------------------------------- - @Test(groups = "tck") + @Test() public void basicTest_isSupported_TemporalField_supported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : validFields()) { @@ -109,7 +106,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { } } - @Test(groups = "tck") + @Test() public void basicTest_isSupported_TemporalField_unsupported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : invalidFields()) { @@ -118,7 +115,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { } } - @Test(groups = "tck") + @Test() public void basicTest_isSupported_TemporalField_null() { for (TemporalAccessor sample : samples()) { assertEquals(sample.isSupported(null), false, "Failed on " + sample); @@ -128,7 +125,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { //----------------------------------------------------------------------- // range(TemporalField) //----------------------------------------------------------------------- - @Test(groups = "tck") + @Test() public void basicTest_range_TemporalField_supported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : validFields()) { @@ -137,7 +134,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { } } - @Test(groups = "tck") + @Test() public void basicTest_range_TemporalField_unsupported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : invalidFields()) { @@ -151,7 +148,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { } } - @Test(groups = "tck") + @Test() public void basicTest_range_TemporalField_null() { for (TemporalAccessor sample : samples()) { try { @@ -166,7 +163,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { //----------------------------------------------------------------------- // get(TemporalField) //----------------------------------------------------------------------- - @Test(groups = "tck") + @Test() public void basicTest_get_TemporalField_supported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : validFields()) { @@ -184,7 +181,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { } } - @Test(groups = "tck") + @Test() public void basicTest_get_TemporalField_unsupported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : invalidFields()) { @@ -205,7 +202,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { } } - @Test(groups = "tck") + @Test() public void basicTest_get_TemporalField_null() { for (TemporalAccessor sample : samples()) { try { @@ -220,7 +217,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { //----------------------------------------------------------------------- // getLong(TemporalField) //----------------------------------------------------------------------- - @Test(groups = "tck") + @Test() public void basicTest_getLong_TemporalField_supported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : validFields()) { @@ -229,7 +226,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { } } - @Test(groups = "tck") + @Test() public void basicTest_getLong_TemporalField_unsupported() { for (TemporalAccessor sample : samples()) { for (TemporalField field : invalidFields()) { @@ -250,7 +247,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { } } - @Test(groups = "tck") + @Test() public void basicTest_getLong_TemporalField_null() { for (TemporalAccessor sample : samples()) { try { @@ -263,7 +260,7 @@ public abstract class AbstractDateTimeTest extends AbstractTCKTest { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void basicTest_query() { for (TemporalAccessor sample : samples()) { assertEquals(sample.query(new TemporalQuery() { diff --git a/jdk/test/java/time/tck/java/time/TCKClock.java b/jdk/test/java/time/tck/java/time/TCKClock.java index 82e47f7f681..843992e0d79 100644 --- a/jdk/test/java/time/tck/java/time/TCKClock.java +++ b/jdk/test/java/time/tck/java/time/TCKClock.java @@ -59,10 +59,12 @@ */ package tck.java.time; -import java.time.*; - import static org.testng.Assert.assertEquals; +import java.time.Clock; +import java.time.Instant; +import java.time.ZoneId; + import org.testng.annotations.Test; /** diff --git a/jdk/test/java/time/tck/java/time/TCKDayOfWeek.java b/jdk/test/java/time/tck/java/time/TCKDayOfWeek.java index 196c0402a99..671d9ec53e9 100644 --- a/jdk/test/java/time/tck/java/time/TCKDayOfWeek.java +++ b/jdk/test/java/time/tck/java/time/TCKDayOfWeek.java @@ -70,12 +70,10 @@ import java.time.DateTimeException; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.LocalTime; -import java.time.chrono.IsoChronology; import java.time.format.TextStyle; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; @@ -125,7 +123,7 @@ public class TCKDayOfWeek extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_singleton() { for (int i = 1; i <= 7; i++) { DayOfWeek test = DayOfWeek.of(i); @@ -134,28 +132,28 @@ public class TCKDayOfWeek extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_valueTooLow() { DayOfWeek.of(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_valueTooHigh() { DayOfWeek.of(8); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(DayOfWeek.from(LocalDate.of(2011, 6, 6)), DayOfWeek.MONDAY); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { DayOfWeek.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { DayOfWeek.from((TemporalAccessor) null); } @@ -179,13 +177,13 @@ public class TCKDayOfWeek extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {DayOfWeek.FRIDAY, Queries.chronology(), null}, - {DayOfWeek.FRIDAY, Queries.zoneId(), null}, - {DayOfWeek.FRIDAY, Queries.precision(), ChronoUnit.DAYS}, - {DayOfWeek.FRIDAY, Queries.zone(), null}, - {DayOfWeek.FRIDAY, Queries.offset(), null}, - {DayOfWeek.FRIDAY, Queries.localDate(), null}, - {DayOfWeek.FRIDAY, Queries.localTime(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.chronology(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.zoneId(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.precision(), ChronoUnit.DAYS}, + {DayOfWeek.FRIDAY, TemporalQuery.zone(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.offset(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.localDate(), null}, + {DayOfWeek.FRIDAY, TemporalQuery.localTime(), null}, }; } @@ -207,17 +205,17 @@ public class TCKDayOfWeek extends AbstractDateTimeTest { //----------------------------------------------------------------------- // getText() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getText() { assertEquals(DayOfWeek.MONDAY.getDisplayName(TextStyle.SHORT, Locale.US), "Mon"); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void test_getText_nullStyle() { DayOfWeek.MONDAY.getDisplayName(null, Locale.US); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void test_getText_nullLocale() { DayOfWeek.MONDAY.getDisplayName(TextStyle.FULL, null); } @@ -264,7 +262,7 @@ public class TCKDayOfWeek extends AbstractDateTimeTest { }; } - @Test(dataProvider="plus", groups={"tck"}) + @Test(dataProvider="plus") public void test_plus_long(int base, long amount, int expected) { assertEquals(DayOfWeek.of(base).plus(amount), DayOfWeek.of(expected)); } @@ -295,7 +293,7 @@ public class TCKDayOfWeek extends AbstractDateTimeTest { }; } - @Test(dataProvider="minus", groups={"tck"}) + @Test(dataProvider="minus") public void test_minus_long(int base, long amount, int expected) { assertEquals(DayOfWeek.of(base).minus(amount), DayOfWeek.of(expected)); } @@ -303,7 +301,7 @@ public class TCKDayOfWeek extends AbstractDateTimeTest { //----------------------------------------------------------------------- // adjustInto() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjustInto() { assertEquals(DayOfWeek.MONDAY.adjustInto(LocalDate.of(2012, 9, 2)), LocalDate.of(2012, 8, 27)); assertEquals(DayOfWeek.MONDAY.adjustInto(LocalDate.of(2012, 9, 3)), LocalDate.of(2012, 9, 3)); @@ -312,7 +310,7 @@ public class TCKDayOfWeek extends AbstractDateTimeTest { assertEquals(DayOfWeek.MONDAY.adjustInto(LocalDate.of(2012, 9, 11)), LocalDate.of(2012, 9, 10)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_adjustInto_null() { DayOfWeek.MONDAY.adjustInto((Temporal) null); } @@ -320,7 +318,7 @@ public class TCKDayOfWeek extends AbstractDateTimeTest { //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString() { assertEquals(DayOfWeek.MONDAY.toString(), "MONDAY"); assertEquals(DayOfWeek.TUESDAY.toString(), "TUESDAY"); @@ -334,7 +332,7 @@ public class TCKDayOfWeek extends AbstractDateTimeTest { //----------------------------------------------------------------------- // generated methods //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_enum() { assertEquals(DayOfWeek.valueOf("MONDAY"), DayOfWeek.MONDAY); assertEquals(DayOfWeek.values()[0], DayOfWeek.MONDAY); diff --git a/jdk/test/java/time/tck/java/time/TCKDuration.java b/jdk/test/java/time/tck/java/time/TCKDuration.java index 797b54b1f31..bae2cf69805 100644 --- a/jdk/test/java/time/tck/java/time/TCKDuration.java +++ b/jdk/test/java/time/tck/java/time/TCKDuration.java @@ -72,20 +72,23 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.time.DateTimeException; import java.time.Duration; import java.time.Instant; +import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.Period; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalUnit; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Locale; @@ -98,6 +101,8 @@ import org.testng.annotations.Test; @Test public class TCKDuration extends AbstractTCKTest { + private static final long CYCLE_SECS = 146097L * 86400L; + //----------------------------------------------------------------------- @Test public void test_serialization() throws Exception { @@ -121,7 +126,7 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // constants //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_zero() { assertEquals(Duration.ZERO.getSeconds(), 0L); assertEquals(Duration.ZERO.getNano(), 0); @@ -130,7 +135,7 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // ofSeconds(long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_seconds_long() { for (long i = -2; i <= 2; i++) { Duration t = Duration.ofSeconds(i); @@ -142,7 +147,7 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // ofSeconds(long,long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_seconds_long_long() { for (long i = -2; i <= 2; i++) { for (int j = 0; j < 10; j++) { @@ -163,14 +168,14 @@ public class TCKDuration extends AbstractTCKTest { } } - @Test(groups={"tck"}) + @Test public void factory_seconds_long_long_nanosNegativeAdjusted() { Duration test = Duration.ofSeconds(2L, -1); assertEquals(test.getSeconds(), 1); assertEquals(test.getNano(), 999999999); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_seconds_long_long_tooBig() { Duration.ofSeconds(Long.MAX_VALUE, 1000000000); } @@ -195,7 +200,7 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="MillisDurationNoNanos", groups={"tck"}) + @Test(dataProvider="MillisDurationNoNanos") public void factory_millis_long(long millis, long expectedSeconds, int expectedNanoOfSecond) { Duration test = Duration.ofMillis(millis); assertEquals(test.getSeconds(), expectedSeconds); @@ -205,35 +210,35 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // ofNanos(long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_nanos_nanos() { Duration test = Duration.ofNanos(1); assertEquals(test.getSeconds(), 0); assertEquals(test.getNano(), 1); } - @Test(groups={"tck"}) + @Test public void factory_nanos_nanosSecs() { Duration test = Duration.ofNanos(1000000002); assertEquals(test.getSeconds(), 1); assertEquals(test.getNano(), 2); } - @Test(groups={"tck"}) + @Test public void factory_nanos_negative() { Duration test = Duration.ofNanos(-2000000001); assertEquals(test.getSeconds(), -3); assertEquals(test.getNano(), 999999999); } - @Test(groups={"tck"}) + @Test public void factory_nanos_max() { Duration test = Duration.ofNanos(Long.MAX_VALUE); assertEquals(test.getSeconds(), Long.MAX_VALUE / 1000000000); assertEquals(test.getNano(), Long.MAX_VALUE % 1000000000); } - @Test(groups={"tck"}) + @Test public void factory_nanos_min() { Duration test = Duration.ofNanos(Long.MIN_VALUE); assertEquals(test.getSeconds(), Long.MIN_VALUE / 1000000000 - 1); @@ -243,33 +248,33 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // ofMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_minutes() { Duration test = Duration.ofMinutes(2); assertEquals(test.getSeconds(), 120); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_minutes_max() { Duration test = Duration.ofMinutes(Long.MAX_VALUE / 60); assertEquals(test.getSeconds(), (Long.MAX_VALUE / 60) * 60); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_minutes_min() { Duration test = Duration.ofMinutes(Long.MIN_VALUE / 60); assertEquals(test.getSeconds(), (Long.MIN_VALUE / 60) * 60); assertEquals(test.getNano(), 0); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_minutes_tooBig() { Duration.ofMinutes(Long.MAX_VALUE / 60 + 1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_minutes_tooSmall() { Duration.ofMinutes(Long.MIN_VALUE / 60 - 1); } @@ -277,33 +282,33 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // ofHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_hours() { Duration test = Duration.ofHours(2); assertEquals(test.getSeconds(), 2 * 3600); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_hours_max() { Duration test = Duration.ofHours(Long.MAX_VALUE / 3600); assertEquals(test.getSeconds(), (Long.MAX_VALUE / 3600) * 3600); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_hours_min() { Duration test = Duration.ofHours(Long.MIN_VALUE / 3600); assertEquals(test.getSeconds(), (Long.MIN_VALUE / 3600) * 3600); assertEquals(test.getNano(), 0); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_hours_tooBig() { Duration.ofHours(Long.MAX_VALUE / 3600 + 1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_hours_tooSmall() { Duration.ofHours(Long.MIN_VALUE / 3600 - 1); } @@ -311,33 +316,33 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // ofDays() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_days() { Duration test = Duration.ofDays(2); assertEquals(test.getSeconds(), 2 * 86400); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_days_max() { Duration test = Duration.ofDays(Long.MAX_VALUE / 86400); assertEquals(test.getSeconds(), (Long.MAX_VALUE / 86400) * 86400); assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_days_min() { Duration test = Duration.ofDays(Long.MIN_VALUE / 86400); assertEquals(test.getSeconds(), (Long.MIN_VALUE / 86400) * 86400); assertEquals(test.getNano(), 0); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_days_tooBig() { Duration.ofDays(Long.MAX_VALUE / 86400 + 1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void factory_days_tooSmall() { Duration.ofDays(Long.MIN_VALUE / 86400 - 1); } @@ -405,7 +410,7 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="OfTemporalUnit", groups={"tck"}) + @Test(dataProvider="OfTemporalUnit") public void factory_of_longTemporalUnit(long amount, TemporalUnit unit, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.of(amount, unit); assertEquals(t.getSeconds(), expectedSeconds); @@ -424,76 +429,93 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="OfTemporalUnitOutOfRange", expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(dataProvider="OfTemporalUnitOutOfRange", expectedExceptions=ArithmeticException.class) public void factory_of_longTemporalUnit_outOfRange(long amount, TemporalUnit unit) { Duration.of(amount, unit); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_longTemporalUnit_estimatedUnit() { Duration.of(2, WEEKS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_longTemporalUnit_null() { Duration.of(1, (TemporalUnit) null); } //----------------------------------------------------------------------- - // between() + // from(TemporalAmount) //----------------------------------------------------------------------- - @DataProvider(name="durationBetweenInstant") - Object[][] data_durationBetweenInstant() { - return new Object[][] { - {0, 0, 0, 0, 0, 0}, - {3, 0, 7, 0, 4, 0}, - {3, 20, 7, 50, 4, 30}, - {3, 80, 7, 50, 3, 999999970}, - {7, 0, 3, 0, -4, 0}, + @Test + public void factory_from_TemporalAmount_Duration() { + TemporalAmount amount = Duration.ofHours(3); + assertEquals(Duration.from(amount), Duration.ofHours(3)); + } + + @Test + public void factory_from_TemporalAmount_DaysNanos() { + TemporalAmount amount = new TemporalAmount() { + @Override + public long get(TemporalUnit unit) { + if (unit == DAYS) { + return 23; + } else { + return 45; + } + } + @Override + public List getUnits() { + List list = new ArrayList<>(); + list.add(DAYS); + list.add(NANOS); + return list; + } + @Override + public Temporal addTo(Temporal temporal) { + throw new UnsupportedOperationException(); + } + @Override + public Temporal subtractFrom(Temporal temporal) { + throw new UnsupportedOperationException(); + } }; + Duration t = Duration.from(amount); + assertEquals(t.getSeconds(), 23 * 86400); + assertEquals(t.getNano(), 45); } - @Test(dataProvider="durationBetweenInstant") - public void factory_between_TemporalTemporal_Instant(long secs1, int nanos1, long secs2, int nanos2, long expectedSeconds, int expectedNanoOfSecond) { - Instant start = Instant.ofEpochSecond(secs1, nanos1); - Instant end = Instant.ofEpochSecond(secs2, nanos2); - Duration t = Duration.between(start, end); - assertEquals(t.getSeconds(), expectedSeconds); - assertEquals(t.getNano(), expectedNanoOfSecond); - } - - @DataProvider(name="durationBetweenLocalTime") - Object[][] data_durationBetweenLocalTime() { - return new Object[][] { - {LocalTime.of(11, 0, 30), LocalTime.of(11, 0, 45), 15L, 0}, - {LocalTime.of(11, 0, 30), LocalTime.of(11, 0, 25), -5L, 0}, + @Test(expectedExceptions = ArithmeticException.class) + public void factory_from_TemporalAmount_Minutes_tooBig() { + TemporalAmount amount = new TemporalAmount() { + @Override + public long get(TemporalUnit unit) { + return (Long.MAX_VALUE / 60) + 2; + } + @Override + public List getUnits() { + return Collections.singletonList(MINUTES); + } + @Override + public Temporal addTo(Temporal temporal) { + throw new UnsupportedOperationException(); + } + @Override + public Temporal subtractFrom(Temporal temporal) { + throw new UnsupportedOperationException(); + } }; + Duration.from(amount); } - @Test(dataProvider="durationBetweenLocalTime") - public void factory_between_TemporalTemporal_LT(LocalTime start, LocalTime end, long expectedSeconds, int expectedNanoOfSecond) { - Duration t = Duration.between(start, end); - assertEquals(t.getSeconds(), expectedSeconds); - assertEquals(t.getNano(), expectedNanoOfSecond); + @Test(expectedExceptions = DateTimeException.class) + public void factory_from_TemporalAmount_Period() { + Duration.from(Period.ZERO); } - @Test(expectedExceptions=DateTimeException.class) - public void factory_between_TemporalTemporal_mixedTypes() { - Instant start = Instant.ofEpochSecond(1); - ZonedDateTime end = Instant.ofEpochSecond(4).atZone(ZoneOffset.UTC); - Duration.between(start, end); - } - - @Test(expectedExceptions=NullPointerException.class) - public void factory_between__TemporalTemporal_startNull() { - Instant end = Instant.ofEpochSecond(1); - Duration.between(null, end); - } - - @Test(expectedExceptions=NullPointerException.class) - public void factory_between__TemporalTemporal_endNull() { - Instant start = Instant.ofEpochSecond(1); - Duration.between(start, null); + @Test(expectedExceptions = NullPointerException.class) + public void factory_from_TemporalAmount_null() { + Duration.from(null); } //----------------------------------------------------------------------- @@ -749,17 +771,115 @@ public class TCKDuration extends AbstractTCKTest { } //----------------------------------------------------------------------- - @Test - public void test_deserialization() throws Exception { - Duration orginal = Duration.ofSeconds(2); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); - out.writeObject(orginal); - out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream in = new ObjectInputStream(bais); - Duration ser = (Duration) in.readObject(); - assertEquals(Duration.ofSeconds(2), ser); + // between() + //----------------------------------------------------------------------- + @DataProvider(name="durationBetweenInstant") + Object[][] data_durationBetweenInstant() { + return new Object[][] { + {0, 0, 0, 0, 0, 0}, + {3, 0, 7, 0, 4, 0}, + {7, 0, 3, 0, -4, 0}, + + {3, 20, 7, 50, 4, 30}, + {3, 80, 7, 50, 3, 999999970}, + {3, 80, 7, 79, 3, 999999999}, + {3, 80, 7, 80, 4, 0}, + {3, 80, 7, 81, 4, 1}, + }; + } + + @Test(dataProvider="durationBetweenInstant") + public void factory_between_TemporalTemporal_Instant(long secs1, int nanos1, long secs2, int nanos2, long expectedSeconds, int expectedNanoOfSecond) { + Instant start = Instant.ofEpochSecond(secs1, nanos1); + Instant end = Instant.ofEpochSecond(secs2, nanos2); + Duration t = Duration.between(start, end); + assertEquals(t.getSeconds(), expectedSeconds); + assertEquals(t.getNano(), expectedNanoOfSecond); + } + + @Test(dataProvider="durationBetweenInstant") + public void factory_between_TemporalTemporal_Instant_negated(long secs1, int nanos1, long secs2, int nanos2, long expectedSeconds, int expectedNanoOfSecond) { + Instant start = Instant.ofEpochSecond(secs1, nanos1); + Instant end = Instant.ofEpochSecond(secs2, nanos2); + assertEquals(Duration.between(end, start), Duration.between(start, end).negated()); + } + + @DataProvider(name="durationBetweenLocalTime") + Object[][] data_durationBetweenLocalTime() { + return new Object[][] { + {LocalTime.of(11, 0, 30), LocalTime.of(11, 0, 45), 15L, 0}, + {LocalTime.of(11, 0, 30), LocalTime.of(11, 0, 25), -5L, 0}, + }; + } + + @Test(dataProvider="durationBetweenLocalTime") + public void factory_between_TemporalTemporal_LT(LocalTime start, LocalTime end, long expectedSeconds, int expectedNanoOfSecond) { + Duration t = Duration.between(start, end); + assertEquals(t.getSeconds(), expectedSeconds); + assertEquals(t.getNano(), expectedNanoOfSecond); + } + + @Test(dataProvider="durationBetweenLocalTime") + public void factory_between_TemporalTemporal_LT_negated(LocalTime start, LocalTime end, long expectedSeconds, int expectedNanoOfSecond) { + assertEquals(Duration.between(end, start), Duration.between(start, end).negated()); + } + + @DataProvider(name="durationBetweenLocalDateTime") + Object[][] data_durationBetweenLocalDateTime() { + return new Object[][] { + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 30, 65_000_000), -2L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), -1L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 32, 65_000_000), 0L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 33, 65_000_000), 1L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 34, 65_000_000), 2L, 500_000_000}, + + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 30, 565_000_000), -1L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 31, 565_000_000), 0L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 32, 565_000_000), 1L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 33, 565_000_000), 2L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 34, 565_000_000), 3L, 500_000_000}, + + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 30, 65_000_000), -1L, 0}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), 0L, 0}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 32, 65_000_000), 1L, 0}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 33, 65_000_000), 2L, 0}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2013, 3, 24, 0, 44, 34, 65_000_000), 3L, 0}, + + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2813, 3, 24, 0, 44, 30, 565_000_000), 2 * CYCLE_SECS - 1L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2813, 3, 24, 0, 44, 31, 565_000_000), 2 * CYCLE_SECS + 0L, 500_000_000}, + {LocalDateTime.of(2013, 3, 24, 0, 44, 31, 65_000_000), LocalDateTime.of(2813, 3, 24, 0, 44, 32, 565_000_000), 2 * CYCLE_SECS + 1L, 500_000_000}, + }; + } + + @Test(dataProvider="durationBetweenLocalDateTime") + public void factory_between_TemporalTemporal_LDT(LocalDateTime start, LocalDateTime end, long expectedSeconds, int expectedNanoOfSecond) { + Duration t = Duration.between(start, end); + assertEquals(t.getSeconds(), expectedSeconds); + assertEquals(t.getNano(), expectedNanoOfSecond); + } + + @Test(dataProvider="durationBetweenLocalDateTime") + public void factory_between_TemporalTemporal_LDT_negated(LocalDateTime start, LocalDateTime end, long expectedSeconds, int expectedNanoOfSecond) { + assertEquals(Duration.between(end, start), Duration.between(start, end).negated()); + } + + @Test(expectedExceptions=DateTimeException.class) + public void factory_between_TemporalTemporal_mixedTypes() { + Instant start = Instant.ofEpochSecond(1); + ZonedDateTime end = Instant.ofEpochSecond(4).atZone(ZoneOffset.UTC); + Duration.between(start, end); + } + + @Test(expectedExceptions=NullPointerException.class) + public void factory_between__TemporalTemporal_startNull() { + Instant end = Instant.ofEpochSecond(1); + Duration.between(null, end); + } + + @Test(expectedExceptions=NullPointerException.class) + public void factory_between__TemporalTemporal_endNull() { + Instant start = Instant.ofEpochSecond(1); + Duration.between(start, null); } //----------------------------------------------------------------------- @@ -977,27 +1097,27 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="Plus", groups={"tck"}) + @Test(dataProvider="Plus") public void plus(long seconds, int nanos, long otherSeconds, int otherNanos, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos).plus(Duration.ofSeconds(otherSeconds, otherNanos)); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void plusOverflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999); t.plus(Duration.ofSeconds(0, 1)); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void plusOverflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE); t.plus(Duration.ofSeconds(-1, 999999999)); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void plus_longTemporalUnit_seconds() { Duration t = Duration.ofSeconds(1); t = t.plus(1, SECONDS); @@ -1005,7 +1125,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(0, t.getNano()); } - @Test(groups={"tck"}) + @Test public void plus_longTemporalUnit_millis() { Duration t = Duration.ofSeconds(1); t = t.plus(1, MILLIS); @@ -1013,7 +1133,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(1000000, t.getNano()); } - @Test(groups={"tck"}) + @Test public void plus_longTemporalUnit_micros() { Duration t = Duration.ofSeconds(1); t = t.plus(1, MICROS); @@ -1021,7 +1141,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(1000, t.getNano()); } - @Test(groups={"tck"}) + @Test public void plus_longTemporalUnit_nanos() { Duration t = Duration.ofSeconds(1); t = t.plus(1, NANOS); @@ -1029,12 +1149,138 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(1, t.getNano()); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void plus_longTemporalUnit_null() { Duration t = Duration.ofSeconds(1); t.plus(1, (TemporalUnit) null); } + //----------------------------------------------------------------------- + @DataProvider(name="PlusDays") + Object[][] provider_plusDays_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, 1}, + {0, -1, -1}, + {Long.MAX_VALUE/3600/24, 0, Long.MAX_VALUE/3600/24}, + {Long.MIN_VALUE/3600/24, 0, Long.MIN_VALUE/3600/24}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {1, Long.MIN_VALUE/3600/24, Long.MIN_VALUE/3600/24 + 1}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {-1, 0, -1}, + {-1, 1, 0}, + {-1, -1, -2}, + {-1, Long.MAX_VALUE/3600/24, Long.MAX_VALUE/3600/24 - 1}, + }; + } + + @Test(dataProvider="PlusDays") + public void plusDays_long(long days, long amount, long expectedDays) { + Duration t = Duration.ofDays(days); + t = t.plusDays(amount); + assertEquals(t.toDays(), expectedDays); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusDays_long_overflowTooBig() { + Duration t = Duration.ofDays(1); + t.plusDays(Long.MAX_VALUE/3600/24); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusDays_long_overflowTooSmall() { + Duration t = Duration.ofDays(-1); + t.plusDays(Long.MIN_VALUE/3600/24); + } + + //----------------------------------------------------------------------- + @DataProvider(name="PlusHours") + Object[][] provider_plusHours_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, 1}, + {0, -1, -1}, + {Long.MAX_VALUE/3600, 0, Long.MAX_VALUE/3600}, + {Long.MIN_VALUE/3600, 0, Long.MIN_VALUE/3600}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {1, Long.MIN_VALUE/3600, Long.MIN_VALUE/3600 + 1}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {-1, 0, -1}, + {-1, 1, 0}, + {-1, -1, -2}, + {-1, Long.MAX_VALUE/3600, Long.MAX_VALUE/3600 - 1}, + }; + } + + @Test(dataProvider="PlusHours") + public void plusHours_long(long hours, long amount, long expectedHours) { + Duration t = Duration.ofHours(hours); + t = t.plusHours(amount); + assertEquals(t.toHours(), expectedHours); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusHours_long_overflowTooBig() { + Duration t = Duration.ofHours(1); + t.plusHours(Long.MAX_VALUE/3600); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusHours_long_overflowTooSmall() { + Duration t = Duration.ofHours(-1); + t.plusHours(Long.MIN_VALUE/3600); + } + + //----------------------------------------------------------------------- + @DataProvider(name="PlusMinutes") + Object[][] provider_plusMinutes_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, 1}, + {0, -1, -1}, + {Long.MAX_VALUE/60, 0, Long.MAX_VALUE/60}, + {Long.MIN_VALUE/60, 0, Long.MIN_VALUE/60}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {1, Long.MIN_VALUE/60, Long.MIN_VALUE/60 + 1}, + {1, 0, 1}, + {1, 1, 2}, + {1, -1, 0}, + {-1, 0, -1}, + {-1, 1, 0}, + {-1, -1, -2}, + {-1, Long.MAX_VALUE/60, Long.MAX_VALUE/60 - 1}, + }; + } + + @Test(dataProvider="PlusMinutes") + public void plusMinutes_long(long minutes, long amount, long expectedMinutes) { + Duration t = Duration.ofMinutes(minutes); + t = t.plusMinutes(amount); + assertEquals(t.toMinutes(), expectedMinutes); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusMinutes_long_overflowTooBig() { + Duration t = Duration.ofMinutes(1); + t.plusMinutes(Long.MAX_VALUE/60); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void plusMinutes_long_overflowTooSmall() { + Duration t = Duration.ofMinutes(-1); + t.plusMinutes(Long.MIN_VALUE/60); + } + //----------------------------------------------------------------------- @DataProvider(name="PlusSeconds") Object[][] provider_plusSeconds_long() { @@ -1062,7 +1308,7 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="PlusSeconds", groups={"tck"}) + @Test(dataProvider="PlusSeconds") public void plusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.plusSeconds(amount); @@ -1070,13 +1316,13 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusSeconds_long_overflowTooBig() { Duration t = Duration.ofSeconds(1, 0); t.plusSeconds(Long.MAX_VALUE); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusSeconds_long_overflowTooSmall() { Duration t = Duration.ofSeconds(-1, 0); t.plusSeconds(Long.MIN_VALUE); @@ -1138,21 +1384,21 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="PlusMillis", groups={"tck"}) + @Test(dataProvider="PlusMillis") public void plusMillis_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.plusMillis(amount); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(dataProvider="PlusMillis", groups={"tck"}) + @Test(dataProvider="PlusMillis") public void plusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds + 1, nanos); t = t.plusMillis(amount); assertEquals(t.getSeconds(), expectedSeconds + 1); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(dataProvider="PlusMillis", groups={"tck"}) + @Test(dataProvider="PlusMillis") public void plusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds - 1, nanos); t = t.plusMillis(amount); @@ -1160,7 +1406,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(groups={"tck"}) + @Test public void plusMillis_long_max() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 998999999); t = t.plusMillis(1); @@ -1168,13 +1414,13 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), 999999999); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusMillis_long_overflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999000000); t.plusMillis(1); } - @Test(groups={"tck"}) + @Test public void plusMillis_long_min() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 1000000); t = t.plusMillis(-1); @@ -1182,7 +1428,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), 0); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusMillis_long_overflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0); t.plusMillis(-1); @@ -1264,7 +1510,7 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="PlusNanos", groups={"tck"}) + @Test(dataProvider="PlusNanos") public void plusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.plusNanos(amount); @@ -1272,13 +1518,13 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusNanos_long_overflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999); t.plusNanos(1); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void plusNanos_long_overflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0); t.plusNanos(-1); @@ -1470,27 +1716,27 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="Minus", groups={"tck"}) + @Test(dataProvider="Minus") public void minus(long seconds, int nanos, long otherSeconds, int otherNanos, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos).minus(Duration.ofSeconds(otherSeconds, otherNanos)); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void minusOverflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE); t.minus(Duration.ofSeconds(0, 1)); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void minusOverflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999); t.minus(Duration.ofSeconds(-1, 999999999)); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void minus_longTemporalUnit_seconds() { Duration t = Duration.ofSeconds(1); t = t.minus(1, SECONDS); @@ -1498,7 +1744,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(0, t.getNano()); } - @Test(groups={"tck"}) + @Test public void minus_longTemporalUnit_millis() { Duration t = Duration.ofSeconds(1); t = t.minus(1, MILLIS); @@ -1506,7 +1752,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(999000000, t.getNano()); } - @Test(groups={"tck"}) + @Test public void minus_longTemporalUnit_micros() { Duration t = Duration.ofSeconds(1); t = t.minus(1, MICROS); @@ -1514,7 +1760,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(999999000, t.getNano()); } - @Test(groups={"tck"}) + @Test public void minus_longTemporalUnit_nanos() { Duration t = Duration.ofSeconds(1); t = t.minus(1, NANOS); @@ -1522,12 +1768,138 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(999999999, t.getNano()); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void minus_longTemporalUnit_null() { Duration t = Duration.ofSeconds(1); t.minus(1, (TemporalUnit) null); } + //----------------------------------------------------------------------- + @DataProvider(name="MinusDays") + Object[][] provider_minusDays_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, -1}, + {0, -1, 1}, + {Long.MAX_VALUE/3600/24, 0, Long.MAX_VALUE/3600/24}, + {Long.MIN_VALUE/3600/24, 0, Long.MIN_VALUE/3600/24}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {Long.MAX_VALUE/3600/24, 1, Long.MAX_VALUE/3600/24 - 1}, + {Long.MIN_VALUE/3600/24, -1, Long.MIN_VALUE/3600/24 + 1}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {-1, 0, -1}, + {-1, 1, -2}, + {-1, -1, 0}, + }; + } + + @Test(dataProvider="MinusDays") + public void minusDays_long(long days, long amount, long expectedDays) { + Duration t = Duration.ofDays(days); + t = t.minusDays(amount); + assertEquals(t.toDays(), expectedDays); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusDays_long_overflowTooBig() { + Duration t = Duration.ofDays(Long.MAX_VALUE/3600/24); + t.minusDays(-1); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusDays_long_overflowTooSmall() { + Duration t = Duration.ofDays(Long.MIN_VALUE/3600/24); + t.minusDays(1); + } + + //----------------------------------------------------------------------- + @DataProvider(name="MinusHours") + Object[][] provider_minusHours_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, -1}, + {0, -1, 1}, + {Long.MAX_VALUE/3600, 0, Long.MAX_VALUE/3600}, + {Long.MIN_VALUE/3600, 0, Long.MIN_VALUE/3600}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {Long.MAX_VALUE/3600, 1, Long.MAX_VALUE/3600 - 1}, + {Long.MIN_VALUE/3600, -1, Long.MIN_VALUE/3600 + 1}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {-1, 0, -1}, + {-1, 1, -2}, + {-1, -1, 0}, + }; + } + + @Test(dataProvider="MinusHours") + public void minusHours_long(long hours, long amount, long expectedHours) { + Duration t = Duration.ofHours(hours); + t = t.minusHours(amount); + assertEquals(t.toHours(), expectedHours); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusHours_long_overflowTooBig() { + Duration t = Duration.ofHours(Long.MAX_VALUE/3600); + t.minusHours(-1); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusHours_long_overflowTooSmall() { + Duration t = Duration.ofHours(Long.MIN_VALUE/3600); + t.minusHours(1); + } + + //----------------------------------------------------------------------- + @DataProvider(name="MinusMinutes") + Object[][] provider_minusminutes_long() { + return new Object[][] { + {0, 0, 0}, + {0, 1, -1}, + {0, -1, 1}, + {Long.MAX_VALUE/60, 0, Long.MAX_VALUE/60}, + {Long.MIN_VALUE/60, 0, Long.MIN_VALUE/60}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {Long.MAX_VALUE/60, 1, Long.MAX_VALUE/60 - 1}, + {Long.MIN_VALUE/60, -1, Long.MIN_VALUE/60 + 1}, + {1, 0, 1}, + {1, 1, 0}, + {1, -1, 2}, + {-1, 0, -1}, + {-1, 1, -2}, + {-1, -1, 0}, + }; + } + + @Test(dataProvider="MinusMinutes") + public void minusMinutes_long(long minutes, long amount, long expectedMinutes) { + Duration t = Duration.ofMinutes(minutes); + t = t.minusMinutes(amount); + assertEquals(t.toMinutes(), expectedMinutes); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusMinutes_long_overflowTooBig() { + Duration t = Duration.ofMinutes(Long.MAX_VALUE/60); + t.minusMinutes(-1); + } + + @Test(expectedExceptions = {ArithmeticException.class}) + public void minusMinutes_long_overflowTooSmall() { + Duration t = Duration.ofMinutes(Long.MIN_VALUE/60); + t.minusMinutes(1); + } + //----------------------------------------------------------------------- @DataProvider(name="MinusSeconds") Object[][] provider_minusSeconds_long() { @@ -1555,7 +1927,7 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="MinusSeconds", groups={"tck"}) + @Test(dataProvider="MinusSeconds") public void minusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.minusSeconds(amount); @@ -1563,13 +1935,13 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusSeconds_long_overflowTooBig() { Duration t = Duration.ofSeconds(1, 0); t.minusSeconds(Long.MIN_VALUE + 1); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusSeconds_long_overflowTooSmall() { Duration t = Duration.ofSeconds(-2, 0); t.minusSeconds(Long.MAX_VALUE); @@ -1631,21 +2003,21 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="MinusMillis", groups={"tck"}) + @Test(dataProvider="MinusMillis") public void minusMillis_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.minusMillis(amount); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(dataProvider="MinusMillis", groups={"tck"}) + @Test(dataProvider="MinusMillis") public void minusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds + 1, nanos); t = t.minusMillis(amount); assertEquals(t.getSeconds(), expectedSeconds + 1); assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(dataProvider="MinusMillis", groups={"tck"}) + @Test(dataProvider="MinusMillis") public void minusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds - 1, nanos); t = t.minusMillis(amount); @@ -1653,7 +2025,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(groups={"tck"}) + @Test public void minusMillis_long_max() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 998999999); t = t.minusMillis(-1); @@ -1661,13 +2033,13 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), 999999999); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusMillis_long_overflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999000000); t.minusMillis(-1); } - @Test(groups={"tck"}) + @Test public void minusMillis_long_min() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 1000000); t = t.minusMillis(1); @@ -1675,7 +2047,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), 0); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusMillis_long_overflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0); t.minusMillis(1); @@ -1757,7 +2129,7 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="MinusNanos", groups={"tck"}) + @Test(dataProvider="MinusNanos") public void minusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.minusNanos(amount); @@ -1765,13 +2137,13 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), expectedNanoOfSecond); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusNanos_long_overflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999); t.minusNanos(-1); } - @Test(expectedExceptions = {ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions = {ArithmeticException.class}) public void minusNanos_long_overflowTooSmall() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0); t.minusNanos(1); @@ -1873,7 +2245,7 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="MultipliedBy", groups={"tck"}) + @Test(dataProvider="MultipliedBy") public void multipliedBy(long seconds, int nanos, int multiplicand, long expectedSeconds, int expectedNanos) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.multipliedBy(multiplicand); @@ -1881,25 +2253,25 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), expectedNanos); } - @Test(groups={"tck"}) + @Test public void multipliedBy_max() { Duration test = Duration.ofSeconds(1); assertEquals(test.multipliedBy(Long.MAX_VALUE), Duration.ofSeconds(Long.MAX_VALUE)); } - @Test(groups={"tck"}) + @Test public void multipliedBy_min() { Duration test = Duration.ofSeconds(1); assertEquals(test.multipliedBy(Long.MIN_VALUE), Duration.ofSeconds(Long.MIN_VALUE)); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MAX_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig_negative() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MIN_VALUE); @@ -1990,7 +2362,7 @@ public class TCKDuration extends AbstractTCKTest { }; } - @Test(dataProvider="DividedBy", groups={"tck"}) + @Test(dataProvider="DividedBy") public void dividedBy(long seconds, int nanos, int divisor, long expectedSeconds, int expectedNanos) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.dividedBy(divisor); @@ -1998,14 +2370,14 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(t.getNano(), expectedNanos); } - @Test(dataProvider="DividedBy", expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(dataProvider="DividedBy", expectedExceptions=ArithmeticException.class) public void dividedByZero(long seconds, int nanos, int divisor, long expectedSeconds, int expectedNanos) { Duration t = Duration.ofSeconds(seconds, nanos); t.dividedBy(0); fail(t + " divided by zero did not throw ArithmeticException"); } - @Test(groups={"tck"}) + @Test public void dividedBy_max() { Duration test = Duration.ofSeconds(Long.MAX_VALUE); assertEquals(test.dividedBy(Long.MAX_VALUE), Duration.ofSeconds(1)); @@ -2014,7 +2386,7 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // negated() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_negated() { assertEquals(Duration.ofSeconds(0).negated(), Duration.ofSeconds(0)); assertEquals(Duration.ofSeconds(12).negated(), Duration.ofSeconds(-12)); @@ -2026,7 +2398,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(Duration.ofSeconds(Long.MAX_VALUE).negated(), Duration.ofSeconds(-Long.MAX_VALUE)); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_negated_overflow() { Duration.ofSeconds(Long.MIN_VALUE).negated(); } @@ -2034,7 +2406,7 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // abs() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_abs() { assertEquals(Duration.ofSeconds(0).abs(), Duration.ofSeconds(0)); assertEquals(Duration.ofSeconds(12).abs(), Duration.ofSeconds(12)); @@ -2046,7 +2418,7 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(Duration.ofSeconds(Long.MAX_VALUE).abs(), Duration.ofSeconds(Long.MAX_VALUE)); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_abs_overflow() { Duration.ofSeconds(Long.MIN_VALUE).abs(); } @@ -2054,19 +2426,19 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // toNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toNanos() { Duration test = Duration.ofSeconds(321, 123456789); assertEquals(test.toNanos(), 321123456789L); } - @Test(groups={"tck"}) + @Test public void test_toNanos_max() { Duration test = Duration.ofSeconds(0, Long.MAX_VALUE); assertEquals(test.toNanos(), Long.MAX_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_toNanos_tooBig() { Duration test = Duration.ofSeconds(0, Long.MAX_VALUE).plusNanos(1); test.toNanos(); @@ -2075,19 +2447,19 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // toMillis() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toMillis() { Duration test = Duration.ofSeconds(321, 123456789); assertEquals(test.toMillis(), 321000 + 123); } - @Test(groups={"tck"}) + @Test public void test_toMillis_max() { Duration test = Duration.ofSeconds(Long.MAX_VALUE / 1000, (Long.MAX_VALUE % 1000) * 1000000); assertEquals(test.toMillis(), Long.MAX_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_toMillis_tooBig() { Duration test = Duration.ofSeconds(Long.MAX_VALUE / 1000, ((Long.MAX_VALUE % 1000) + 1) * 1000000); test.toMillis(); @@ -2096,7 +2468,7 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { doTest_comparisons_Duration( Duration.ofSeconds(-2L, 0), @@ -2134,13 +2506,13 @@ public class TCKDuration extends AbstractTCKTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { Duration a = Duration.ofSeconds(0L, 0); a.compareTo(null); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({ "unchecked", "rawtypes" }) public void compareToNonDuration() { Comparable c = Duration.ofSeconds(0L); @@ -2150,7 +2522,7 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { Duration test5a = Duration.ofSeconds(5L, 20); Duration test5b = Duration.ofSeconds(5L, 20); @@ -2178,13 +2550,13 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(test6.equals(test6), true); } - @Test(groups={"tck"}) + @Test public void test_equals_null() { Duration test5 = Duration.ofSeconds(5L, 20); assertEquals(test5.equals(null), false); } - @Test(groups={"tck"}) + @Test public void test_equals_otherClass() { Duration test5 = Duration.ofSeconds(5L, 20); assertEquals(test5.equals(""), false); @@ -2193,7 +2565,7 @@ public class TCKDuration extends AbstractTCKTest { //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_hashCode() { Duration test5a = Duration.ofSeconds(5L, 20); Duration test5b = Duration.ofSeconds(5L, 20); @@ -2208,6 +2580,71 @@ public class TCKDuration extends AbstractTCKTest { assertEquals(test5a.hashCode() == test6.hashCode(), false); } + //----------------------------------------------------------------------- + @DataProvider(name="withNanos") + Object[][] provider_withNanos_int() { + return new Object[][] { + {0, 0, 0, 0, 0}, + {0, 0, 1, 0, 1}, + {0, 0, 999999999, 0, 999999999}, + + {1, 0, 0, 1, 0}, + {1, 0, 1, 1, 1}, + {1, 0, 999999999, 1, 999999999}, + + {-1, 0, 0, -1, 0}, + {-1, 0, 1, -1, 1}, + {-1, 0, 999999999, -1, 999999999}, + + {1, 999999999, 0, 1, 0}, + {1, 999999999, 1, 1, 1}, + {1, 999999998, 2, 1, 2}, + + {Long.MAX_VALUE, 0, 999999999, Long.MAX_VALUE, 999999999}, + {Long.MIN_VALUE, 0, 999999999, Long.MIN_VALUE, 999999999}, + }; + } + + @Test(dataProvider="withNanos") + public void withNanos_long(long seconds, int nanos, int amount, long expectedSeconds, int expectedNanoOfSecond) { + Duration t = Duration.ofSeconds(seconds, nanos); + t = t.withNanos(amount); + assertEquals(t.getSeconds(), expectedSeconds); + assertEquals(t.getNano(), expectedNanoOfSecond); + } + + //----------------------------------------------------------------------- + @DataProvider(name="withSeconds") + Object[][] provider_withSeconds_long() { + return new Object[][] { + {0, 0, 0, 0, 0}, + {0, 0, 1, 1, 0}, + {0, 0, -1, -1, 0}, + {0, 0, Long.MAX_VALUE, Long.MAX_VALUE, 0}, + {0, 0, Long.MIN_VALUE, Long.MIN_VALUE, 0}, + + {1, 0, 0, 0, 0}, + {1, 0, 2, 2, 0}, + {1, 0, -1, -1, 0}, + {1, 0, Long.MAX_VALUE, Long.MAX_VALUE, 0}, + {1, 0, Long.MIN_VALUE, Long.MIN_VALUE, 0}, + + {-1, 1, 0, 0, 1}, + {-1, 1, 1, 1, 1}, + {-1, 1, -1, -1, 1}, + {-1, 1, Long.MAX_VALUE, Long.MAX_VALUE, 1}, + {-1, 1, Long.MIN_VALUE, Long.MIN_VALUE, 1}, + }; + } + + @Test(dataProvider="withSeconds") + public void withSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) { + Duration t = Duration.ofSeconds(seconds, nanos); + t = t.withSeconds(amount); + assertEquals(t.getSeconds(), expectedSeconds); + assertEquals(t.getNano(), expectedNanoOfSecond); + } + //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- @@ -2299,6 +2736,6 @@ public class TCKDuration extends AbstractTCKTest { @Test(dataProvider="BadTemporalUnit", expectedExceptions=DateTimeException.class) public void test_bad_getUnit(long amount, TemporalUnit unit) { Duration t = Duration.of(amount, unit); - long actual = t.get(unit); + t.get(unit); } } diff --git a/jdk/test/java/time/tck/java/time/TCKInstant.java b/jdk/test/java/time/tck/java/time/TCKInstant.java index 0dd745d88e5..0bab2477992 100644 --- a/jdk/test/java/time/tck/java/time/TCKInstant.java +++ b/jdk/test/java/time/tck/java/time/TCKInstant.java @@ -75,6 +75,7 @@ import static java.time.temporal.ChronoUnit.WEEKS; import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -84,18 +85,20 @@ import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; import java.time.OffsetDateTime; +import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -113,6 +116,8 @@ public class TCKInstant extends AbstractDateTimeTest { private static final long MIN_SECOND = Instant.MIN.getEpochSecond(); private static final long MAX_SECOND = Instant.MAX.getEpochSecond(); + private static final ZoneId ZONE_PARIS = ZoneId.of("Europe/Paris"); + private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); private Instant TEST_12345_123456789; @@ -411,13 +416,13 @@ public class TCKInstant extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_12345_123456789, Queries.chronology(), null}, - {TEST_12345_123456789, Queries.zoneId(), null}, - {TEST_12345_123456789, Queries.precision(), NANOS}, - {TEST_12345_123456789, Queries.zone(), null}, - {TEST_12345_123456789, Queries.offset(), null}, - {TEST_12345_123456789, Queries.localDate(), null}, - {TEST_12345_123456789, Queries.localTime(), null}, + {TEST_12345_123456789, TemporalQuery.chronology(), null}, + {TEST_12345_123456789, TemporalQuery.zoneId(), null}, + {TEST_12345_123456789, TemporalQuery.precision(), NANOS}, + {TEST_12345_123456789, TemporalQuery.zone(), null}, + {TEST_12345_123456789, TemporalQuery.offset(), null}, + {TEST_12345_123456789, TemporalQuery.localDate(), null}, + {TEST_12345_123456789, TemporalQuery.localTime(), null}, }; } @@ -436,6 +441,128 @@ public class TCKInstant extends AbstractDateTimeTest { TEST_12345_123456789.query(null); } + //----------------------------------------------------------------------- + // adjustInto(Temporal) + //----------------------------------------------------------------------- + @DataProvider(name="adjustInto") + Object[][] data_adjustInto() { + return new Object[][]{ + {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(10, 200), null}, + {Instant.ofEpochSecond(10, -200), Instant.now(), Instant.ofEpochSecond(10, -200), null}, + {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(-10), null}, + {Instant.ofEpochSecond(10), Instant.MIN, Instant.ofEpochSecond(10), null}, + {Instant.ofEpochSecond(10), Instant.MAX, Instant.ofEpochSecond(10), null}, + + {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(10, 200), null}, + {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZoneOffset.UTC), OffsetDateTime.of(1970, 1, 1, 0, 0, 10, 200, ZoneOffset.UTC), null}, + {Instant.ofEpochSecond(10, 200), OffsetDateTime.of(1970, 1, 1, 0, 0, 20, 10, OFFSET_PTWO), OffsetDateTime.of(1970, 1, 1, 2, 0, 10, 200, OFFSET_PTWO), null}, + {Instant.ofEpochSecond(10, 200), ZonedDateTime.of(1970, 1, 1, 0, 0, 20, 10, ZONE_PARIS), ZonedDateTime.of(1970, 1, 1, 1, 0, 10, 200, ZONE_PARIS), null}, + + {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class}, + + }; + } + + @Test(dataProvider="adjustInto") + public void test_adjustInto(Instant test, Temporal temporal, Temporal expected, Class expectedEx) { + if (expectedEx == null) { + Temporal result = test.adjustInto(temporal); + assertEquals(result, expected); + } else { + try { + Temporal result = test.adjustInto(temporal); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- + // with(TemporalAdjuster) + //----------------------------------------------------------------------- + @DataProvider(name="with") + Object[][] data_with() { + return new Object[][]{ + {Instant.ofEpochSecond(10, 200), Instant.ofEpochSecond(20), Instant.ofEpochSecond(20), null}, + {Instant.ofEpochSecond(10), Instant.ofEpochSecond(20, -100), Instant.ofEpochSecond(20, -100), null}, + {Instant.ofEpochSecond(-10), Instant.EPOCH, Instant.ofEpochSecond(0), null}, + {Instant.ofEpochSecond(10), Instant.MIN, Instant.MIN, null}, + {Instant.ofEpochSecond(10), Instant.MAX, Instant.MAX, null}, + + {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20).toInstant(ZoneOffset.UTC), Instant.ofEpochSecond(20), null}, + + {Instant.ofEpochSecond(10, 200), LocalDateTime.of(1970, 1, 1, 0, 0, 20), null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), null, null, NullPointerException.class}, + + }; + } + + + @Test(dataProvider="with") + public void test_with_temporalAdjuster(Instant test, TemporalAdjuster adjuster, Instant expected, Class expectedEx) { + if (expectedEx == null) { + Instant result = test.with(adjuster); + assertEquals(result, expected); + } else { + try { + Instant result = test.with(adjuster); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- + // with(TemporalField, long) + //----------------------------------------------------------------------- + @DataProvider(name="with_longTemporalField") + Object[][] data_with_longTemporalField() { + return new Object[][]{ + {Instant.ofEpochSecond(10, 200), ChronoField.INSTANT_SECONDS, 100, Instant.ofEpochSecond(100, 200), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.INSTANT_SECONDS, 0, Instant.ofEpochSecond(0, 200), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.INSTANT_SECONDS, -100, Instant.ofEpochSecond(-100, 200), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_SECOND, 100, Instant.ofEpochSecond(10, 100), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_SECOND, 0, Instant.ofEpochSecond(10), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_SECOND, 100, Instant.ofEpochSecond(10, 100*1000), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_SECOND, 0, Instant.ofEpochSecond(10), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_SECOND, 100, Instant.ofEpochSecond(10, 100*1000*1000), null}, + {Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_SECOND, 0, Instant.ofEpochSecond(10), null}, + + {Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_SECOND, 1000000000L, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_SECOND, 1000000, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_SECOND, 1000, null, DateTimeException.class}, + + {Instant.ofEpochSecond(10, 200), ChronoField.SECOND_OF_MINUTE, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.SECOND_OF_DAY, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.OFFSET_SECONDS, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.NANO_OF_DAY, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MINUTE_OF_HOUR, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MINUTE_OF_DAY, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MILLI_OF_DAY, 1, null, DateTimeException.class}, + {Instant.ofEpochSecond(10, 200), ChronoField.MICRO_OF_DAY, 1, null, DateTimeException.class}, + + + }; + } + + @Test(dataProvider="with_longTemporalField") + public void test_with_longTemporalField(Instant test, TemporalField field, long value, Instant expected, Class expectedEx) { + if (expectedEx == null) { + Instant result = test.with(field, value); + assertEquals(result, expected); + } else { + try { + Instant result = test.with(field, value); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + //----------------------------------------------------------------------- // truncated(TemporalUnit) //----------------------------------------------------------------------- @@ -509,7 +636,7 @@ public class TCKInstant extends AbstractDateTimeTest { {Instant.ofEpochSecond(86400 + 10800 + 60 + 1, 123_456_789), NINETY_MINS, Instant.ofEpochSecond(86400 + 10800, 0)}, }; } - @Test(groups={"tck"}, dataProvider="truncatedToValid") + @Test(dataProvider="truncatedToValid") public void test_truncatedTo_valid(Instant input, TemporalUnit unit, Instant expected) { assertEquals(input.truncatedTo(unit), expected); } @@ -524,12 +651,12 @@ public class TCKInstant extends AbstractDateTimeTest { }; } - @Test(groups={"tck"}, dataProvider="truncatedToInvalid", expectedExceptions=DateTimeException.class) + @Test(dataProvider="truncatedToInvalid", expectedExceptions=DateTimeException.class) public void test_truncatedTo_invalid(Instant input, TemporalUnit unit) { input.truncatedTo(unit); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_12345_123456789.truncatedTo(null); } @@ -1579,6 +1706,130 @@ public class TCKInstant extends AbstractDateTimeTest { i.minusNanos(1); } + //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + {5, 650, -1, 650, SECONDS, -6}, + {5, 650, 0, 650, SECONDS, -5}, + {5, 650, 3, 650, SECONDS, -2}, + {5, 650, 4, 650, SECONDS, -1}, + {5, 650, 5, 650, SECONDS, 0}, + {5, 650, 6, 650, SECONDS, 1}, + {5, 650, 7, 650, SECONDS, 2}, + + {5, 650, -1, 0, SECONDS, -6}, + {5, 650, 0, 0, SECONDS, -5}, + {5, 650, 3, 0, SECONDS, -2}, + {5, 650, 4, 0, SECONDS, -1}, + {5, 650, 5, 0, SECONDS, 0}, + {5, 650, 6, 0, SECONDS, 0}, + {5, 650, 7, 0, SECONDS, 1}, + + {5, 650, -1, 950, SECONDS, -5}, + {5, 650, 0, 950, SECONDS, -4}, + {5, 650, 3, 950, SECONDS, -1}, + {5, 650, 4, 950, SECONDS, 0}, + {5, 650, 5, 950, SECONDS, 0}, + {5, 650, 6, 950, SECONDS, 1}, + {5, 650, 7, 950, SECONDS, 2}, + + {5, 650, -1, 50, SECONDS, -6}, + {5, 650, 0, 50, SECONDS, -5}, + {5, 650, 4, 50, SECONDS, -1}, + {5, 650, 5, 50, SECONDS, 0}, + {5, 650, 6, 50, SECONDS, 0}, + {5, 650, 7, 50, SECONDS, 1}, + {5, 650, 8, 50, SECONDS, 2}, + + {5, 650_000_000, -1, 650_000_000, NANOS, -6_000_000_000L}, + {5, 650_000_000, 0, 650_000_000, NANOS, -5_000_000_000L}, + {5, 650_000_000, 3, 650_000_000, NANOS, -2_000_000_000L}, + {5, 650_000_000, 4, 650_000_000, NANOS, -1_000_000_000L}, + {5, 650_000_000, 5, 650_000_000, NANOS, 0}, + {5, 650_000_000, 6, 650_000_000, NANOS, 1_000_000_000L}, + {5, 650_000_000, 7, 650_000_000, NANOS, 2_000_000_000L}, + + {5, 650_000_000, -1, 0, NANOS, -6_650_000_000L}, + {5, 650_000_000, 0, 0, NANOS, -5_650_000_000L}, + {5, 650_000_000, 3, 0, NANOS, -2_650_000_000L}, + {5, 650_000_000, 4, 0, NANOS, -1_650_000_000L}, + {5, 650_000_000, 5, 0, NANOS, -650_000_000L}, + {5, 650_000_000, 6, 0, NANOS, 350_000_000L}, + {5, 650_000_000, 7, 0, NANOS, 1_350_000_000L}, + + {5, 650_000_000, -1, 950_000_000, NANOS, -5_700_000_000L}, + {5, 650_000_000, 0, 950_000_000, NANOS, -4_700_000_000L}, + {5, 650_000_000, 3, 950_000_000, NANOS, -1_700_000_000L}, + {5, 650_000_000, 4, 950_000_000, NANOS, -700_000_000L}, + {5, 650_000_000, 5, 950_000_000, NANOS, 300_000_000L}, + {5, 650_000_000, 6, 950_000_000, NANOS, 1_300_000_000L}, + {5, 650_000_000, 7, 950_000_000, NANOS, 2_300_000_000L}, + + {5, 650_000_000, -1, 50_000_000, NANOS, -6_600_000_000L}, + {5, 650_000_000, 0, 50_000_000, NANOS, -5_600_000_000L}, + {5, 650_000_000, 4, 50_000_000, NANOS, -1_600_000_000L}, + {5, 650_000_000, 5, 50_000_000, NANOS, -600_000_000L}, + {5, 650_000_000, 6, 50_000_000, NANOS, 400_000_000L}, + {5, 650_000_000, 7, 50_000_000, NANOS, 1_400_000_000L}, + {5, 650_000_000, 8, 50_000_000, NANOS, 2_400_000_000L}, + + {0, 0, -60, 0, MINUTES, -1L}, + {0, 0, -1, 999_999_999, MINUTES, 0L}, + {0, 0, 59, 0, MINUTES, 0L}, + {0, 0, 59, 999_999_999, MINUTES, 0L}, + {0, 0, 60, 0, MINUTES, 1L}, + {0, 0, 61, 0, MINUTES, 1L}, + + {0, 0, -3600, 0, HOURS, -1L}, + {0, 0, -1, 999_999_999, HOURS, 0L}, + {0, 0, 3599, 0, HOURS, 0L}, + {0, 0, 3599, 999_999_999, HOURS, 0L}, + {0, 0, 3600, 0, HOURS, 1L}, + {0, 0, 3601, 0, HOURS, 1L}, + + {0, 0, -86400, 0, DAYS, -1L}, + {0, 0, -1, 999_999_999, DAYS, 0L}, + {0, 0, 86399, 0, DAYS, 0L}, + {0, 0, 86399, 999_999_999, DAYS, 0L}, + {0, 0, 86400, 0, DAYS, 1L}, + {0, 0, 86401, 0, DAYS, 1L}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(long seconds1, int nanos1, long seconds2, long nanos2, TemporalUnit unit, long expected) { + Instant i1 = Instant.ofEpochSecond(seconds1, nanos1); + Instant i2 = Instant.ofEpochSecond(seconds2, nanos2); + long amount = i1.periodUntil(i2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(long seconds1, int nanos1, long seconds2, long nanos2, TemporalUnit unit, long expected) { + Instant i1 = Instant.ofEpochSecond(seconds1, nanos1); + Instant i2 = Instant.ofEpochSecond(seconds2, nanos2); + long amount = i2.periodUntil(i1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = UnsupportedTemporalTypeException.class) + public void test_periodUntil_TemporalUnit_unsupportedUnit() { + TEST_12345_123456789.periodUntil(TEST_12345_123456789, MONTHS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_12345_123456789.periodUntil(null, HOURS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_12345_123456789.periodUntil(TEST_12345_123456789, null); + } + //----------------------------------------------------------------------- // atOffset() //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/tck/java/time/TCKLocalDate.java b/jdk/test/java/time/tck/java/time/TCKLocalDate.java index 48b69385bd0..926aca4a761 100644 --- a/jdk/test/java/time/tck/java/time/TCKLocalDate.java +++ b/jdk/test/java/time/tck/java/time/TCKLocalDate.java @@ -67,11 +67,19 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.ChronoUnit.CENTURIES; +import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.DECADES; +import static java.time.temporal.ChronoUnit.HOURS; +import static java.time.temporal.ChronoUnit.MILLENNIA; +import static java.time.temporal.ChronoUnit.MONTHS; +import static java.time.temporal.ChronoUnit.WEEKS; +import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; @@ -101,13 +109,13 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -137,7 +145,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { private Instant MAX_INSTANT; private Instant MIN_INSTANT; - @BeforeMethod(groups={"tck", "implementation"}) + @BeforeMethod public void setUp() { TEST_2007_07_15 = LocalDate.of(2007, 7, 15); @@ -170,7 +178,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { ALIGNED_WEEK_OF_MONTH, ALIGNED_WEEK_OF_YEAR, MONTH_OF_YEAR, - EPOCH_MONTH, + PROLEPTIC_MONTH, YEAR_OF_ERA, YEAR, ERA, @@ -236,7 +244,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { LocalDate expected = LocalDate.now(Clock.systemDefaultZone()); LocalDate test = LocalDate.now(); @@ -253,12 +261,12 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { LocalDate.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); LocalDate expected = LocalDate.now(Clock.system(zone)); @@ -276,12 +284,12 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { LocalDate.now((Clock) null); } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_utc() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); @@ -293,7 +301,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_offset() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); @@ -305,7 +313,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_beforeEpoch() { for (int i =-1; i >= -(2 * 24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i); @@ -318,27 +326,27 @@ public class TCKLocalDate extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock_maxYear() { Clock clock = Clock.fixed(MAX_INSTANT, ZoneOffset.UTC); LocalDate test = LocalDate.now(clock); assertEquals(test, MAX_DATE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void now_Clock_tooBig() { Clock clock = Clock.fixed(MAX_INSTANT.plusSeconds(24 * 60 * 60), ZoneOffset.UTC); LocalDate.now(clock); } - @Test(groups={"tck"}) + @Test public void now_Clock_minYear() { Clock clock = Clock.fixed(MIN_INSTANT, ZoneOffset.UTC); LocalDate test = LocalDate.now(clock); assertEquals(test, MIN_DATE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void now_Clock_tooLow() { Clock clock = Clock.fixed(MIN_INSTANT.minusNanos(1), ZoneOffset.UTC); LocalDate.now(clock); @@ -347,84 +355,84 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // of() factories //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_intsMonth() { assertEquals(TEST_2007_07_15, LocalDate.of(2007, Month.JULY, 15)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_intsMonth_29febNonLeap() { LocalDate.of(2007, Month.FEBRUARY, 29); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_intsMonth_31apr() { LocalDate.of(2007, Month.APRIL, 31); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_intsMonth_dayTooLow() { LocalDate.of(2007, Month.JANUARY, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_intsMonth_dayTooHigh() { LocalDate.of(2007, Month.JANUARY, 32); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_intsMonth_nullMonth() { LocalDate.of(2007, null, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_intsMonth_yearTooLow() { LocalDate.of(Integer.MIN_VALUE, Month.JANUARY, 1); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_ints() { check(TEST_2007_07_15, 2007, 7, 15); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_29febNonLeap() { LocalDate.of(2007, 2, 29); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_31apr() { LocalDate.of(2007, 4, 31); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_dayTooLow() { LocalDate.of(2007, 1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_dayTooHigh() { LocalDate.of(2007, 1, 32); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_monthTooLow() { LocalDate.of(2007, 0, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_monthTooHigh() { LocalDate.of(2007, 13, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_ints_yearTooLow() { LocalDate.of(Integer.MIN_VALUE, 1, 1); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofYearDay_ints_nonLeap() { LocalDate date = LocalDate.of(2007, 1, 1); for (int i = 1; i < 365; i++) { @@ -433,7 +441,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void factory_ofYearDay_ints_leap() { LocalDate date = LocalDate.of(2008, 1, 1); for (int i = 1; i < 366; i++) { @@ -442,22 +450,22 @@ public class TCKLocalDate extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_366nonLeap() { LocalDate.ofYearDay(2007, 366); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_dayTooLow() { LocalDate.ofYearDay(2007, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_dayTooHigh() { LocalDate.ofYearDay(2007, 367); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofYearDay_ints_yearTooLow() { LocalDate.ofYearDay(Integer.MIN_VALUE, 1); } @@ -491,7 +499,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // ofEpochDay() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofEpochDay() { long date_0000_01_01 = -678941 - 40587; assertEquals(LocalDate.ofEpochDay(0), LocalDate.of(1970, 1, 1)); @@ -512,12 +520,12 @@ public class TCKLocalDate extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochDay_aboveMax() { LocalDate.ofEpochDay(MAX_VALID_EPOCHDAYS + 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochDay_belowMin() { LocalDate.ofEpochDay(MIN_VALID_EPOCHDAYS - 1); } @@ -525,18 +533,18 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // from() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_from_TemporalAccessor() { assertEquals(LocalDate.from(LocalDate.of(2007, 7, 15)), LocalDate.of(2007, 7, 15)); assertEquals(LocalDate.from(LocalDateTime.of(2007, 7, 15, 12, 30)), LocalDate.of(2007, 7, 15)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { LocalDate.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { LocalDate.from((TemporalAccessor) null); } @@ -544,7 +552,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse() //----------------------------------------------------------------------- - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void factory_parse_validText(int y, int m, int d, String parsable) { LocalDate t = LocalDate.parse(parsable); assertNotNull(t, parsable); @@ -570,22 +578,22 @@ public class TCKLocalDate extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleBadParse", expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(dataProvider="sampleBadParse", expectedExceptions={DateTimeParseException.class}) public void factory_parse_invalidText(String unparsable) { LocalDate.parse(unparsable); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue() { LocalDate.parse("2008-06-32"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_invalidValue() { LocalDate.parse("2008-06-31"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { LocalDate.parse((String) null); } @@ -593,20 +601,20 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d"); LocalDate test = LocalDate.parse("2010 12 3", f); assertEquals(test, LocalDate.of(2010, 12, 3)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d"); LocalDate.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { LocalDate.parse("ANY", null); } @@ -617,21 +625,26 @@ public class TCKLocalDate extends AbstractDateTimeTest { @Test public void test_get_TemporalField() { LocalDate test = LocalDate.of(2008, 6, 30); - assertEquals(test.get(ChronoField.YEAR), 2008); - assertEquals(test.get(ChronoField.MONTH_OF_YEAR), 6); - assertEquals(test.get(ChronoField.DAY_OF_MONTH), 30); - assertEquals(test.get(ChronoField.DAY_OF_WEEK), 1); - assertEquals(test.get(ChronoField.DAY_OF_YEAR), 182); + assertEquals(test.get(YEAR), 2008); + assertEquals(test.get(MONTH_OF_YEAR), 6); + assertEquals(test.get(YEAR_OF_ERA), 2008); + assertEquals(test.get(ERA), 1); + assertEquals(test.get(DAY_OF_MONTH), 30); + assertEquals(test.get(DAY_OF_WEEK), 1); + assertEquals(test.get(DAY_OF_YEAR), 182); } @Test public void test_getLong_TemporalField() { LocalDate test = LocalDate.of(2008, 6, 30); - assertEquals(test.getLong(ChronoField.YEAR), 2008); - assertEquals(test.getLong(ChronoField.MONTH_OF_YEAR), 6); - assertEquals(test.getLong(ChronoField.DAY_OF_MONTH), 30); - assertEquals(test.getLong(ChronoField.DAY_OF_WEEK), 1); - assertEquals(test.getLong(ChronoField.DAY_OF_YEAR), 182); + assertEquals(test.getLong(YEAR), 2008); + assertEquals(test.getLong(MONTH_OF_YEAR), 6); + assertEquals(test.getLong(YEAR_OF_ERA), 2008); + assertEquals(test.getLong(ERA), 1); + assertEquals(test.getLong(PROLEPTIC_MONTH), 2008 * 12 + 6 - 1); + assertEquals(test.getLong(DAY_OF_MONTH), 30); + assertEquals(test.getLong(DAY_OF_WEEK), 1); + assertEquals(test.getLong(DAY_OF_YEAR), 182); } //----------------------------------------------------------------------- @@ -640,13 +653,13 @@ public class TCKLocalDate extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2007_07_15, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_2007_07_15, Queries.zoneId(), null}, - {TEST_2007_07_15, Queries.precision(), ChronoUnit.DAYS}, - {TEST_2007_07_15, Queries.zone(), null}, - {TEST_2007_07_15, Queries.offset(), null}, - {TEST_2007_07_15, Queries.localDate(), TEST_2007_07_15}, - {TEST_2007_07_15, Queries.localTime(), null}, + {TEST_2007_07_15, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_2007_07_15, TemporalQuery.zoneId(), null}, + {TEST_2007_07_15, TemporalQuery.precision(), ChronoUnit.DAYS}, + {TEST_2007_07_15, TemporalQuery.zone(), null}, + {TEST_2007_07_15, TemporalQuery.offset(), null}, + {TEST_2007_07_15, TemporalQuery.localDate(), TEST_2007_07_15}, + {TEST_2007_07_15, TemporalQuery.localTime(), null}, }; } @@ -681,7 +694,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_get(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); assertEquals(a.getYear(), y); @@ -689,7 +702,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { assertEquals(a.getDayOfMonth(), d); } - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_getDOY(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); int total = 0; @@ -700,7 +713,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { assertEquals(a.getDayOfYear(), doy); } - @Test(groups={"tck"}) + @Test public void test_getDayOfWeek() { DayOfWeek dow = DayOfWeek.MONDAY; for (Month month : Month.values()) { @@ -716,7 +729,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // isLeapYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isLeapYear() { assertEquals(LocalDate.of(1999, 1, 1).isLeapYear(), false); assertEquals(LocalDate.of(2000, 1, 1).isLeapYear(), true); @@ -736,7 +749,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // lengthOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_lengthOfMonth_notLeapYear() { assertEquals(LocalDate.of(2007, 1, 1).lengthOfMonth(), 31); assertEquals(LocalDate.of(2007, 2, 1).lengthOfMonth(), 28); @@ -752,7 +765,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { assertEquals(LocalDate.of(2007, 12, 1).lengthOfMonth(), 31); } - @Test(groups={"tck"}) + @Test public void test_lengthOfMonth_leapYear() { assertEquals(LocalDate.of(2008, 1, 1).lengthOfMonth(), 31); assertEquals(LocalDate.of(2008, 2, 1).lengthOfMonth(), 29); @@ -771,7 +784,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // lengthOfYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_lengthOfYear() { assertEquals(LocalDate.of(2007, 1, 1).lengthOfYear(), 365); assertEquals(LocalDate.of(2008, 1, 1).lengthOfYear(), 366); @@ -780,7 +793,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // with() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_adjustment() { final LocalDate sample = LocalDate.of(2012, 3, 4); TemporalAdjuster adjuster = new TemporalAdjuster() { @@ -792,7 +805,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { assertEquals(TEST_2007_07_15.with(adjuster), sample); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_adjustment_null() { TEST_2007_07_15.with((TemporalAdjuster) null); } @@ -800,28 +813,28 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // with(TemporalField,long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_TemporalField_long_normal() { LocalDate t = TEST_2007_07_15.with(YEAR, 2008); assertEquals(t, LocalDate.of(2008, 7, 15)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"} ) + @Test(expectedExceptions=NullPointerException.class ) public void test_with_TemporalField_long_null() { TEST_2007_07_15.with((TemporalField) null, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"} ) + @Test(expectedExceptions=DateTimeException.class ) public void test_with_TemporalField_long_invalidField() { TEST_2007_07_15.with(MockFieldNoValue.INSTANCE, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"} ) + @Test(expectedExceptions=DateTimeException.class ) public void test_with_TemporalField_long_timeField() { TEST_2007_07_15.with(ChronoField.AMPM_OF_DAY, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"} ) + @Test(expectedExceptions=DateTimeException.class ) public void test_with_TemporalField_long_invalidValue() { TEST_2007_07_15.with(ChronoField.DAY_OF_WEEK, -1); } @@ -829,18 +842,18 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withYear_int_normal() { LocalDate t = TEST_2007_07_15.withYear(2008); assertEquals(t, LocalDate.of(2008, 7, 15)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withYear_int_invalid() { TEST_2007_07_15.withYear(Year.MIN_VALUE - 1); } - @Test(groups={"tck"}) + @Test public void test_withYear_int_adjustDay() { LocalDate t = LocalDate.of(2008, 2, 29).withYear(2007); LocalDate expected = LocalDate.of(2007, 2, 28); @@ -850,18 +863,18 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth_int_normal() { LocalDate t = TEST_2007_07_15.withMonth(1); assertEquals(t, LocalDate.of(2007, 1, 15)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_int_invalid() { TEST_2007_07_15.withMonth(13); } - @Test(groups={"tck"}) + @Test public void test_withMonth_int_adjustDay() { LocalDate t = LocalDate.of(2007, 12, 31).withMonth(11); LocalDate expected = LocalDate.of(2007, 11, 30); @@ -871,18 +884,18 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_normal() { LocalDate t = TEST_2007_07_15.withDayOfMonth(1); assertEquals(t, LocalDate.of(2007, 7, 1)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_illegal() { TEST_2007_07_15.withDayOfMonth(32); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_invalid() { LocalDate.of(2007, 11, 30).withDayOfMonth(31); } @@ -890,18 +903,18 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withDayOfYear(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfYear_normal() { LocalDate t = TEST_2007_07_15.withDayOfYear(33); assertEquals(t, LocalDate.of(2007, 2, 2)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_illegal() { TEST_2007_07_15.withDayOfYear(367); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_invalid() { TEST_2007_07_15.withDayOfYear(366); } @@ -909,38 +922,38 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plus(Period) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_Period_positiveMonths() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); LocalDate t = TEST_2007_07_15.plus(period); assertEquals(t, LocalDate.of(2008, 2, 15)); } - @Test(groups={"tck"}) + @Test public void test_plus_Period_negativeDays() { MockSimplePeriod period = MockSimplePeriod.of(-25, ChronoUnit.DAYS); LocalDate t = TEST_2007_07_15.plus(period); assertEquals(t, LocalDate.of(2007, 6, 20)); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_Period_timeNotAllowed() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.HOURS); TEST_2007_07_15.plus(period); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_Period_null() { TEST_2007_07_15.plus((MockSimplePeriod) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_Period_invalidTooLarge() { MockSimplePeriod period = MockSimplePeriod.of(1, ChronoUnit.YEARS); LocalDate.of(Year.MAX_VALUE, 1, 1).plus(period); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_Period_invalidTooSmall() { MockSimplePeriod period = MockSimplePeriod.of(-1, ChronoUnit.YEARS); LocalDate.of(Year.MIN_VALUE, 1, 1).plus(period); @@ -949,34 +962,34 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_positiveMonths() { LocalDate t = TEST_2007_07_15.plus(7, ChronoUnit.MONTHS); assertEquals(t, LocalDate.of(2008, 2, 15)); } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_negativeDays() { LocalDate t = TEST_2007_07_15.plus(-25, ChronoUnit.DAYS); assertEquals(t, LocalDate.of(2007, 6, 20)); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_longTemporalUnit_timeNotAllowed() { TEST_2007_07_15.plus(7, ChronoUnit.HOURS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_longTemporalUnit_null() { TEST_2007_07_15.plus(1, (TemporalUnit) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_longTemporalUnit_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 1, 1).plus(1, ChronoUnit.YEARS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_longTemporalUnit_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).plus(-1, ChronoUnit.YEARS); } @@ -984,56 +997,56 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears_long_normal() { LocalDate t = TEST_2007_07_15.plusYears(1); assertEquals(t, LocalDate.of(2008, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_negative() { LocalDate t = TEST_2007_07_15.plusYears(-1); assertEquals(t, LocalDate.of(2006, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_adjustDay() { LocalDate t = LocalDate.of(2008, 2, 29).plusYears(1); LocalDate expected = LocalDate.of(2009, 2, 28); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_big() { long years = 20L + Year.MAX_VALUE; LocalDate test = LocalDate.of(-40, 6, 1).plusYears(years); assertEquals(test, LocalDate.of((int) (-40L + years), 6, 1)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLarge() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 6, 1); test.plusYears(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLargeMaxAddMax() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.plusYears(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLargeMaxAddMin() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.plusYears(Long.MIN_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooSmall_validInt() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooSmall_invalidInt() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusYears(-10); } @@ -1041,227 +1054,227 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_normal() { LocalDate t = TEST_2007_07_15.plusMonths(1); assertEquals(t, LocalDate.of(2007, 8, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_overYears() { LocalDate t = TEST_2007_07_15.plusMonths(25); assertEquals(t, LocalDate.of(2009, 8, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_negative() { LocalDate t = TEST_2007_07_15.plusMonths(-1); assertEquals(t, LocalDate.of(2007, 6, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.plusMonths(-7); assertEquals(t, LocalDate.of(2006, 12, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_negativeOverYears() { LocalDate t = TEST_2007_07_15.plusMonths(-31); assertEquals(t, LocalDate.of(2004, 12, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_adjustDayFromLeapYear() { LocalDate t = LocalDate.of(2008, 2, 29).plusMonths(12); LocalDate expected = LocalDate.of(2009, 2, 28); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_adjustDayFromMonthLength() { LocalDate t = LocalDate.of(2007, 3, 31).plusMonths(1); LocalDate expected = LocalDate.of(2007, 4, 30); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_big() { long months = 20L + Integer.MAX_VALUE; LocalDate test = LocalDate.of(-40, 6, 1).plusMonths(months); assertEquals(test, LocalDate.of((int) (-40L + months / 12), 6 + (int) (months % 12), 1)); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusMonths_long_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 1).plusMonths(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_long_invalidTooLargeMaxAddMax() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.plusMonths(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_long_invalidTooLargeMaxAddMin() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.plusMonths(Long.MIN_VALUE); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusMonths_long_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusMonths(-1); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_normal() { LocalDate t = TEST_2007_07_15.plusWeeks(1); assertEquals(t, LocalDate.of(2007, 7, 22)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overMonths() { LocalDate t = TEST_2007_07_15.plusWeeks(9); assertEquals(t, LocalDate.of(2007, 9, 16)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overYears() { LocalDate t = LocalDate.of(2006, 7, 16).plusWeeks(52); assertEquals(t, TEST_2007_07_15); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overLeapYears() { LocalDate t = TEST_2007_07_15.plusYears(-1).plusWeeks(104); assertEquals(t, LocalDate.of(2008, 7, 12)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negative() { LocalDate t = TEST_2007_07_15.plusWeeks(-1); assertEquals(t, LocalDate.of(2007, 7, 8)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.plusWeeks(-28); assertEquals(t, LocalDate.of(2006, 12, 31)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negativeOverYears() { LocalDate t = TEST_2007_07_15.plusWeeks(-104); assertEquals(t, LocalDate.of(2005, 7, 17)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_maximum() { LocalDate t = LocalDate.of(Year.MAX_VALUE, 12, 24).plusWeeks(1); LocalDate expected = LocalDate.of(Year.MAX_VALUE, 12, 31); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_minimum() { LocalDate t = LocalDate.of(Year.MIN_VALUE, 1, 8).plusWeeks(-1); LocalDate expected = LocalDate.of(Year.MIN_VALUE, 1, 1); assertEquals(t, expected); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusWeeks_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 25).plusWeeks(1); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusWeeks_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 7).plusWeeks(-1); } - @Test(expectedExceptions={ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions={ArithmeticException.class}) public void test_plusWeeks_invalidMaxMinusMax() { LocalDate.of(Year.MAX_VALUE, 12, 25).plusWeeks(Long.MAX_VALUE); } - @Test(expectedExceptions={ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions={ArithmeticException.class}) public void test_plusWeeks_invalidMaxMinusMin() { LocalDate.of(Year.MAX_VALUE, 12, 25).plusWeeks(Long.MIN_VALUE); } - @Test(groups={"tck"}) + @Test public void test_plusDays_normal() { LocalDate t = TEST_2007_07_15.plusDays(1); assertEquals(t, LocalDate.of(2007, 7, 16)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overMonths() { LocalDate t = TEST_2007_07_15.plusDays(62); assertEquals(t, LocalDate.of(2007, 9, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overYears() { LocalDate t = LocalDate.of(2006, 7, 14).plusDays(366); assertEquals(t, TEST_2007_07_15); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overLeapYears() { LocalDate t = TEST_2007_07_15.plusYears(-1).plusDays(365 + 366); assertEquals(t, LocalDate.of(2008, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negative() { LocalDate t = TEST_2007_07_15.plusDays(-1); assertEquals(t, LocalDate.of(2007, 7, 14)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.plusDays(-196); assertEquals(t, LocalDate.of(2006, 12, 31)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negativeOverYears() { LocalDate t = TEST_2007_07_15.plusDays(-730); assertEquals(t, LocalDate.of(2005, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_plusDays_maximum() { LocalDate t = LocalDate.of(Year.MAX_VALUE, 12, 30).plusDays(1); LocalDate expected = LocalDate.of(Year.MAX_VALUE, 12, 31); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_plusDays_minimum() { LocalDate t = LocalDate.of(Year.MIN_VALUE, 1, 2).plusDays(-1); LocalDate expected = LocalDate.of(Year.MIN_VALUE, 1, 1); assertEquals(t, expected); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusDays_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 31).plusDays(1); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusDays_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusDays(-1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_plusDays_overflowTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 31).plusDays(Long.MAX_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_plusDays_overflowTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusDays(Long.MIN_VALUE); } @@ -1269,38 +1282,38 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minus(Period) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_Period_positiveMonths() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); LocalDate t = TEST_2007_07_15.minus(period); assertEquals(t, LocalDate.of(2006, 12, 15)); } - @Test(groups={"tck"}) + @Test public void test_minus_Period_negativeDays() { MockSimplePeriod period = MockSimplePeriod.of(-25, ChronoUnit.DAYS); LocalDate t = TEST_2007_07_15.minus(period); assertEquals(t, LocalDate.of(2007, 8, 9)); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_Period_timeNotAllowed() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.HOURS); TEST_2007_07_15.minus(period); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_Period_null() { TEST_2007_07_15.minus((MockSimplePeriod) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_Period_invalidTooLarge() { MockSimplePeriod period = MockSimplePeriod.of(-1, ChronoUnit.YEARS); LocalDate.of(Year.MAX_VALUE, 1, 1).minus(period); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_Period_invalidTooSmall() { MockSimplePeriod period = MockSimplePeriod.of(1, ChronoUnit.YEARS); LocalDate.of(Year.MIN_VALUE, 1, 1).minus(period); @@ -1309,34 +1322,34 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_positiveMonths() { LocalDate t = TEST_2007_07_15.minus(7, ChronoUnit.MONTHS); assertEquals(t, LocalDate.of(2006, 12, 15)); } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_negativeDays() { LocalDate t = TEST_2007_07_15.minus(-25, ChronoUnit.DAYS); assertEquals(t, LocalDate.of(2007, 8, 9)); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_longTemporalUnit_timeNotAllowed() { TEST_2007_07_15.minus(7, ChronoUnit.HOURS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_longTemporalUnit_null() { TEST_2007_07_15.minus(1, (TemporalUnit) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_longTemporalUnit_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 1, 1).minus(-1, ChronoUnit.YEARS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_longTemporalUnit_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).minus(1, ChronoUnit.YEARS); } @@ -1344,51 +1357,51 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears_long_normal() { LocalDate t = TEST_2007_07_15.minusYears(1); assertEquals(t, LocalDate.of(2006, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_negative() { LocalDate t = TEST_2007_07_15.minusYears(-1); assertEquals(t, LocalDate.of(2008, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_adjustDay() { LocalDate t = LocalDate.of(2008, 2, 29).minusYears(1); LocalDate expected = LocalDate.of(2007, 2, 28); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_big() { long years = 20L + Year.MAX_VALUE; LocalDate test = LocalDate.of(40, 6, 1).minusYears(years); assertEquals(test, LocalDate.of((int) (40L - years), 6, 1)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLarge() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 6, 1); test.minusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLargeMaxAddMax() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.minusYears(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLargeMaxAddMin() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.minusYears(Long.MIN_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).minusYears(1); } @@ -1396,231 +1409,306 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_normal() { LocalDate t = TEST_2007_07_15.minusMonths(1); assertEquals(t, LocalDate.of(2007, 6, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_overYears() { LocalDate t = TEST_2007_07_15.minusMonths(25); assertEquals(t, LocalDate.of(2005, 6, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_negative() { LocalDate t = TEST_2007_07_15.minusMonths(-1); assertEquals(t, LocalDate.of(2007, 8, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.minusMonths(-7); assertEquals(t, LocalDate.of(2008, 2, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_negativeOverYears() { LocalDate t = TEST_2007_07_15.minusMonths(-31); assertEquals(t, LocalDate.of(2010, 2, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_adjustDayFromLeapYear() { LocalDate t = LocalDate.of(2008, 2, 29).minusMonths(12); LocalDate expected = LocalDate.of(2007, 2, 28); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_adjustDayFromMonthLength() { LocalDate t = LocalDate.of(2007, 3, 31).minusMonths(1); LocalDate expected = LocalDate.of(2007, 2, 28); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_big() { long months = 20L + Integer.MAX_VALUE; LocalDate test = LocalDate.of(40, 6, 1).minusMonths(months); assertEquals(test, LocalDate.of((int) (40L - months / 12), 6 - (int) (months % 12), 1)); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusMonths_long_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 1).minusMonths(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_long_invalidTooLargeMaxAddMax() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.minusMonths(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_long_invalidTooLargeMaxAddMin() { LocalDate test = LocalDate.of(Year.MAX_VALUE, 12, 1); test.minusMonths(Long.MIN_VALUE); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusMonths_long_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).minusMonths(1); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_normal() { LocalDate t = TEST_2007_07_15.minusWeeks(1); assertEquals(t, LocalDate.of(2007, 7, 8)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overMonths() { LocalDate t = TEST_2007_07_15.minusWeeks(9); assertEquals(t, LocalDate.of(2007, 5, 13)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overYears() { LocalDate t = LocalDate.of(2008, 7, 13).minusWeeks(52); assertEquals(t, TEST_2007_07_15); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overLeapYears() { LocalDate t = TEST_2007_07_15.minusYears(-1).minusWeeks(104); assertEquals(t, LocalDate.of(2006, 7, 18)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negative() { LocalDate t = TEST_2007_07_15.minusWeeks(-1); assertEquals(t, LocalDate.of(2007, 7, 22)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.minusWeeks(-28); assertEquals(t, LocalDate.of(2008, 1, 27)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negativeOverYears() { LocalDate t = TEST_2007_07_15.minusWeeks(-104); assertEquals(t, LocalDate.of(2009, 7, 12)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_maximum() { LocalDate t = LocalDate.of(Year.MAX_VALUE, 12, 24).minusWeeks(-1); LocalDate expected = LocalDate.of(Year.MAX_VALUE, 12, 31); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_minimum() { LocalDate t = LocalDate.of(Year.MIN_VALUE, 1, 8).minusWeeks(1); LocalDate expected = LocalDate.of(Year.MIN_VALUE, 1, 1); assertEquals(t, expected); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusWeeks_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 25).minusWeeks(-1); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusWeeks_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 7).minusWeeks(1); } - @Test(expectedExceptions={ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions={ArithmeticException.class}) public void test_minusWeeks_invalidMaxMinusMax() { LocalDate.of(Year.MAX_VALUE, 12, 25).minusWeeks(Long.MAX_VALUE); } - @Test(expectedExceptions={ArithmeticException.class}, groups={"tck"}) + @Test(expectedExceptions={ArithmeticException.class}) public void test_minusWeeks_invalidMaxMinusMin() { LocalDate.of(Year.MAX_VALUE, 12, 25).minusWeeks(Long.MIN_VALUE); } - @Test(groups={"tck"}) + @Test public void test_minusDays_normal() { LocalDate t = TEST_2007_07_15.minusDays(1); assertEquals(t, LocalDate.of(2007, 7, 14)); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overMonths() { LocalDate t = TEST_2007_07_15.minusDays(62); assertEquals(t, LocalDate.of(2007, 5, 14)); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overYears() { LocalDate t = LocalDate.of(2008, 7, 16).minusDays(367); assertEquals(t, TEST_2007_07_15); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overLeapYears() { LocalDate t = TEST_2007_07_15.plusYears(2).minusDays(365 + 366); assertEquals(t, TEST_2007_07_15); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negative() { LocalDate t = TEST_2007_07_15.minusDays(-1); assertEquals(t, LocalDate.of(2007, 7, 16)); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negativeAcrossYear() { LocalDate t = TEST_2007_07_15.minusDays(-169); assertEquals(t, LocalDate.of(2007, 12, 31)); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negativeOverYears() { LocalDate t = TEST_2007_07_15.minusDays(-731); assertEquals(t, LocalDate.of(2009, 7, 15)); } - @Test(groups={"tck"}) + @Test public void test_minusDays_maximum() { LocalDate t = LocalDate.of(Year.MAX_VALUE, 12, 30).minusDays(-1); LocalDate expected = LocalDate.of(Year.MAX_VALUE, 12, 31); assertEquals(t, expected); } - @Test(groups={"tck"}) + @Test public void test_minusDays_minimum() { LocalDate t = LocalDate.of(Year.MIN_VALUE, 1, 2).minusDays(1); LocalDate expected = LocalDate.of(Year.MIN_VALUE, 1, 1); assertEquals(t, expected); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusDays_invalidTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 31).minusDays(-1); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusDays_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).minusDays(1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_minusDays_overflowTooLarge() { LocalDate.of(Year.MAX_VALUE, 12, 31).minusDays(Long.MIN_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_minusDays_overflowTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).minusDays(Long.MAX_VALUE); } + //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + {date(2000, 1, 1), date(2000, 1, 1), DAYS, 0}, + {date(2000, 1, 1), date(2000, 1, 1), WEEKS, 0}, + {date(2000, 1, 1), date(2000, 1, 1), MONTHS, 0}, + {date(2000, 1, 1), date(2000, 1, 1), YEARS, 0}, + {date(2000, 1, 1), date(2000, 1, 1), DECADES, 0}, + {date(2000, 1, 1), date(2000, 1, 1), CENTURIES, 0}, + {date(2000, 1, 1), date(2000, 1, 1), MILLENNIA, 0}, + + {date(2000, 1, 15), date(2000, 2, 14), DAYS, 30}, + {date(2000, 1, 15), date(2000, 2, 15), DAYS, 31}, + {date(2000, 1, 15), date(2000, 2, 16), DAYS, 32}, + + {date(2000, 1, 15), date(2000, 2, 17), WEEKS, 4}, + {date(2000, 1, 15), date(2000, 2, 18), WEEKS, 4}, + {date(2000, 1, 15), date(2000, 2, 19), WEEKS, 5}, + {date(2000, 1, 15), date(2000, 2, 20), WEEKS, 5}, + + {date(2000, 1, 15), date(2000, 2, 14), MONTHS, 0}, + {date(2000, 1, 15), date(2000, 2, 15), MONTHS, 1}, + {date(2000, 1, 15), date(2000, 2, 16), MONTHS, 1}, + {date(2000, 1, 15), date(2000, 3, 14), MONTHS, 1}, + {date(2000, 1, 15), date(2000, 3, 15), MONTHS, 2}, + {date(2000, 1, 15), date(2000, 3, 16), MONTHS, 2}, + + {date(2000, 1, 15), date(2001, 1, 14), YEARS, 0}, + {date(2000, 1, 15), date(2001, 1, 15), YEARS, 1}, + {date(2000, 1, 15), date(2001, 1, 16), YEARS, 1}, + {date(2000, 1, 15), date(2004, 1, 14), YEARS, 3}, + {date(2000, 1, 15), date(2004, 1, 15), YEARS, 4}, + {date(2000, 1, 15), date(2004, 1, 16), YEARS, 4}, + + {date(2000, 1, 15), date(2010, 1, 14), DECADES, 0}, + {date(2000, 1, 15), date(2010, 1, 15), DECADES, 1}, + + {date(2000, 1, 15), date(2100, 1, 14), CENTURIES, 0}, + {date(2000, 1, 15), date(2100, 1, 15), CENTURIES, 1}, + + {date(2000, 1, 15), date(3000, 1, 14), MILLENNIA, 0}, + {date(2000, 1, 15), date(3000, 1, 15), MILLENNIA, 1}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { + long amount = date1.periodUntil(date2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { + long amount = date2.periodUntil(date1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = UnsupportedTemporalTypeException.class) + public void test_periodUntil_TemporalUnit_unsupportedUnit() { + TEST_2007_07_15.periodUntil(TEST_2007_07_15, HOURS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_2007_07_15.periodUntil(null, DAYS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_2007_07_15.periodUntil(TEST_2007_07_15, null); + } + //----------------------------------------------------------------------- // periodUntil(ChronoLocalDate) //----------------------------------------------------------------------- @@ -1732,156 +1820,171 @@ public class TCKLocalDate extends AbstractDateTimeTest { TEST_2007_07_15.periodUntil(null); } + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d"); + String t = LocalDate.of(2010, 12, 3).format(f); + assertEquals(t, "2010 12 3"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + LocalDate.of(2010, 12, 3).format(null); + } + //----------------------------------------------------------------------- // atTime() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atTime_LocalTime() { LocalDate t = LocalDate.of(2008, 6, 30); assertEquals(t.atTime(LocalTime.of(11, 30)), LocalDateTime.of(2008, 6, 30, 11, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atTime_LocalTime_null() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime((LocalTime) null); } //------------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atTime_int_int() { LocalDate t = LocalDate.of(2008, 6, 30); assertEquals(t.atTime(11, 30), LocalDateTime.of(2008, 6, 30, 11, 30)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_hourTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(-1, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_hourTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(24, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_minuteTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_minuteTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 60); } - @Test(groups={"tck"}) + @Test public void test_atTime_int_int_int() { LocalDate t = LocalDate.of(2008, 6, 30); assertEquals(t.atTime(11, 30, 40), LocalDateTime.of(2008, 6, 30, 11, 30, 40)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_hourTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(-1, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_hourTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(24, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_minuteTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, -1, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_minuteTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 60, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_secondTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_secondTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, 60); } - @Test(groups={"tck"}) + @Test public void test_atTime_int_int_int_int() { LocalDate t = LocalDate.of(2008, 6, 30); assertEquals(t.atTime(11, 30, 40, 50), LocalDateTime.of(2008, 6, 30, 11, 30, 40, 50)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_hourTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(-1, 30, 40, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_hourTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(24, 30, 40, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_minuteTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, -1, 40, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_minuteTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 60, 40, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_secondTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, -1, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_secondTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, 60, 50); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_nanoTooSmall() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, 40, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atTime_int_int_int_int_nanoTooBig() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime(11, 30, 40, 1000000000); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atTime_OffsetTime() { LocalDate t = LocalDate.of(2008, 6, 30); assertEquals(t.atTime(OffsetTime.of(11, 30, 0, 0, OFFSET_PONE)), OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PONE)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atTime_OffsetTime_null() { LocalDate t = LocalDate.of(2008, 6, 30); t.atTime((OffsetTime) null); @@ -1929,7 +2032,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // toEpochDay() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toEpochDay() { long date_0000_01_01 = -678941 - 40587; @@ -1954,7 +2057,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { doTest_comparisons_LocalDate( LocalDate.of(Year.MIN_VALUE, 1, 1), @@ -2002,36 +2105,36 @@ public class TCKLocalDate extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { TEST_2007_07_15.compareTo(null); } - @Test(groups={"tck"}) + @Test public void test_isBefore() { assertTrue(TEST_2007_07_15.isBefore(LocalDate.of(2007, 07, 16))); assertFalse(TEST_2007_07_15.isBefore(LocalDate.of(2007, 07, 14))); assertFalse(TEST_2007_07_15.isBefore(TEST_2007_07_15)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_ObjectNull() { TEST_2007_07_15.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_ObjectNull() { TEST_2007_07_15.isAfter(null); } - @Test(groups={"tck"}) + @Test public void test_isAfter() { assertTrue(TEST_2007_07_15.isAfter(LocalDate.of(2007, 07, 14))); assertFalse(TEST_2007_07_15.isAfter(LocalDate.of(2007, 07, 16))); assertFalse(TEST_2007_07_15.isAfter(TEST_2007_07_15)); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({"unchecked", "rawtypes"}) public void compareToNonLocalDate() { Comparable c = TEST_2007_07_15; @@ -2041,42 +2144,42 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates" , groups={"tck"}) + @Test(dataProvider="sampleDates" ) public void test_equals_true(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); LocalDate b = LocalDate.of(y, m, d); assertEquals(a.equals(b), true); } - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_equals_false_year_differs(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); LocalDate b = LocalDate.of(y + 1, m, d); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_equals_false_month_differs(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); LocalDate b = LocalDate.of(y, m + 1, d); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_equals_false_day_differs(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); LocalDate b = LocalDate.of(y, m, d + 1); assertEquals(a.equals(b), false); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_2007_07_15.equals(TEST_2007_07_15), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_2007_07_15.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_2007_07_15.equals(null), false); } @@ -2084,7 +2187,7 @@ public class TCKLocalDate extends AbstractDateTimeTest { //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_hashCode(int y, int m, int d) { LocalDate a = LocalDate.of(y, m, d); assertEquals(a.hashCode(), a.hashCode()); @@ -2111,26 +2214,15 @@ public class TCKLocalDate extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int y, int m, int d, String expected) { LocalDate t = LocalDate.of(y, m, d); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d"); - String t = LocalDate.of(2010, 12, 3).toString(f); - assertEquals(t, "2010 12 3"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - LocalDate.of(2010, 12, 3).toString(null); + private LocalDate date(int year, int month, int day) { + return LocalDate.of(year, month, day); } } diff --git a/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java b/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java index 9b95fcd51b7..f7d5c9ed1f4 100644 --- a/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java +++ b/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java @@ -70,7 +70,6 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.HOUR_OF_AMPM; import static java.time.temporal.ChronoField.HOUR_OF_DAY; @@ -83,19 +82,30 @@ import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.NANO_OF_DAY; import static java.time.temporal.ChronoField.NANO_OF_SECOND; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.SECOND_OF_DAY; import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.ChronoUnit.CENTURIES; import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.DECADES; +import static java.time.temporal.ChronoUnit.HALF_DAYS; +import static java.time.temporal.ChronoUnit.HOURS; +import static java.time.temporal.ChronoUnit.MICROS; +import static java.time.temporal.ChronoUnit.MILLENNIA; +import static java.time.temporal.ChronoUnit.MILLIS; +import static java.time.temporal.ChronoUnit.MINUTES; import static java.time.temporal.ChronoUnit.MONTHS; import static java.time.temporal.ChronoUnit.NANOS; import static java.time.temporal.ChronoUnit.SECONDS; +import static java.time.temporal.ChronoUnit.WEEKS; import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -108,6 +118,7 @@ import java.time.LocalDateTime; import java.time.LocalTime; import java.time.Month; import java.time.OffsetDateTime; +import java.time.OffsetTime; import java.time.Year; import java.time.ZoneId; import java.time.ZoneOffset; @@ -118,7 +129,6 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -153,7 +163,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { private Instant MAX_INSTANT; private Instant MIN_INSTANT; - @BeforeMethod(groups={"implementation","tck"}) + @BeforeMethod public void setUp() { MAX_DATE_TIME = LocalDateTime.MAX; MIN_DATE_TIME = LocalDateTime.MIN; @@ -195,7 +205,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { ALIGNED_WEEK_OF_MONTH, ALIGNED_WEEK_OF_YEAR, MONTH_OF_YEAR, - EPOCH_MONTH, + PROLEPTIC_MONTH, YEAR_OF_ERA, YEAR, ERA, @@ -272,7 +282,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(timeOut=30000, groups={"tck"}) // TODO: remove when time zone loading is faster + @Test(timeOut=30000) // TODO: remove when time zone loading is faster public void now() { LocalDateTime expected = LocalDateTime.now(Clock.systemDefaultZone()); LocalDateTime test = LocalDateTime.now(); @@ -289,12 +299,12 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { LocalDateTime.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); LocalDateTime expected = LocalDateTime.now(Clock.system(zone)); @@ -312,12 +322,12 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { LocalDateTime.now((Clock) null); } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_utc() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); @@ -333,7 +343,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_offset() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); @@ -349,7 +359,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { @@ -365,27 +375,27 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock_maxYear() { Clock clock = Clock.fixed(MAX_INSTANT, ZoneOffset.UTC); LocalDateTime test = LocalDateTime.now(clock); assertEquals(test, MAX_DATE_TIME); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void now_Clock_tooBig() { Clock clock = Clock.fixed(MAX_INSTANT.plusSeconds(24 * 60 * 60), ZoneOffset.UTC); LocalDateTime.now(clock); } - @Test(groups={"tck"}) + @Test public void now_Clock_minYear() { Clock clock = Clock.fixed(MIN_INSTANT, ZoneOffset.UTC); LocalDateTime test = LocalDateTime.now(clock); assertEquals(test, MIN_DATE_TIME); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void now_Clock_tooLow() { Clock clock = Clock.fixed(MIN_INSTANT.minusNanos(1), ZoneOffset.UTC); LocalDateTime.now(clock); @@ -395,375 +405,375 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { // of() factories //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_4intsMonth() { LocalDateTime dateTime = LocalDateTime.of(2007, Month.JULY, 15, 12, 30); check(dateTime, 2007, 7, 15, 12, 30, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, Month.JULY, 15, 12, 30); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_4intsMonth_nullMonth() { LocalDateTime.of(2007, null, 15, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_dayTooLow() { LocalDateTime.of(2007, Month.JULY, -1, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_dayTooHigh() { LocalDateTime.of(2007, Month.JULY, 32, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_hourTooLow() { LocalDateTime.of(2007, Month.JULY, 15, -1, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_hourTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 24, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_minuteTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_4intsMonth_minuteTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_5intsMonth() { LocalDateTime dateTime = LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 40); check(dateTime, 2007, 7, 15, 12, 30, 40, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, Month.JULY, 15, 12, 30, 40); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_5intsMonth_nullMonth() { LocalDateTime.of(2007, null, 15, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_dayTooLow() { LocalDateTime.of(2007, Month.JULY, -1, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_dayTooHigh() { LocalDateTime.of(2007, Month.JULY, 32, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_hourTooLow() { LocalDateTime.of(2007, Month.JULY, 15, -1, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_hourTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 24, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_minuteTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, -1, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_minuteTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 60, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_secondTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5intsMonth_secondTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_6intsMonth() { LocalDateTime dateTime = LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 40, 987654321); check(dateTime, 2007, 7, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, Month.JULY, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_6intsMonth_nullMonth() { LocalDateTime.of(2007, null, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_dayTooLow() { LocalDateTime.of(2007, Month.JULY, -1, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_dayTooHigh() { LocalDateTime.of(2007, Month.JULY, 32, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_hourTooLow() { LocalDateTime.of(2007, Month.JULY, 15, -1, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_hourTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 24, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_minuteTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, -1, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_minuteTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 60, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_secondTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, -1, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_secondTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 60, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_nanoTooLow() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 40, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6intsMonth_nanoTooHigh() { LocalDateTime.of(2007, Month.JULY, 15, 12, 30, 40, 1000000000); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_5ints() { LocalDateTime dateTime = LocalDateTime.of(2007, 7, 15, 12, 30); check(dateTime, 2007, 7, 15, 12, 30, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, 7, 15, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_monthTooLow() { LocalDateTime.of(2007, 0, 15, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_monthTooHigh() { LocalDateTime.of(2007, 13, 15, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_dayTooLow() { LocalDateTime.of(2007, 7, -1, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_dayTooHigh() { LocalDateTime.of(2007, 7, 32, 12, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_hourTooLow() { LocalDateTime.of(2007, 7, 15, -1, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_hourTooHigh() { LocalDateTime.of(2007, 7, 15, 24, 30); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_minuteTooLow() { LocalDateTime.of(2007, 7, 15, 12, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_5ints_minuteTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_6ints() { LocalDateTime dateTime = LocalDateTime.of(2007, 7, 15, 12, 30, 40); check(dateTime, 2007, 7, 15, 12, 30, 40, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, 7, 15, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_monthTooLow() { LocalDateTime.of(2007, 0, 15, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_monthTooHigh() { LocalDateTime.of(2007, 13, 15, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_dayTooLow() { LocalDateTime.of(2007, 7, -1, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_dayTooHigh() { LocalDateTime.of(2007, 7, 32, 12, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_hourTooLow() { LocalDateTime.of(2007, 7, 15, -1, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_hourTooHigh() { LocalDateTime.of(2007, 7, 15, 24, 30, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_minuteTooLow() { LocalDateTime.of(2007, 7, 15, 12, -1, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_minuteTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 60, 40); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_secondTooLow() { LocalDateTime.of(2007, 7, 15, 12, 30, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_6ints_secondTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 30, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_7ints() { LocalDateTime dateTime = LocalDateTime.of(2007, 7, 15, 12, 30, 40, 987654321); check(dateTime, 2007, 7, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_yearTooLow() { LocalDateTime.of(Integer.MIN_VALUE, 7, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_monthTooLow() { LocalDateTime.of(2007, 0, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_monthTooHigh() { LocalDateTime.of(2007, 13, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_dayTooLow() { LocalDateTime.of(2007, 7, -1, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_dayTooHigh() { LocalDateTime.of(2007, 7, 32, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_hourTooLow() { LocalDateTime.of(2007, 7, 15, -1, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_hourTooHigh() { LocalDateTime.of(2007, 7, 15, 24, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_minuteTooLow() { LocalDateTime.of(2007, 7, 15, 12, -1, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_minuteTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 60, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_secondTooLow() { LocalDateTime.of(2007, 7, 15, 12, 30, -1, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_secondTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 30, 60, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_nanoTooLow() { LocalDateTime.of(2007, 7, 15, 12, 30, 40, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_of_7ints_nanoTooHigh() { LocalDateTime.of(2007, 7, 15, 12, 30, 40, 1000000000); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_LocalDate_LocalTime() { LocalDateTime dateTime = LocalDateTime.of(LocalDate.of(2007, 7, 15), LocalTime.of(12, 30, 40, 987654321)); check(dateTime, 2007, 7, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDate_LocalTime_nullLocalDate() { LocalDateTime.of(null, LocalTime.of(12, 30, 40, 987654321)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDate_LocalTime_nullLocalTime() { LocalDateTime.of(LocalDate.of(2007, 7, 15), null); } @@ -790,22 +800,22 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { assertEquals(test, expected); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_instantTooBig() { LocalDateTime.ofInstant(Instant.MAX, OFFSET_PONE) ; } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_instantTooSmall() { LocalDateTime.ofInstant(Instant.MIN, OFFSET_PONE) ; } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_nullInstant() { LocalDateTime.ofInstant((Instant) null, ZONE_GAZA); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_nullZone() { LocalDateTime.ofInstant(Instant.EPOCH, (ZoneId) null); } @@ -813,7 +823,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // ofEpochSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofEpochSecond_longOffset_afterEpoch() { LocalDateTime base = LocalDateTime.of(1970, 1, 1, 2, 0, 0, 500); for (int i = 0; i < 100000; i++) { @@ -822,7 +832,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void factory_ofEpochSecond_longOffset_beforeEpoch() { LocalDateTime base = LocalDateTime.of(1970, 1, 1, 2, 0, 0, 500); for (int i = 0; i < 100000; i++) { @@ -831,27 +841,27 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochSecond_longOffset_tooBig() { LocalDateTime.ofEpochSecond(Long.MAX_VALUE, 500, OFFSET_PONE); // TODO: better test } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochSecond_longOffset_tooSmall() { LocalDateTime.ofEpochSecond(Long.MIN_VALUE, 500, OFFSET_PONE); // TODO: better test } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochSecond_badNanos_toBig() { LocalDateTime.ofEpochSecond(0, 1_000_000_000, OFFSET_PONE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofEpochSecond_badNanos_toSmall() { LocalDateTime.ofEpochSecond(0, -1, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofEpochSecond_longOffset_nullOffset() { LocalDateTime.ofEpochSecond(0L, 500, null); } @@ -859,19 +869,19 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // from() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_from_TemporalAccessor() { LocalDateTime base = LocalDateTime.of(2007, 7, 15, 17, 30); assertEquals(LocalDateTime.from(base), base); assertEquals(LocalDateTime.from(ZonedDateTime.of(base, ZoneOffset.ofHours(2))), base); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_from_TemporalAccessor_invalid_noDerive() { LocalDateTime.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_from_TemporalAccessor_null() { LocalDateTime.from((TemporalAccessor) null); } @@ -879,7 +889,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse() //----------------------------------------------------------------------- - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_parse(int y, int month, int d, int h, int m, int s, int n, String text) { LocalDateTime t = LocalDateTime.parse(text); assertEquals(t.getYear(), y); @@ -891,17 +901,17 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { assertEquals(t.getNano(), n); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue() { LocalDateTime.parse("2008-06-32T11:15"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_invalidValue() { LocalDateTime.parse("2008-06-31T11:15"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { LocalDateTime.parse((String) null); } @@ -909,20 +919,20 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); LocalDateTime test = LocalDateTime.parse("2010 12 3 11 30 45", f); assertEquals(test, LocalDateTime.of(2010, 12, 3, 11, 30, 45)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); LocalDateTime.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { LocalDateTime.parse("ANY", null); } @@ -970,13 +980,13 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2007_07_15_12_30_40_987654321, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_2007_07_15_12_30_40_987654321, Queries.zoneId(), null}, - {TEST_2007_07_15_12_30_40_987654321, Queries.precision(), ChronoUnit.NANOS}, - {TEST_2007_07_15_12_30_40_987654321, Queries.zone(), null}, - {TEST_2007_07_15_12_30_40_987654321, Queries.offset(), null}, - {TEST_2007_07_15_12_30_40_987654321, Queries.localDate(), LocalDate.of(2007, 7, 15)}, - {TEST_2007_07_15_12_30_40_987654321, Queries.localTime(), LocalTime.of(12, 30, 40, 987654321)}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.zoneId(), null}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.precision(), ChronoUnit.NANOS}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.zone(), null}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.offset(), null}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.localDate(), LocalDate.of(2007, 7, 15)}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.localTime(), LocalTime.of(12, 30, 40, 987654321)}, }; } @@ -1033,7 +1043,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // get*() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_get_dates(int y, int m, int d) { LocalDateTime a = LocalDateTime.of(y, m, d, 12, 30); assertEquals(a.getYear(), y); @@ -1041,7 +1051,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { assertEquals(a.getDayOfMonth(), d); } - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_getDOY(int y, int m, int d) { LocalDateTime a = LocalDateTime.of(y, m, d, 12 ,30); int total = 0; @@ -1052,7 +1062,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { assertEquals(a.getDayOfYear(), doy); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_get_times(int h, int m, int s, int ns) { LocalDateTime a = LocalDateTime.of(TEST_2007_07_15_12_30_40_987654321.toLocalDate(), LocalTime.of(h, m, s, ns)); assertEquals(a.getHour(), h); @@ -1064,7 +1074,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // getDayOfWeek() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getDayOfWeek() { DayOfWeek dow = DayOfWeek.MONDAY; for (Month month : Month.values()) { @@ -1078,10 +1088,50 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } + //----------------------------------------------------------------------- + // adjustInto(Temporal) + //----------------------------------------------------------------------- + @DataProvider(name="adjustInto") + Object[][] data_adjustInto() { + return new Object[][]{ + {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime.of(2012, 3, 4, 23, 5, 0, 0), null}, + {LocalDateTime.of(2012, Month.MARCH, 4, 0, 0), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), LocalDateTime.of(2012, 3, 4, 0, 0), null}, + {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MAX, LocalDateTime.of(2012, 3, 4, 23, 5), null}, + {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MIN, LocalDateTime.of(2012, 3, 4, 23, 5), null}, + {LocalDateTime.MAX, LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MAX, null}, + {LocalDateTime.MIN, LocalDateTime.of(2012, 3, 4, 23, 5), LocalDateTime.MIN, null}, + + {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetDateTime.of(2210, 2, 2, 0, 0, 0, 0, ZoneOffset.UTC), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZoneOffset.UTC), null}, + {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetDateTime.of(2210, 2, 2, 0, 0, 0, 0, OFFSET_PONE), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null}, + {LocalDateTime.of(2012, 3, 4, 23, 5), ZonedDateTime.of(2210, 2, 2, 0, 0, 0, 0, ZONE_PARIS), ZonedDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZONE_PARIS), null}, + + {LocalDateTime.of(2012, 3, 4, 23, 5), LocalDate.of(2210, 2, 2), null, DateTimeException.class}, + {LocalDateTime.of(2012, 3, 4, 23, 5), LocalTime.of(22, 3, 0), null, DateTimeException.class}, + {LocalDateTime.of(2012, 3, 4, 23, 5), OffsetTime.of(22, 3, 0, 0, ZoneOffset.UTC), null, DateTimeException.class}, + {LocalDateTime.of(2012, 3, 4, 23, 5), null, null, NullPointerException.class}, + + }; + } + + @Test(dataProvider="adjustInto") + public void test_adjustInto(LocalDateTime test, Temporal temporal, Temporal expected, Class expectedEx) { + if (expectedEx == null) { + Temporal result = test.adjustInto(temporal); + assertEquals(result, expected); + } else { + try { + Temporal result = test.adjustInto(temporal); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + //----------------------------------------------------------------------- // with() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_adjustment() { final LocalDateTime sample = LocalDateTime.of(2012, 3, 4, 23, 5); TemporalAdjuster adjuster = new TemporalAdjuster() { @@ -1093,7 +1143,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { assertEquals(TEST_2007_07_15_12_30_40_987654321.with(adjuster), sample); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_adjustment_null() { TEST_2007_07_15_12_30_40_987654321.with((TemporalAdjuster) null); } @@ -1101,18 +1151,18 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withYear_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withYear(2008); check(t, 2008, 7, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withYear_int_invalid() { TEST_2007_07_15_12_30_40_987654321.withYear(Year.MIN_VALUE - 1); } - @Test(groups={"tck"}) + @Test public void test_withYear_int_adjustDay() { LocalDateTime t = LocalDateTime.of(2008, 2, 29, 12, 30).withYear(2007); LocalDateTime expected = LocalDateTime.of(2007, 2, 28, 12, 30); @@ -1122,18 +1172,18 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withMonth(1); check(t, 2007, 1, 15, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_int_invalid() { TEST_2007_07_15_12_30_40_987654321.withMonth(13); } - @Test(groups={"tck"}) + @Test public void test_withMonth_int_adjustDay() { LocalDateTime t = LocalDateTime.of(2007, 12, 31, 12, 30).withMonth(11); LocalDateTime expected = LocalDateTime.of(2007, 11, 30, 12, 30); @@ -1143,18 +1193,18 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withDayOfMonth(1); check(t, 2007, 7, 1, 12, 30, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_invalid() { LocalDateTime.of(2007, 11, 30, 12, 30).withDayOfMonth(32); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_invalidCombination() { LocalDateTime.of(2007, 11, 30, 12, 30).withDayOfMonth(31); } @@ -1162,18 +1212,18 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withDayOfYear(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfYear_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withDayOfYear(33); assertEquals(t, LocalDateTime.of(2007, 2, 2, 12, 30, 40, 987654321)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_illegal() { TEST_2007_07_15_12_30_40_987654321.withDayOfYear(367); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_invalid() { TEST_2007_07_15_12_30_40_987654321.withDayOfYear(366); } @@ -1181,7 +1231,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withHour() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withHour_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 24; i++) { @@ -1190,12 +1240,12 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withHour_hourTooLow() { TEST_2007_07_15_12_30_40_987654321.withHour(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withHour_hourTooHigh() { TEST_2007_07_15_12_30_40_987654321.withHour(24); } @@ -1203,7 +1253,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withMinute() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMinute_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { @@ -1212,12 +1262,12 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMinute_minuteTooLow() { TEST_2007_07_15_12_30_40_987654321.withMinute(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMinute_minuteTooHigh() { TEST_2007_07_15_12_30_40_987654321.withMinute(60); } @@ -1225,7 +1275,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; for (int i = 0; i < 60; i++) { @@ -1234,12 +1284,12 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withSecond_secondTooLow() { TEST_2007_07_15_12_30_40_987654321.withSecond(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withSecond_secondTooHigh() { TEST_2007_07_15_12_30_40_987654321.withSecond(60); } @@ -1247,7 +1297,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withNano() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321; t = t.withNano(1); @@ -1260,12 +1310,12 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { assertEquals(t.getNano(), 999999999); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withNanoOfSecond_nanoTooLow() { TEST_2007_07_15_12_30_40_987654321.withNano(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withNanoOfSecond_nanoTooHigh() { TEST_2007_07_15_12_30_40_987654321.withNano(1000000000); } @@ -1273,14 +1323,14 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // truncatedTo(TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_truncatedTo_normal() { assertEquals(TEST_2007_07_15_12_30_40_987654321.truncatedTo(NANOS), TEST_2007_07_15_12_30_40_987654321); assertEquals(TEST_2007_07_15_12_30_40_987654321.truncatedTo(SECONDS), TEST_2007_07_15_12_30_40_987654321.withNano(0)); assertEquals(TEST_2007_07_15_12_30_40_987654321.truncatedTo(DAYS), TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_2007_07_15_12_30_40_987654321.truncatedTo(null); } @@ -1322,29 +1372,29 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_positiveMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plus(7, ChronoUnit.MONTHS); assertEquals(t, LocalDateTime.of(2008, 2, 15, 12, 30, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_negativeDays() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plus(-25, ChronoUnit.DAYS); assertEquals(t, LocalDateTime.of(2007, 6, 20, 12, 30, 40, 987654321)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_longTemporalUnit_null() { TEST_2007_07_15_12_30_40_987654321.plus(1, (TemporalUnit) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_longTemporalUnit_invalidTooLarge() { LocalDateTime.of(Year.MAX_VALUE, 1, 1, 0, 0).plus(1, ChronoUnit.YEARS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plus_longTemporalUnit_invalidTooSmall() { LocalDateTime.of(Year.MIN_VALUE, 1, 1, 0, 0).plus(-1, ChronoUnit.YEARS); } @@ -1352,30 +1402,30 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(1); check(t, 2008, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusYears_int_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(-1); check(t, 2006, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusYears_int_adjustDay() { LocalDateTime t = createDateMidnight(2008, 2, 29).plusYears(1); check(t, 2009, 2, 28, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_int_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 1, 1).plusYears(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_int_invalidTooSmall() { LocalDate.of(Year.MIN_VALUE, 1, 1).plusYears(-1); } @@ -1383,54 +1433,54 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(1); check(t, 2007, 8, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_overYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(25); check(t, 2009, 8, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(-1); check(t, 2007, 6, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(-7); check(t, 2006, 12, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(-31); check(t, 2004, 12, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_adjustDayFromLeapYear() { LocalDateTime t = createDateMidnight(2008, 2, 29).plusMonths(12); check(t, 2009, 2, 28, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_int_adjustDayFromMonthLength() { LocalDateTime t = createDateMidnight(2007, 3, 31).plusMonths(1); check(t, 2007, 4, 30, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_int_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 1).plusMonths(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_int_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).plusMonths(-1); } @@ -1470,7 +1520,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="samplePlusWeeksSymmetry", groups={"tck"}) + @Test(dataProvider="samplePlusWeeksSymmetry") public void test_plusWeeks_symmetry(LocalDateTime reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDateTime t = reference.plusWeeks(weeks).plusWeeks(-weeks); @@ -1481,66 +1531,66 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(1); check(t, 2007, 7, 22, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(9); check(t, 2007, 9, 16, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overYears() { LocalDateTime t = LocalDateTime.of(2006, 7, 16, 12, 30, 40, 987654321).plusWeeks(52); assertEquals(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_overLeapYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(-1).plusWeeks(104); check(t, 2008, 7, 12, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(-1); check(t, 2007, 7, 8, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(-28); check(t, 2006, 12, 31, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(-104); check(t, 2005, 7, 17, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_maximum() { LocalDateTime t = createDateMidnight(Year.MAX_VALUE, 12, 24).plusWeeks(1); check(t, Year.MAX_VALUE, 12, 31, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_minimum() { LocalDateTime t = createDateMidnight(Year.MIN_VALUE, 1, 8).plusWeeks(-1); check(t, Year.MIN_VALUE, 1, 1, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusWeeks_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 25).plusWeeks(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusWeeks_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 7).plusWeeks(-1); } @@ -1580,7 +1630,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="samplePlusDaysSymmetry", groups={"tck"}) + @Test(dataProvider="samplePlusDaysSymmetry") public void test_plusDays_symmetry(LocalDateTime reference) { for (int days = 0; days < 365 * 8; days++) { LocalDateTime t = reference.plusDays(days).plusDays(-days); @@ -1591,76 +1641,76 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plusDays_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(1); check(t, 2007, 7, 16, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(62); check(t, 2007, 9, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overYears() { LocalDateTime t = LocalDateTime.of(2006, 7, 14, 12, 30, 40, 987654321).plusDays(366); assertEquals(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_overLeapYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(-1).plusDays(365 + 366); check(t, 2008, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(-1); check(t, 2007, 7, 14, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(-196); check(t, 2006, 12, 31, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(-730); check(t, 2005, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_plusDays_maximum() { LocalDateTime t = createDateMidnight(Year.MAX_VALUE, 12, 30).plusDays(1); check(t, Year.MAX_VALUE, 12, 31, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_plusDays_minimum() { LocalDateTime t = createDateMidnight(Year.MIN_VALUE, 1, 2).plusDays(-1); check(t, Year.MIN_VALUE, 1, 1, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusDays_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 31).plusDays(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusDays_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).plusDays(-1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_plusDays_overflowTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 31).plusDays(Long.MAX_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_plusDays_overflowTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).plusDays(Long.MIN_VALUE); } @@ -1668,7 +1718,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusHours_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); @@ -1685,7 +1735,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plusHours_fromZero() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = base.toLocalDate().minusDays(3); @@ -1704,7 +1754,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plusHours_fromOne() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0)); LocalDate d = base.toLocalDate().minusDays(3); @@ -1727,7 +1777,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMinutes_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); @@ -1749,7 +1799,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_fromZero() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = base.toLocalDate().minusDays(1); @@ -1768,7 +1818,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMinutes(24 * 60); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().plusDays(1)); @@ -1777,7 +1827,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusSeconds_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); @@ -1852,7 +1902,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="plusSeconds_fromZero", groups={"tck"}) + @Test(dataProvider="plusSeconds_fromZero") public void test_plusSeconds_fromZero(int seconds, LocalDate date, int hour, int min, int sec) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.plusSeconds(seconds); @@ -1863,7 +1913,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { assertEquals(sec, t.getSecond()); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusSeconds(24 * 60 * 60); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().plusDays(1)); @@ -1872,7 +1922,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); @@ -1956,7 +2006,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="plusNanos_fromZero", groups={"tck"}) + @Test(dataProvider="plusNanos_fromZero") public void test_plusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.plusNanos(nanoseconds); @@ -1968,7 +2018,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { assertEquals(nanos, t.getNano()); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusNanos(24 * 60 * 60 * 1000000000L); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().plusDays(1)); @@ -2011,29 +2061,29 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_positiveMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minus(7, ChronoUnit.MONTHS); assertEquals(t, LocalDateTime.of(2006, 12, 15, 12, 30, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_negativeDays() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minus(-25, ChronoUnit.DAYS); assertEquals(t, LocalDateTime.of(2007, 8, 9, 12, 30, 40, 987654321)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_longTemporalUnit_null() { TEST_2007_07_15_12_30_40_987654321.minus(1, (TemporalUnit) null); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_longTemporalUnit_invalidTooLarge() { LocalDateTime.of(Year.MAX_VALUE, 1, 1, 0, 0).minus(-1, ChronoUnit.YEARS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minus_longTemporalUnit_invalidTooSmall() { LocalDateTime.of(Year.MIN_VALUE, 1, 1, 0, 0).minus(1, ChronoUnit.YEARS); } @@ -2041,30 +2091,30 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusYears(1); check(t, 2006, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusYears_int_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusYears(-1); check(t, 2008, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusYears_int_adjustDay() { LocalDateTime t = createDateMidnight(2008, 2, 29).minusYears(1); check(t, 2007, 2, 28, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_int_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 1, 1).minusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_int_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).minusYears(1); } @@ -2072,54 +2122,54 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(1); check(t, 2007, 6, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_overYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(25); check(t, 2005, 6, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(-1); check(t, 2007, 8, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(-7); check(t, 2008, 2, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(-31); check(t, 2010, 2, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_adjustDayFromLeapYear() { LocalDateTime t = createDateMidnight(2008, 2, 29).minusMonths(12); check(t, 2007, 2, 28, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_int_adjustDayFromMonthLength() { LocalDateTime t = createDateMidnight(2007, 3, 31).minusMonths(1); check(t, 2007, 2, 28, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_int_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 1).minusMonths(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_int_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).minusMonths(1); } @@ -2159,7 +2209,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleMinusWeeksSymmetry", groups={"tck"}) + @Test(dataProvider="sampleMinusWeeksSymmetry") public void test_minusWeeks_symmetry(LocalDateTime reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDateTime t = reference.minusWeeks(weeks).minusWeeks(-weeks); @@ -2170,66 +2220,66 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(1); check(t, 2007, 7, 8, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(9); check(t, 2007, 5, 13, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overYears() { LocalDateTime t = LocalDateTime.of(2008, 7, 13, 12, 30, 40, 987654321).minusWeeks(52); assertEquals(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_overLeapYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusYears(-1).minusWeeks(104); check(t, 2006, 7, 18, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(-1); check(t, 2007, 7, 22, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(-28); check(t, 2008, 1, 27, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(-104); check(t, 2009, 7, 12, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_maximum() { LocalDateTime t = createDateMidnight(Year.MAX_VALUE, 12, 24).minusWeeks(-1); check(t, Year.MAX_VALUE, 12, 31, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_minimum() { LocalDateTime t = createDateMidnight(Year.MIN_VALUE, 1, 8).minusWeeks(1); check(t, Year.MIN_VALUE, 1, 1, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusWeeks_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 25).minusWeeks(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusWeeks_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 7).minusWeeks(1); } @@ -2269,7 +2319,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleMinusDaysSymmetry", groups={"tck"}) + @Test(dataProvider="sampleMinusDaysSymmetry") public void test_minusDays_symmetry(LocalDateTime reference) { for (int days = 0; days < 365 * 8; days++) { LocalDateTime t = reference.minusDays(days).minusDays(-days); @@ -2280,76 +2330,76 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minusDays_normal() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(1); check(t, 2007, 7, 14, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overMonths() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(62); check(t, 2007, 5, 14, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overYears() { LocalDateTime t = LocalDateTime.of(2008, 7, 16, 12, 30, 40, 987654321).minusDays(367); assertEquals(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_overLeapYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(2).minusDays(365 + 366); assertEquals(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negative() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(-1); check(t, 2007, 7, 16, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negativeAcrossYear() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(-169); check(t, 2007, 12, 31, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_negativeOverYears() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(-731); check(t, 2009, 7, 15, 12, 30, 40, 987654321); } - @Test(groups={"tck"}) + @Test public void test_minusDays_maximum() { LocalDateTime t = createDateMidnight(Year.MAX_VALUE, 12, 30).minusDays(-1); check(t, Year.MAX_VALUE, 12, 31, 0, 0, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_minusDays_minimum() { LocalDateTime t = createDateMidnight(Year.MIN_VALUE, 1, 2).minusDays(1); check(t, Year.MIN_VALUE, 1, 1, 0, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusDays_invalidTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 31).minusDays(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusDays_invalidTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).minusDays(1); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_minusDays_overflowTooLarge() { createDateMidnight(Year.MAX_VALUE, 12, 31).minusDays(Long.MIN_VALUE); } - @Test(expectedExceptions=ArithmeticException.class, groups={"tck"}) + @Test(expectedExceptions=ArithmeticException.class) public void test_minusDays_overflowTooSmall() { createDateMidnight(Year.MIN_VALUE, 1, 1).minusDays(Long.MAX_VALUE); } @@ -2357,7 +2407,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusHours_one() { LocalDateTime t =TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); @@ -2374,7 +2424,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minusHours_fromZero() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = base.toLocalDate().plusDays(2); @@ -2393,7 +2443,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minusHours_fromOne() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0)); LocalDate d = base.toLocalDate().plusDays(2); @@ -2416,7 +2466,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMinutes_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); @@ -2441,7 +2491,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_fromZero() { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = base.toLocalDate().minusDays(1); @@ -2460,7 +2510,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMinutes(24 * 60); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1)); @@ -2469,7 +2519,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusSeconds_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); @@ -2549,7 +2599,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="minusSeconds_fromZero", groups={"tck"}) + @Test(dataProvider="minusSeconds_fromZero") public void test_minusSeconds_fromZero(int seconds, LocalDate date, int hour, int min, int sec) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusSeconds(seconds); @@ -2563,7 +2613,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusNanos_halfABillion() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate().minusDays(1); @@ -2654,7 +2704,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="minusNanos_fromZero", groups={"tck"}) + @Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) { LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDateTime t = base.minusNanos(nanoseconds); @@ -2666,16 +2716,194 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { assertEquals(nanos, t.getNano()); } + //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + // date only + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), DAYS, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), WEEKS, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), MONTHS, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), YEARS, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), DECADES, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), CENTURIES, 0}, + {dtNoon(2000, 1, 1), dtNoon(2000, 1, 1), MILLENNIA, 0}, + + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 14), DAYS, 30}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 15), DAYS, 31}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 16), DAYS, 32}, + + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 17), WEEKS, 4}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 18), WEEKS, 4}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 19), WEEKS, 5}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 20), WEEKS, 5}, + + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 14), MONTHS, 0}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 15), MONTHS, 1}, + {dtNoon(2000, 1, 15), dtNoon(2000, 2, 16), MONTHS, 1}, + {dtNoon(2000, 1, 15), dtNoon(2000, 3, 14), MONTHS, 1}, + {dtNoon(2000, 1, 15), dtNoon(2000, 3, 15), MONTHS, 2}, + {dtNoon(2000, 1, 15), dtNoon(2000, 3, 16), MONTHS, 2}, + + {dtNoon(2000, 1, 15), dtNoon(2001, 1, 14), YEARS, 0}, + {dtNoon(2000, 1, 15), dtNoon(2001, 1, 15), YEARS, 1}, + {dtNoon(2000, 1, 15), dtNoon(2001, 1, 16), YEARS, 1}, + {dtNoon(2000, 1, 15), dtNoon(2004, 1, 14), YEARS, 3}, + {dtNoon(2000, 1, 15), dtNoon(2004, 1, 15), YEARS, 4}, + {dtNoon(2000, 1, 15), dtNoon(2004, 1, 16), YEARS, 4}, + + {dtNoon(2000, 1, 15), dtNoon(2010, 1, 14), DECADES, 0}, + {dtNoon(2000, 1, 15), dtNoon(2010, 1, 15), DECADES, 1}, + + {dtNoon(2000, 1, 15), dtNoon(2100, 1, 14), CENTURIES, 0}, + {dtNoon(2000, 1, 15), dtNoon(2100, 1, 15), CENTURIES, 1}, + + {dtNoon(2000, 1, 15), dtNoon(3000, 1, 14), MILLENNIA, 0}, + {dtNoon(2000, 1, 15), dtNoon(3000, 1, 15), MILLENNIA, 1}, + + // time only + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), NANOS, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), MICROS, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), MILLIS, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), SECONDS, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), MINUTES, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), HOURS, 0}, + {dtEpoch(0, 0, 0, 0), dtEpoch(0, 0, 0, 0), HALF_DAYS, 0}, + + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), NANOS, 2 * 3600 * 1_000_000_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), MICROS, 2 * 3600 * 1_000_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), MILLIS, 2 * 3600 * 1_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), SECONDS, 2 * 3600}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), MINUTES, 2 * 60}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), HOURS, 2}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 0, 0, 0), HALF_DAYS, 0}, + + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), NANOS, 14 * 3600 * 1_000_000_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), MICROS, 14 * 3600 * 1_000_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), MILLIS, 14 * 3600 * 1_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), SECONDS, 14 * 3600}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), MINUTES, 14 * 60}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), HOURS, 14}, + {dtEpoch(0, 0, 0, 0), dtEpoch(14, 0, 0, 0), HALF_DAYS, 1}, + + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), NANOS, (2 * 3600 + 30 * 60 + 40) * 1_000_000_000L + 1500}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), MICROS, (2 * 3600 + 30 * 60 + 40) * 1_000_000L + 1}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), MILLIS, (2 * 3600 + 30 * 60 + 40) * 1_000L}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), SECONDS, 2 * 3600 + 30 * 60 + 40}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), MINUTES, 2 * 60 + 30}, + {dtEpoch(0, 0, 0, 0), dtEpoch(2, 30, 40, 1500), HOURS, 2}, + + // combinations + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 499), NANOS, -1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 500), NANOS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 501), NANOS, 1}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 39, 500), SECONDS, -1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 39, 501), SECONDS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 499), SECONDS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 500), SECONDS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 501), SECONDS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 41, 499), SECONDS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 41, 500), SECONDS, 1}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 499), NANOS, -1 + 86400_000_000_000L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 500), NANOS, 0 + 86400_000_000_000L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 501), NANOS, 1 + 86400_000_000_000L}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 39, 499), SECONDS, -2 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 39, 500), SECONDS, -1 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 39, 501), SECONDS, -1 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 499), SECONDS, -1 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 500), SECONDS, 0 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 501), SECONDS, 0 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 41, 499), SECONDS, 0 + 86400L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 41, 500), SECONDS, 1 + 86400L}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 29, 40, 499), MINUTES, -2 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 29, 40, 500), MINUTES, -1 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 29, 40, 501), MINUTES, -1 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 499), MINUTES, -1 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 500), MINUTES, 0 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 501), MINUTES, 0 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 31, 40, 499), MINUTES, 0 + 24 * 60L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 31, 40, 500), MINUTES, 1 + 24 * 60L}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 11, 30, 40, 499), HOURS, -2 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 11, 30, 40, 500), HOURS, -1 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 11, 30, 40, 501), HOURS, -1 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 499), HOURS, -1 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 500), HOURS, 0 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 501), HOURS, 0 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 13, 30, 40, 499), HOURS, 0 + 24L}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 13, 30, 40, 500), HOURS, 1 + 24L}, + + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 13, 12, 30, 40, 499), DAYS, -2}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 13, 12, 30, 40, 500), DAYS, -2}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 13, 12, 30, 40, 501), DAYS, -1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 14, 12, 30, 40, 499), DAYS, -1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 14, 12, 30, 40, 500), DAYS, -1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 14, 12, 30, 40, 501), DAYS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 499), DAYS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 500), DAYS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 15, 12, 30, 40, 501), DAYS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 499), DAYS, 0}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 500), DAYS, 1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 16, 12, 30, 40, 501), DAYS, 1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 17, 12, 30, 40, 499), DAYS, 1}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 17, 12, 30, 40, 500), DAYS, 2}, + {dt(2000, 1, 15, 12, 30, 40, 500), dt(2000, 1, 17, 12, 30, 40, 501), DAYS, 2}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(LocalDateTime dt1, LocalDateTime dt2, TemporalUnit unit, long expected) { + long amount = dt1.periodUntil(dt2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(LocalDateTime dt1, LocalDateTime dt2, TemporalUnit unit, long expected) { + long amount = dt2.periodUntil(dt1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_2007_07_15_12_30_40_987654321.periodUntil(null, HOURS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_2007_07_15_12_30_40_987654321.periodUntil(TEST_2007_07_15_12_30_40_987654321, null); + } + + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); + String t = LocalDateTime.of(2010, 12, 3, 11, 30, 45).format(f); + assertEquals(t, "2010 12 3 11 30 45"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + LocalDateTime.of(2010, 12, 3, 11, 30, 45).format(null); + } + //----------------------------------------------------------------------- // atOffset() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atOffset() { LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30); assertEquals(t.atOffset(OFFSET_PTWO), OffsetDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), OFFSET_PTWO)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atOffset_nullZoneOffset() { LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30); t.atOffset((ZoneOffset) null); @@ -2684,34 +2912,34 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // atZone() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atZone() { LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30); assertEquals(t.atZone(ZONE_PARIS), ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), ZONE_PARIS)); } - @Test(groups={"tck"}) + @Test public void test_atZone_Offset() { LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30); assertEquals(t.atZone(OFFSET_PTWO), ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), OFFSET_PTWO)); } - @Test(groups={"tck"}) + @Test public void test_atZone_dstGap() { LocalDateTime t = LocalDateTime.of(2007, 4, 1, 0, 0); assertEquals(t.atZone(ZONE_GAZA), ZonedDateTime.of(LocalDateTime.of(2007, 4, 1, 1, 0), ZONE_GAZA)); } - @Test(groups={"tck"}) + @Test public void test_atZone_dstOverlap() { LocalDateTime t = LocalDateTime.of(2007, 10, 28, 2, 30); assertEquals(t.atZone(ZONE_PARIS), ZonedDateTime.ofStrict(LocalDateTime.of(2007, 10, 28, 2, 30), OFFSET_PTWO, ZONE_PARIS)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atZone_nullTimeZone() { LocalDateTime t = LocalDateTime.of(2008, 6, 30, 11, 30); t.atZone((ZoneId) null); @@ -2720,7 +2948,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // toEpochSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_afterEpoch() { for (int i = -5; i < 5; i++) { ZoneOffset offset = ZoneOffset.ofHours(i); @@ -2731,7 +2959,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_beforeEpoch() { for (int i = 0; i < 100000; i++) { LocalDateTime a = LocalDateTime.of(1970, 1, 1, 0, 0).minusSeconds(i); @@ -2742,22 +2970,22 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { test_comparisons_LocalDateTime( - LocalDate.of(Year.MIN_VALUE, 1, 1), - LocalDate.of(Year.MIN_VALUE, 12, 31), - LocalDate.of(-1, 1, 1), - LocalDate.of(-1, 12, 31), - LocalDate.of(0, 1, 1), - LocalDate.of(0, 12, 31), - LocalDate.of(1, 1, 1), - LocalDate.of(1, 12, 31), - LocalDate.of(2008, 1, 1), - LocalDate.of(2008, 2, 29), - LocalDate.of(2008, 12, 31), - LocalDate.of(Year.MAX_VALUE, 1, 1), - LocalDate.of(Year.MAX_VALUE, 12, 31) + LocalDate.of(Year.MIN_VALUE, 1, 1), + LocalDate.of(Year.MIN_VALUE, 12, 31), + LocalDate.of(-1, 1, 1), + LocalDate.of(-1, 12, 31), + LocalDate.of(0, 1, 1), + LocalDate.of(0, 12, 31), + LocalDate.of(1, 1, 1), + LocalDate.of(1, 12, 31), + LocalDate.of(2008, 1, 1), + LocalDate.of(2008, 2, 29), + LocalDate.of(2008, 12, 31), + LocalDate.of(Year.MAX_VALUE, 1, 1), + LocalDate.of(Year.MAX_VALUE, 12, 31) ); } @@ -2823,22 +3051,22 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { TEST_2007_07_15_12_30_40_987654321.compareTo(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_ObjectNull() { TEST_2007_07_15_12_30_40_987654321.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_ObjectNull() { TEST_2007_07_15_12_30_40_987654321.isAfter(null); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({"unchecked", "rawtypes"}) public void compareToNonLocalDateTime() { Comparable c = TEST_2007_07_15_12_30_40_987654321; @@ -2883,73 +3111,73 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_true(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d, h, mi, s, n); assertTrue(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_year_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y + 1, m, d, h, mi, s, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_month_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m + 1, d, h, mi, s, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_day_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d + 1, h, mi, s, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_hour_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d, h + 1, mi, s, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_minute_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d, h, mi + 1, s, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_second_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d, h, mi, s + 1, n); assertFalse(a.equals(b)); } - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_equals_false_nano_differs(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); LocalDateTime b = LocalDateTime.of(y, m, d, h, mi, s, n + 1); assertFalse(a.equals(b)); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_2007_07_15_12_30_40_987654321.equals(TEST_2007_07_15_12_30_40_987654321), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_2007_07_15_12_30_40_987654321.equals("2007-07-15T12:30:40.987654321"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_2007_07_15_12_30_40_987654321.equals(null), false); } @@ -2957,7 +3185,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDateTimes", groups={"tck"}) + @Test(dataProvider="sampleDateTimes") public void test_hashCode(int y, int m, int d, int h, int mi, int s, int n) { LocalDateTime a = LocalDateTime.of(y, m, d, h, mi, s, n); assertEquals(a.hashCode(), a.hashCode()); @@ -2979,26 +3207,23 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int y, int m, int d, int h, int mi, int s, int n, String expected) { LocalDateTime t = LocalDateTime.of(y, m, d, h, mi, s, n); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); - String t = LocalDateTime.of(2010, 12, 3, 11, 30, 45).toString(f); - assertEquals(t, "2010 12 3 11 30 45"); + private LocalDateTime dtNoon(int year, int month, int day) { + return LocalDateTime.of(year, month, day, 12, 0); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - LocalDateTime.of(2010, 12, 3, 11, 30, 45).toString(null); + private LocalDateTime dtEpoch(int hour, int min, int sec, int nano) { + return LocalDateTime.of(1970, 1, 1, hour, min, sec, nano); + } + + private LocalDateTime dt(int year, int month, int day, int hour, int min, int sec, int nano) { + return LocalDateTime.of(year, month, day, hour, min, sec, nano); } } diff --git a/jdk/test/java/time/tck/java/time/TCKLocalTime.java b/jdk/test/java/time/tck/java/time/TCKLocalTime.java index 9b4d65f4938..72d52a24afe 100644 --- a/jdk/test/java/time/tck/java/time/TCKLocalTime.java +++ b/jdk/test/java/time/tck/java/time/TCKLocalTime.java @@ -76,6 +76,7 @@ import static java.time.temporal.ChronoField.SECOND_OF_DAY; import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; import static java.time.temporal.ChronoUnit.DAYS; import static java.time.temporal.ChronoUnit.FOREVER; +import static java.time.temporal.ChronoUnit.HALF_DAYS; import static java.time.temporal.ChronoUnit.HOURS; import static java.time.temporal.ChronoUnit.MICROS; import static java.time.temporal.ChronoUnit.MILLIS; @@ -99,16 +100,17 @@ import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.OffsetDateTime; import java.time.OffsetTime; import java.time.Period; import java.time.ZoneId; import java.time.ZoneOffset; +import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -116,6 +118,7 @@ import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; @@ -133,6 +136,7 @@ import org.testng.annotations.Test; public class TCKLocalTime extends AbstractDateTimeTest { private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); + private static final ZoneId ZONE_PARIS = ZoneId.of("Europe/Paris"); private LocalTime TEST_12_30_40_987654321; @@ -142,7 +146,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { INVALID_UNITS = (TemporalUnit[]) set.toArray(new TemporalUnit[set.size()]); } - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_12_30_40_987654321 = LocalTime.of(12, 30, 40, 987654321); } @@ -258,7 +262,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // constants //----------------------------------------------------------------------- - @Test(groups={"tck","implementation"}) + @Test public void constant_MIDNIGHT() { check(LocalTime.MIDNIGHT, 0, 0, 0, 0); } @@ -281,7 +285,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { LocalTime expected = LocalTime.now(Clock.systemDefaultZone()); LocalTime test = LocalTime.now(); @@ -292,12 +296,12 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { LocalTime.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); LocalTime expected = LocalTime.now(Clock.system(zone)); @@ -315,12 +319,12 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { LocalTime.now((Clock) null); } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -333,7 +337,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_beforeEpoch() { for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -347,7 +351,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock_max() { Clock clock = Clock.fixed(Instant.MAX, ZoneOffset.UTC); LocalTime test = LocalTime.now(clock); @@ -357,7 +361,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { assertEquals(test.getNano(), 999_999_999); } - @Test(groups={"tck"}) + @Test public void now_Clock_min() { Clock clock = Clock.fixed(Instant.MIN, ZoneOffset.UTC); LocalTime test = LocalTime.now(clock); @@ -370,71 +374,71 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // of() factories //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_time_2ints() { LocalTime test = LocalTime.of(12, 30); check(test, 12, 30, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_2ints_hourTooLow() { LocalTime.of(-1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_2ints_hourTooHigh() { LocalTime.of(24, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_2ints_minuteTooLow() { LocalTime.of(0, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_2ints_minuteTooHigh() { LocalTime.of(0, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_time_3ints() { LocalTime test = LocalTime.of(12, 30, 40); check(test, 12, 30, 40, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_hourTooLow() { LocalTime.of(-1, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_hourTooHigh() { LocalTime.of(24, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_minuteTooLow() { LocalTime.of(0, -1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_minuteTooHigh() { LocalTime.of(0, 60, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_secondTooLow() { LocalTime.of(0, 0, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_3ints_secondTooHigh() { LocalTime.of(0, 0, 60); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_time_4ints() { LocalTime test = LocalTime.of(12, 30, 40, 987654321); check(test, 12, 30, 40, 987654321); @@ -442,42 +446,42 @@ public class TCKLocalTime extends AbstractDateTimeTest { check(test, 12, 0, 40, 987654321); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_hourTooLow() { LocalTime.of(-1, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_hourTooHigh() { LocalTime.of(24, 0, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_minuteTooLow() { LocalTime.of(0, -1, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_minuteTooHigh() { LocalTime.of(0, 60, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_secondTooLow() { LocalTime.of(0, 0, -1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_secondTooHigh() { LocalTime.of(0, 0, 60, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_nanoTooLow() { LocalTime.of(0, 0, 0, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_time_4ints_nanoTooHigh() { LocalTime.of(0, 0, 0, 1000000000); } @@ -485,18 +489,18 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // ofSecondOfDay(long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofSecondOfDay() { LocalTime localTime = LocalTime.ofSecondOfDay(2 * 60 * 60 + 17 * 60 + 23); check(localTime, 2, 17, 23, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofSecondOfDay_tooLow() { LocalTime.ofSecondOfDay(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofSecondOfDay_tooHigh() { LocalTime.ofSecondOfDay(24 * 60 * 60); } @@ -504,18 +508,18 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // ofNanoOfDay(long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofNanoOfDay() { LocalTime localTime = LocalTime.ofNanoOfDay(60 * 60 * 1000000000L + 17); check(localTime, 1, 0, 0, 17); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofNanoOfDay_tooLow() { LocalTime.ofNanoOfDay(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofNanoOfDay_tooHigh() { LocalTime.ofNanoOfDay(24 * 60 * 60 * 1000000000L); } @@ -523,18 +527,18 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // from() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_from_TemporalAccessor() { assertEquals(LocalTime.from(LocalTime.of(17, 30)), LocalTime.of(17, 30)); assertEquals(LocalTime.from(LocalDateTime.of(2012, 5, 1, 17, 30)), LocalTime.of(17, 30)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_from_TemporalAccessor_invalid_noDerive() { LocalTime.from(LocalDate.of(2007, 7, 15)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_from_TemporalAccessor_null() { LocalTime.from((TemporalAccessor) null); } @@ -542,7 +546,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse() //----------------------------------------------------------------------- - @Test(dataProvider = "sampleToString", groups={"tck"}) + @Test(dataProvider = "sampleToString") public void factory_parse_validText(int h, int m, int s, int n, String parsable) { LocalTime t = LocalTime.parse(parsable); assertNotNull(t, parsable); @@ -567,29 +571,29 @@ public class TCKLocalTime extends AbstractDateTimeTest { }; } - @Test(dataProvider = "sampleBadParse", expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(dataProvider = "sampleBadParse", expectedExceptions={DateTimeParseException.class}) public void factory_parse_invalidText(String unparsable) { LocalTime.parse(unparsable); } //-----------------------------------------------------------------------s - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalHour() { LocalTime.parse("25:00"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalMinute() { LocalTime.parse("12:60"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalSecond() { LocalTime.parse("12:12:60"); } //-----------------------------------------------------------------------s - @Test(expectedExceptions = {NullPointerException.class}, groups={"tck"}) + @Test(expectedExceptions = {NullPointerException.class}) public void factory_parse_nullTest() { LocalTime.parse((String) null); } @@ -597,20 +601,20 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); LocalTime test = LocalTime.parse("14 30 40", f); assertEquals(test, LocalTime.of(14, 30, 40)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); LocalTime.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { LocalTime.parse("ANY", null); } @@ -656,13 +660,13 @@ public class TCKLocalTime extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_12_30_40_987654321, Queries.chronology(), null}, - {TEST_12_30_40_987654321, Queries.zoneId(), null}, - {TEST_12_30_40_987654321, Queries.precision(), ChronoUnit.NANOS}, - {TEST_12_30_40_987654321, Queries.zone(), null}, - {TEST_12_30_40_987654321, Queries.offset(), null}, - {TEST_12_30_40_987654321, Queries.localDate(), null}, - {TEST_12_30_40_987654321, Queries.localTime(), TEST_12_30_40_987654321}, + {TEST_12_30_40_987654321, TemporalQuery.chronology(), null}, + {TEST_12_30_40_987654321, TemporalQuery.zoneId(), null}, + {TEST_12_30_40_987654321, TemporalQuery.precision(), ChronoUnit.NANOS}, + {TEST_12_30_40_987654321, TemporalQuery.zone(), null}, + {TEST_12_30_40_987654321, TemporalQuery.offset(), null}, + {TEST_12_30_40_987654321, TemporalQuery.localDate(), null}, + {TEST_12_30_40_987654321, TemporalQuery.localTime(), TEST_12_30_40_987654321}, }; } @@ -707,7 +711,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_get(int h, int m, int s, int ns) { LocalTime a = LocalTime.of(h, m, s, ns); assertEquals(a.getHour(), h); @@ -716,10 +720,54 @@ public class TCKLocalTime extends AbstractDateTimeTest { assertEquals(a.getNano(), ns); } + //----------------------------------------------------------------------- + // adjustInto(Temporal) + //----------------------------------------------------------------------- + @DataProvider(name="adjustInto") + Object[][] data_adjustInto() { + return new Object[][]{ + {LocalTime.of(23, 5), LocalTime.of(4, 1, 1, 100), LocalTime.of(23, 5, 0, 0), null}, + {LocalTime.of(23, 5, 20), LocalTime.of(4, 1, 1, 100), LocalTime.of(23, 5, 20, 0), null}, + {LocalTime.of(23, 5, 20, 1000), LocalTime.of(4, 1, 1, 100), LocalTime.of(23, 5, 20, 1000), null}, + {LocalTime.of(23, 5, 20, 1000), LocalTime.MAX, LocalTime.of(23, 5, 20, 1000), null}, + {LocalTime.of(23, 5, 20, 1000), LocalTime.MIN, LocalTime.of(23, 5, 20, 1000), null}, + {LocalTime.of(23, 5, 20, 1000), LocalTime.NOON, LocalTime.of(23, 5, 20, 1000), null}, + {LocalTime.of(23, 5, 20, 1000), LocalTime.MIDNIGHT, LocalTime.of(23, 5, 20, 1000), null}, + {LocalTime.MAX, LocalTime.of(23, 5, 20, 1000), LocalTime.of(23, 59, 59, 999999999), null}, + {LocalTime.MIN, LocalTime.of(23, 5, 20, 1000), LocalTime.of(0, 0, 0), null}, + {LocalTime.NOON, LocalTime.of(23, 5, 20, 1000), LocalTime.of(12, 0, 0), null}, + {LocalTime.MIDNIGHT, LocalTime.of(23, 5, 20, 1000), LocalTime.of(0, 0, 0), null}, + + {LocalTime.of(23, 5), LocalDateTime.of(2210, 2, 2, 1, 1), LocalDateTime.of(2210, 2, 2, 23, 5), null}, + {LocalTime.of(23, 5), OffsetTime.of(1, 1, 0, 0, OFFSET_PTWO), OffsetTime.of(23, 5, 0, 0, OFFSET_PTWO), null}, + {LocalTime.of(23, 5), OffsetDateTime.of(2210, 2, 2, 1, 1, 0, 0, OFFSET_PTWO), OffsetDateTime.of(2210, 2, 2, 23, 5, 0, 0, OFFSET_PTWO), null}, + {LocalTime.of(23, 5), ZonedDateTime.of(2210, 2, 2, 1, 1, 0, 0, ZONE_PARIS), ZonedDateTime.of(2210, 2, 2, 23, 5, 0, 0, ZONE_PARIS), null}, + + {LocalTime.of(23, 5), LocalDate.of(2210, 2, 2), null, DateTimeException.class}, + {LocalTime.of(23, 5), null, null, NullPointerException.class}, + + }; + } + + @Test(dataProvider="adjustInto") + public void test_adjustInto(LocalTime test, Temporal temporal, Temporal expected, Class expectedEx) { + if (expectedEx == null) { + Temporal result = test.adjustInto(temporal); + assertEquals(result, expected); + } else { + try { + Temporal result = test.adjustInto(temporal); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + //----------------------------------------------------------------------- // with() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_adjustment() { final LocalTime sample = LocalTime.of(23, 5); TemporalAdjuster adjuster = new TemporalAdjuster() { @@ -731,7 +779,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { assertEquals(TEST_12_30_40_987654321.with(adjuster), sample); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_adjustment_null() { TEST_12_30_40_987654321.with((TemporalAdjuster) null); } @@ -739,7 +787,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withHour() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withHour_normal() { LocalTime t = TEST_12_30_40_987654321; for (int i = 0; i < 24; i++) { @@ -748,30 +796,30 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_withHour_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.withHour(12); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_withHour_toMidnight_equal() { LocalTime t = LocalTime.of(1, 0).withHour(0); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_withHour_toMidday_equal() { LocalTime t = LocalTime.of(1, 0).withHour(12); assertEquals(t, LocalTime.NOON); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withHour_hourTooLow() { TEST_12_30_40_987654321.withHour(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withHour_hourTooHigh() { TEST_12_30_40_987654321.withHour(24); } @@ -779,7 +827,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withMinute() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMinute_normal() { LocalTime t = TEST_12_30_40_987654321; for (int i = 0; i < 60; i++) { @@ -788,30 +836,30 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_withMinute_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.withMinute(30); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_withMinute_toMidnight_equal() { LocalTime t = LocalTime.of(0, 1).withMinute(0); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_withMinute_toMidday_equals() { LocalTime t = LocalTime.of(12, 1).withMinute(0); assertEquals(t, LocalTime.NOON); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMinute_minuteTooLow() { TEST_12_30_40_987654321.withMinute(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMinute_minuteTooHigh() { TEST_12_30_40_987654321.withMinute(60); } @@ -819,7 +867,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withSecond_normal() { LocalTime t = TEST_12_30_40_987654321; for (int i = 0; i < 60; i++) { @@ -828,30 +876,30 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_withSecond_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.withSecond(40); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_withSecond_toMidnight_equal() { LocalTime t = LocalTime.of(0, 0, 1).withSecond(0); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_withSecond_toMidday_equal() { LocalTime t = LocalTime.of(12, 0, 1).withSecond(0); assertEquals(t, LocalTime.NOON); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withSecond_secondTooLow() { TEST_12_30_40_987654321.withSecond(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withSecond_secondTooHigh() { TEST_12_30_40_987654321.withSecond(60); } @@ -859,7 +907,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withNano() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_normal() { LocalTime t = TEST_12_30_40_987654321; t = t.withNano(1); @@ -872,30 +920,30 @@ public class TCKLocalTime extends AbstractDateTimeTest { assertEquals(t.getNano(), 999999999); } - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.withNano(987654321); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_toMidnight_equal() { LocalTime t = LocalTime.of(0, 0, 0, 1).withNano(0); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_toMidday_equal() { LocalTime t = LocalTime.of(12, 0, 0, 1).withNano(0); assertEquals(t, LocalTime.NOON); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withNanoOfSecond_nanoTooLow() { TEST_12_30_40_987654321.withNano(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withNanoOfSecond_nanoTooHigh() { TEST_12_30_40_987654321.withNano(1000000000); } @@ -974,7 +1022,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { }; } - @Test(groups={"tck"}, dataProvider="truncatedToValid") + @Test(dataProvider="truncatedToValid") public void test_truncatedTo_valid(LocalTime input, TemporalUnit unit, LocalTime expected) { assertEquals(input.truncatedTo(unit), expected); } @@ -989,12 +1037,12 @@ public class TCKLocalTime extends AbstractDateTimeTest { }; } - @Test(groups={"tck"}, dataProvider="truncatedToInvalid", expectedExceptions=DateTimeException.class) + @Test(dataProvider="truncatedToInvalid", expectedExceptions=DateTimeException.class) public void test_truncatedTo_invalid(LocalTime input, TemporalUnit unit) { input.truncatedTo(unit); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_12_30_40_987654321.truncatedTo(null); } @@ -1044,25 +1092,25 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_positiveHours() { LocalTime t = TEST_12_30_40_987654321.plus(7, ChronoUnit.HOURS); assertEquals(t, LocalTime.of(19, 30, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_negativeMinutes() { LocalTime t = TEST_12_30_40_987654321.plus(-25, ChronoUnit.MINUTES); assertEquals(t, LocalTime.of(12, 5, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_zero() { LocalTime t = TEST_12_30_40_987654321.plus(0, ChronoUnit.MINUTES); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_invalidUnit() { for (TemporalUnit unit : INVALID_UNITS) { try { @@ -1074,7 +1122,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plus_longTemporalUnit_multiples() { assertEquals(TEST_12_30_40_987654321.plus(0, DAYS), TEST_12_30_40_987654321); assertEquals(TEST_12_30_40_987654321.plus(1, DAYS), TEST_12_30_40_987654321); @@ -1082,7 +1130,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { assertEquals(TEST_12_30_40_987654321.plus(-3, DAYS), TEST_12_30_40_987654321); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_longTemporalUnit_null() { TEST_12_30_40_987654321.plus(1, (TemporalUnit) null); } @@ -1090,7 +1138,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusHours_one() { LocalTime t = LocalTime.MIDNIGHT; for (int i = 0; i < 50; i++) { @@ -1099,7 +1147,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plusHours_fromZero() { LocalTime base = LocalTime.MIDNIGHT; for (int i = -50; i < 50; i++) { @@ -1108,7 +1156,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plusHours_fromOne() { LocalTime base = LocalTime.of(1, 0); for (int i = -50; i < 50; i++) { @@ -1117,25 +1165,25 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plusHours_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.plusHours(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusHours_toMidnight_equal() { LocalTime t = LocalTime.of(23, 0).plusHours(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_plusHours_toMidday_equal() { LocalTime t = LocalTime.of(11, 0).plusHours(1); assertEquals(t, LocalTime.NOON); } - @Test(groups={"tck"}) + @Test public void test_plusHours_big() { LocalTime t = LocalTime.of(2, 30).plusHours(Long.MAX_VALUE); int hours = (int) (Long.MAX_VALUE % 24L); @@ -1145,7 +1193,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMinutes_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1162,7 +1210,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_fromZero() { LocalTime base = LocalTime.MIDNIGHT; int hour; @@ -1187,31 +1235,31 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.plusMinutes(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.plusMinutes(24 * 60); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_toMidnight_equal() { LocalTime t = LocalTime.of(23, 59).plusMinutes(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_toMidday_equal() { LocalTime t = LocalTime.of(11, 59).plusMinutes(1); assertEquals(t, LocalTime.NOON); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_big() { LocalTime t = LocalTime.of(2, 30).plusMinutes(Long.MAX_VALUE); int mins = (int) (Long.MAX_VALUE % (24L * 60L)); @@ -1221,7 +1269,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusSeconds_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1285,7 +1333,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="plusSeconds_fromZero", groups={"tck"}) + @Test(dataProvider="plusSeconds_fromZero") public void test_plusSeconds_fromZero(int seconds, int hour, int min, int sec) { LocalTime base = LocalTime.MIDNIGHT; LocalTime t = base.plusSeconds(seconds); @@ -1295,25 +1343,25 @@ public class TCKLocalTime extends AbstractDateTimeTest { assertEquals(sec, t.getSecond()); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.plusSeconds(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.plusSeconds(24 * 60 * 60); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_toMidnight_equal() { LocalTime t = LocalTime.of(23, 59, 59).plusSeconds(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_toMidday_equal() { LocalTime t = LocalTime.of(11, 59, 59).plusSeconds(1); assertEquals(t, LocalTime.NOON); @@ -1322,7 +1370,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusNanos_halfABillion() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1398,7 +1446,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="plusNanos_fromZero", groups={"tck"}) + @Test(dataProvider="plusNanos_fromZero") public void test_plusNanos_fromZero(long nanoseconds, int hour, int min, int sec, int nanos) { LocalTime base = LocalTime.MIDNIGHT; LocalTime t = base.plusNanos(nanoseconds); @@ -1409,25 +1457,25 @@ public class TCKLocalTime extends AbstractDateTimeTest { assertEquals(nanos, t.getNano()); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.plusNanos(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.plusNanos(24 * 60 * 60 * 1000000000L); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_toMidnight_equal() { LocalTime t = LocalTime.of(23, 59, 59, 999999999).plusNanos(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_toMidday_equal() { LocalTime t = LocalTime.of(11, 59, 59, 999999999).plusNanos(1); assertEquals(t, LocalTime.NOON); @@ -1478,25 +1526,25 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_positiveHours() { LocalTime t = TEST_12_30_40_987654321.minus(7, ChronoUnit.HOURS); assertEquals(t, LocalTime.of(5, 30, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_negativeMinutes() { LocalTime t = TEST_12_30_40_987654321.minus(-25, ChronoUnit.MINUTES); assertEquals(t, LocalTime.of(12, 55, 40, 987654321)); } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_zero() { LocalTime t = TEST_12_30_40_987654321.minus(0, ChronoUnit.MINUTES); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_invalidUnit() { for (TemporalUnit unit : INVALID_UNITS) { try { @@ -1508,7 +1556,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minus_longTemporalUnit_long_multiples() { assertEquals(TEST_12_30_40_987654321.minus(0, DAYS), TEST_12_30_40_987654321); assertEquals(TEST_12_30_40_987654321.minus(1, DAYS), TEST_12_30_40_987654321); @@ -1516,7 +1564,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { assertEquals(TEST_12_30_40_987654321.minus(-3, DAYS), TEST_12_30_40_987654321); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_longTemporalUnit_null() { TEST_12_30_40_987654321.minus(1, (TemporalUnit) null); } @@ -1524,7 +1572,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusHours_one() { LocalTime t = LocalTime.MIDNIGHT; for (int i = 0; i < 50; i++) { @@ -1533,7 +1581,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minusHours_fromZero() { LocalTime base = LocalTime.MIDNIGHT; for (int i = -50; i < 50; i++) { @@ -1542,7 +1590,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minusHours_fromOne() { LocalTime base = LocalTime.of(1, 0); for (int i = -50; i < 50; i++) { @@ -1551,25 +1599,25 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minusHours_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.minusHours(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusHours_toMidnight_equal() { LocalTime t = LocalTime.of(1, 0).minusHours(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_minusHours_toMidday_equal() { LocalTime t = LocalTime.of(13, 0).minusHours(1); assertEquals(t, LocalTime.NOON); } - @Test(groups={"tck"}) + @Test public void test_minusHours_big() { LocalTime t = LocalTime.of(2, 30).minusHours(Long.MAX_VALUE); int hours = (int) (Long.MAX_VALUE % 24L); @@ -1579,7 +1627,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMinutes_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1600,7 +1648,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_fromZero() { LocalTime base = LocalTime.MIDNIGHT; int hour = 22; @@ -1623,31 +1671,31 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.minusMinutes(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.minusMinutes(24 * 60); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_toMidnight_equal() { LocalTime t = LocalTime.of(0, 1).minusMinutes(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_toMidday_equals() { LocalTime t = LocalTime.of(12, 1).minusMinutes(1); assertEquals(t, LocalTime.NOON); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_big() { LocalTime t = LocalTime.of(2, 30).minusMinutes(Long.MAX_VALUE); int mins = (int) (Long.MAX_VALUE % (24L * 60L)); @@ -1657,7 +1705,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusSeconds_one() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1726,7 +1774,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="minusSeconds_fromZero", groups={"tck"}) + @Test(dataProvider="minusSeconds_fromZero") public void test_minusSeconds_fromZero(int seconds, int hour, int min, int sec) { LocalTime base = LocalTime.MIDNIGHT; LocalTime t = base.minusSeconds(seconds); @@ -1736,31 +1784,31 @@ public class TCKLocalTime extends AbstractDateTimeTest { assertEquals(t.getSecond(), sec); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.minusSeconds(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.minusSeconds(24 * 60 * 60); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_toMidnight_equal() { LocalTime t = LocalTime.of(0, 0, 1).minusSeconds(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_toMidday_equal() { LocalTime t = LocalTime.of(12, 0, 1).minusSeconds(1); assertEquals(t, LocalTime.NOON); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_big() { LocalTime t = LocalTime.of(2, 30).minusSeconds(Long.MAX_VALUE); int secs = (int) (Long.MAX_VALUE % (24L * 60L * 60L)); @@ -1770,7 +1818,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusNanos_halfABillion() { LocalTime t = LocalTime.MIDNIGHT; int hour = 0; @@ -1854,7 +1902,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="minusNanos_fromZero", groups={"tck"}) + @Test(dataProvider="minusNanos_fromZero") public void test_minusNanos_fromZero(long nanoseconds, int hour, int min, int sec, int nanos) { LocalTime base = LocalTime.MIDNIGHT; LocalTime t = base.minusNanos(nanoseconds); @@ -1865,40 +1913,121 @@ public class TCKLocalTime extends AbstractDateTimeTest { assertEquals(nanos, t.getNano()); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_noChange_equal() { LocalTime t = TEST_12_30_40_987654321.minusNanos(0); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_noChange_oneDay_equal() { LocalTime t = TEST_12_30_40_987654321.minusNanos(24 * 60 * 60 * 1000000000L); assertEquals(t, TEST_12_30_40_987654321); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_toMidnight_equal() { LocalTime t = LocalTime.of(0, 0, 0, 1).minusNanos(1); assertEquals(t, LocalTime.MIDNIGHT); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_toMidday_equal() { LocalTime t = LocalTime.of(12, 0, 0, 1).minusNanos(1); assertEquals(t, LocalTime.NOON); } + //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + {time(0, 0, 0, 0), time(0, 0, 0, 0), NANOS, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), MICROS, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), MILLIS, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), SECONDS, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), MINUTES, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), HOURS, 0}, + {time(0, 0, 0, 0), time(0, 0, 0, 0), HALF_DAYS, 0}, + + {time(0, 0, 0, 0), time(2, 0, 0, 0), NANOS, 2 * 3600 * 1_000_000_000L}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), MICROS, 2 * 3600 * 1_000_000L}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), MILLIS, 2 * 3600 * 1_000L}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), SECONDS, 2 * 3600}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), MINUTES, 2 * 60}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), HOURS, 2}, + {time(0, 0, 0, 0), time(2, 0, 0, 0), HALF_DAYS, 0}, + + {time(0, 0, 0, 0), time(14, 0, 0, 0), NANOS, 14 * 3600 * 1_000_000_000L}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), MICROS, 14 * 3600 * 1_000_000L}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), MILLIS, 14 * 3600 * 1_000L}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), SECONDS, 14 * 3600}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), MINUTES, 14 * 60}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), HOURS, 14}, + {time(0, 0, 0, 0), time(14, 0, 0, 0), HALF_DAYS, 1}, + + {time(0, 0, 0, 0), time(2, 30, 40, 1500), NANOS, (2 * 3600 + 30 * 60 + 40) * 1_000_000_000L + 1500}, + {time(0, 0, 0, 0), time(2, 30, 40, 1500), MICROS, (2 * 3600 + 30 * 60 + 40) * 1_000_000L + 1}, + {time(0, 0, 0, 0), time(2, 30, 40, 1500), MILLIS, (2 * 3600 + 30 * 60 + 40) * 1_000L}, + {time(0, 0, 0, 0), time(2, 30, 40, 1500), SECONDS, 2 * 3600 + 30 * 60 + 40}, + {time(0, 0, 0, 0), time(2, 30, 40, 1500), MINUTES, 2 * 60 + 30}, + {time(0, 0, 0, 0), time(2, 30, 40, 1500), HOURS, 2}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(LocalTime time1, LocalTime time2, TemporalUnit unit, long expected) { + long amount = time1.periodUntil(time2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(LocalTime time1, LocalTime time2, TemporalUnit unit, long expected) { + long amount = time2.periodUntil(time1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = UnsupportedTemporalTypeException.class) + public void test_periodUntil_TemporalUnit_unsupportedUnit() { + TEST_12_30_40_987654321.periodUntil(TEST_12_30_40_987654321, DAYS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_12_30_40_987654321.periodUntil(null, HOURS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_12_30_40_987654321.periodUntil(TEST_12_30_40_987654321, null); + } + + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); + String t = LocalTime.of(11, 30, 45).format(f); + assertEquals(t, "11 30 45"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + LocalTime.of(11, 30, 45).format(null); + } + //----------------------------------------------------------------------- // atDate() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atDate() { LocalTime t = LocalTime.of(11, 30); assertEquals(t.atDate(LocalDate.of(2012, 6, 30)), LocalDateTime.of(2012, 6, 30, 11, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atDate_nullDate() { TEST_12_30_40_987654321.atDate((LocalDate) null); } @@ -1906,13 +2035,13 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // atOffset() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atOffset() { LocalTime t = LocalTime.of(11, 30); assertEquals(t.atOffset(OFFSET_PTWO), OffsetTime.of(LocalTime.of(11, 30), OFFSET_PTWO)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atOffset_nullZoneOffset() { LocalTime t = LocalTime.of(11, 30); t.atOffset((ZoneOffset) null); @@ -1921,7 +2050,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // toSecondOfDay() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toSecondOfDay() { LocalTime t = LocalTime.of(0, 0); for (int i = 0; i < 24 * 60 * 60; i++) { @@ -1930,7 +2059,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_toSecondOfDay_fromNanoOfDay_symmetry() { LocalTime t = LocalTime.of(0, 0); for (int i = 0; i < 24 * 60 * 60; i++) { @@ -1942,7 +2071,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // toNanoOfDay() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toNanoOfDay() { LocalTime t = LocalTime.of(0, 0); for (int i = 0; i < 1000000; i++) { @@ -1956,7 +2085,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_toNanoOfDay_fromNanoOfDay_symmetry() { LocalTime t = LocalTime.of(0, 0); for (int i = 0; i < 1000000; i++) { @@ -1973,7 +2102,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { doTest_comparisons_LocalTime( LocalTime.MIDNIGHT, @@ -2028,22 +2157,22 @@ public class TCKLocalTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { TEST_12_30_40_987654321.compareTo(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_ObjectNull() { TEST_12_30_40_987654321.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_ObjectNull() { TEST_12_30_40_987654321.isAfter(null); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({"unchecked", "rawtypes"}) public void compareToNonLocalTime() { Comparable c = TEST_12_30_40_987654321; @@ -2053,48 +2182,48 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_true(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s, n); assertEquals(a.equals(b), true); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_hour_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h + 1, m, s, n); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_minute_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m + 1, s, n); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_second_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s + 1, n); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_nano_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s, n + 1); assertEquals(a.equals(b), false); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_12_30_40_987654321.equals(TEST_12_30_40_987654321), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_12_30_40_987654321.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_12_30_40_987654321.equals(null), false); } @@ -2102,35 +2231,35 @@ public class TCKLocalTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_hashCode_same(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s, n); assertEquals(a.hashCode(), b.hashCode()); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_hashCode_hour_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h + 1, m, s, n); assertEquals(a.hashCode() == b.hashCode(), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_hashCode_minute_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m + 1, s, n); assertEquals(a.hashCode() == b.hashCode(), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_hashCode_second_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s + 1, n); assertEquals(a.hashCode() == b.hashCode(), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_hashCode_nano_differs(int h, int m, int s, int n) { LocalTime a = LocalTime.of(h, m, s, n); LocalTime b = LocalTime.of(h, m, s, n + 1); @@ -2172,26 +2301,14 @@ public class TCKLocalTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int h, int m, int s, int n, String expected) { LocalTime t = LocalTime.of(h, m, s, n); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); - String t = LocalTime.of(11, 30, 45).toString(f); - assertEquals(t, "11 30 45"); + private LocalTime time(int hour, int min, int sec, int nano) { + return LocalTime.of(hour, min, sec, nano); } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - LocalTime.of(11, 30, 45).toString(null); - } - } diff --git a/jdk/test/java/time/tck/java/time/TCKMonth.java b/jdk/test/java/time/tck/java/time/TCKMonth.java index c5160c1c286..77e9eef7a96 100644 --- a/jdk/test/java/time/tck/java/time/TCKMonth.java +++ b/jdk/test/java/time/tck/java/time/TCKMonth.java @@ -71,7 +71,6 @@ import java.time.format.TextStyle; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -117,7 +116,7 @@ public class TCKMonth extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_singleton() { for (int i = 1; i <= MAX_LENGTH; i++) { Month test = Month.of(i); @@ -125,28 +124,28 @@ public class TCKMonth extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_tooLow() { Month.of(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_tooHigh() { Month.of(13); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(Month.from(LocalDate.of(2011, 6, 6)), Month.JUNE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { Month.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { Month.from((TemporalAccessor) null); } @@ -170,13 +169,13 @@ public class TCKMonth extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {Month.JUNE, Queries.chronology(), IsoChronology.INSTANCE}, - {Month.JUNE, Queries.zoneId(), null}, - {Month.JUNE, Queries.precision(), ChronoUnit.MONTHS}, - {Month.JUNE, Queries.zone(), null}, - {Month.JUNE, Queries.offset(), null}, - {Month.JUNE, Queries.localDate(), null}, - {Month.JUNE, Queries.localTime(), null}, + {Month.JUNE, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {Month.JUNE, TemporalQuery.zoneId(), null}, + {Month.JUNE, TemporalQuery.precision(), ChronoUnit.MONTHS}, + {Month.JUNE, TemporalQuery.zone(), null}, + {Month.JUNE, TemporalQuery.offset(), null}, + {Month.JUNE, TemporalQuery.localDate(), null}, + {Month.JUNE, TemporalQuery.localTime(), null}, }; } @@ -198,17 +197,17 @@ public class TCKMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // getText() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getText() { assertEquals(Month.JANUARY.getDisplayName(TextStyle.SHORT, Locale.US), "Jan"); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void test_getText_nullStyle() { Month.JANUARY.getDisplayName(null, Locale.US); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void test_getText_nullLocale() { Month.JANUARY.getDisplayName(TextStyle.FULL, null); } @@ -275,7 +274,7 @@ public class TCKMonth extends AbstractDateTimeTest { }; } - @Test(dataProvider="plus", groups={"tck"}) + @Test(dataProvider="plus") public void test_plus_long(int base, long amount, int expected) { assertEquals(Month.of(base).plus(amount), Month.of(expected)); } @@ -316,7 +315,7 @@ public class TCKMonth extends AbstractDateTimeTest { }; } - @Test(dataProvider="minus", groups={"tck"}) + @Test(dataProvider="minus") public void test_minus_long(int base, long amount, int expected) { assertEquals(Month.of(base).minus(amount), Month.of(expected)); } @@ -324,7 +323,7 @@ public class TCKMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // length(boolean) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_length_boolean_notLeapYear() { assertEquals(Month.JANUARY.length(false), 31); assertEquals(Month.FEBRUARY.length(false), 28); @@ -340,7 +339,7 @@ public class TCKMonth extends AbstractDateTimeTest { assertEquals(Month.DECEMBER.length(false), 31); } - @Test(groups={"tck"}) + @Test public void test_length_boolean_leapYear() { assertEquals(Month.JANUARY.length(true), 31); assertEquals(Month.FEBRUARY.length(true), 29); @@ -359,7 +358,7 @@ public class TCKMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minLength() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minLength() { assertEquals(Month.JANUARY.minLength(), 31); assertEquals(Month.FEBRUARY.minLength(), 28); @@ -378,7 +377,7 @@ public class TCKMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // maxLength() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_maxLength() { assertEquals(Month.JANUARY.maxLength(), 31); assertEquals(Month.FEBRUARY.maxLength(), 29); @@ -397,7 +396,7 @@ public class TCKMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // firstDayOfYear(boolean) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_firstDayOfYear_notLeapYear() { assertEquals(Month.JANUARY.firstDayOfYear(false), 1); assertEquals(Month.FEBRUARY.firstDayOfYear(false), 1 + 31); @@ -413,7 +412,7 @@ public class TCKMonth extends AbstractDateTimeTest { assertEquals(Month.DECEMBER.firstDayOfYear(false), 1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30); } - @Test(groups={"tck"}) + @Test public void test_firstDayOfYear_leapYear() { assertEquals(Month.JANUARY.firstDayOfYear(true), 1); assertEquals(Month.FEBRUARY.firstDayOfYear(true), 1 + 31); @@ -432,7 +431,7 @@ public class TCKMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // firstMonthOfQuarter() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_firstMonthOfQuarter() { assertEquals(Month.JANUARY.firstMonthOfQuarter(), Month.JANUARY); assertEquals(Month.FEBRUARY.firstMonthOfQuarter(), Month.JANUARY); @@ -451,7 +450,7 @@ public class TCKMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString() { assertEquals(Month.JANUARY.toString(), "JANUARY"); assertEquals(Month.FEBRUARY.toString(), "FEBRUARY"); @@ -470,7 +469,7 @@ public class TCKMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // generated methods //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_enum() { assertEquals(Month.valueOf("JANUARY"), Month.JANUARY); assertEquals(Month.values()[0], Month.JANUARY); diff --git a/jdk/test/java/time/tck/java/time/TCKMonthDay.java b/jdk/test/java/time/tck/java/time/TCKMonthDay.java index 1a80e8ce303..0bcbdef8195 100644 --- a/jdk/test/java/time/tck/java/time/TCKMonthDay.java +++ b/jdk/test/java/time/tck/java/time/TCKMonthDay.java @@ -84,7 +84,6 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -106,7 +105,7 @@ public class TCKMonthDay extends AbstractDateTimeTest { private MonthDay TEST_07_15; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_07_15 = MonthDay.of(7, 15); } @@ -164,7 +163,7 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { MonthDay expected = MonthDay.now(Clock.systemDefaultZone()); MonthDay test = MonthDay.now(); @@ -181,12 +180,12 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { MonthDay.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); MonthDay expected = MonthDay.now(Clock.system(zone)); @@ -204,7 +203,7 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock() { Instant instant = LocalDateTime.of(2010, 12, 31, 0, 0).toInstant(ZoneOffset.UTC); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); @@ -213,71 +212,71 @@ public class TCKMonthDay extends AbstractDateTimeTest { assertEquals(test.getDayOfMonth(), 31); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { MonthDay.now((Clock) null); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_intMonth() { assertEquals(TEST_07_15, MonthDay.of(Month.JULY, 15)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_intMonth_dayTooLow() { MonthDay.of(Month.JANUARY, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_intMonth_dayTooHigh() { MonthDay.of(Month.JANUARY, 32); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_intMonth_nullMonth() { MonthDay.of(null, 15); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ints() { check(TEST_07_15, 7, 15); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_dayTooLow() { MonthDay.of(1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_dayTooHigh() { MonthDay.of(1, 32); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_monthTooLow() { MonthDay.of(0, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_monthTooHigh() { MonthDay.of(13, 1); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(MonthDay.from(LocalDate.of(2007, 7, 15)), TEST_07_15); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { MonthDay.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { MonthDay.from((TemporalAccessor) null); } @@ -315,7 +314,7 @@ public class TCKMonthDay extends AbstractDateTimeTest { }; } - @Test(dataProvider="goodParseData", groups={"tck"}) + @Test(dataProvider="goodParseData") public void factory_parse_success(String text, MonthDay expected) { MonthDay monthDay = MonthDay.parse(text); assertEquals(monthDay, expected); @@ -333,7 +332,7 @@ public class TCKMonthDay extends AbstractDateTimeTest { }; } - @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class) public void factory_parse_fail(String text, int pos) { try { MonthDay.parse(text); @@ -347,22 +346,22 @@ public class TCKMonthDay extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue_Day() { MonthDay.parse("--06-32"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_invalidValue_Day() { MonthDay.parse("--06-31"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue_Month() { MonthDay.parse("--13-25"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { MonthDay.parse(null); } @@ -370,20 +369,20 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("M d"); MonthDay test = MonthDay.parse("12 3", f); assertEquals(test, MonthDay.of(12, 3)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("M d"); MonthDay.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { MonthDay.parse("ANY", null); } @@ -409,13 +408,13 @@ public class TCKMonthDay extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_07_15, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_07_15, Queries.zoneId(), null}, - {TEST_07_15, Queries.precision(), null}, - {TEST_07_15, Queries.zone(), null}, - {TEST_07_15, Queries.offset(), null}, - {TEST_07_15, Queries.localDate(), null}, - {TEST_07_15, Queries.localTime(), null}, + {TEST_07_15, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_07_15, TemporalQuery.zoneId(), null}, + {TEST_07_15, TemporalQuery.precision(), null}, + {TEST_07_15, TemporalQuery.zone(), null}, + {TEST_07_15, TemporalQuery.offset(), null}, + {TEST_07_15, TemporalQuery.localDate(), null}, + {TEST_07_15, TemporalQuery.localTime(), null}, }; } @@ -461,28 +460,28 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // with(Month) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_Month() { assertEquals(MonthDay.of(6, 30).with(Month.JANUARY), MonthDay.of(1, 30)); } - @Test(groups={"tck"}) + @Test public void test_with_Month_adjustToValid() { assertEquals(MonthDay.of(7, 31).with(Month.JUNE), MonthDay.of(6, 30)); } - @Test(groups={"tck"}) + @Test public void test_with_Month_adjustToValidFeb() { assertEquals(MonthDay.of(7, 31).with(Month.FEBRUARY), MonthDay.of(2, 29)); } - @Test(groups={"tck"}) + @Test public void test_with_Month_noChangeEqual() { MonthDay test = MonthDay.of(6, 30); assertEquals(test.with(Month.JUNE), test); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_Month_null() { MonthDay.of(6, 30).with((Month) null); } @@ -490,33 +489,33 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth() { assertEquals(MonthDay.of(6, 30).withMonth(1), MonthDay.of(1, 30)); } - @Test(groups={"tck"}) + @Test public void test_withMonth_adjustToValid() { assertEquals(MonthDay.of(7, 31).withMonth(6), MonthDay.of(6, 30)); } - @Test(groups={"tck"}) + @Test public void test_withMonth_adjustToValidFeb() { assertEquals(MonthDay.of(7, 31).withMonth(2), MonthDay.of(2, 29)); } - @Test(groups={"tck"}) + @Test public void test_withMonth_int_noChangeEqual() { MonthDay test = MonthDay.of(6, 30); assertEquals(test.withMonth(6), test); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooLow() { MonthDay.of(6, 30).withMonth(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooHigh() { MonthDay.of(6, 30).withMonth(13); } @@ -524,33 +523,33 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth() { assertEquals(MonthDay.of(6, 30).withDayOfMonth(1), MonthDay.of(6, 1)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_invalid() { MonthDay.of(6, 30).withDayOfMonth(31); } - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_adjustToValidFeb() { assertEquals(MonthDay.of(2, 1).withDayOfMonth(29), MonthDay.of(2, 29)); } - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_noChangeEqual() { MonthDay test = MonthDay.of(6, 30); assertEquals(test.withDayOfMonth(30), test); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_tooLow() { MonthDay.of(6, 30).withDayOfMonth(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_tooHigh() { MonthDay.of(6, 30).withDayOfMonth(32); } @@ -558,28 +557,28 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // adjustInto() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjustDate() { MonthDay test = MonthDay.of(6, 30); LocalDate date = LocalDate.of(2007, 1, 1); assertEquals(test.adjustInto(date), LocalDate.of(2007, 6, 30)); } - @Test(groups={"tck"}) + @Test public void test_adjustDate_resolve() { MonthDay test = MonthDay.of(2, 29); LocalDate date = LocalDate.of(2007, 6, 30); assertEquals(test.adjustInto(date), LocalDate.of(2007, 2, 28)); } - @Test(groups={"tck"}) + @Test public void test_adjustDate_equal() { MonthDay test = MonthDay.of(6, 30); LocalDate date = LocalDate.of(2007, 6, 30); assertEquals(test.adjustInto(date), date); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_adjustDate_null() { TEST_07_15.adjustInto((LocalDate) null); } @@ -587,40 +586,55 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // isValidYear(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isValidYear_june() { MonthDay test = MonthDay.of(6, 30); assertEquals(test.isValidYear(2007), true); } - @Test(groups={"tck"}) + @Test public void test_isValidYear_febNonLeap() { MonthDay test = MonthDay.of(2, 29); assertEquals(test.isValidYear(2007), false); } - @Test(groups={"tck"}) + @Test public void test_isValidYear_febLeap() { MonthDay test = MonthDay.of(2, 29); assertEquals(test.isValidYear(2008), true); } + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("M d"); + String t = MonthDay.of(12, 3).format(f); + assertEquals(t, "12 3"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + MonthDay.of(12, 3).format(null); + } + //----------------------------------------------------------------------- // atYear(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atYear_int() { MonthDay test = MonthDay.of(6, 30); assertEquals(test.atYear(2008), LocalDate.of(2008, 6, 30)); } - @Test(groups={"tck"}) + @Test public void test_atYear_int_leapYearAdjust() { MonthDay test = MonthDay.of(2, 29); assertEquals(test.atYear(2005), LocalDate.of(2005, 2, 28)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atYear_int_invalidYear() { MonthDay test = MonthDay.of(6, 30); test.atYear(Integer.MIN_VALUE); @@ -629,7 +643,7 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { doTest_comparisons_MonthDay( MonthDay.of(1, 1), @@ -666,17 +680,17 @@ public class TCKMonthDay extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { TEST_07_15.compareTo(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_ObjectNull() { TEST_07_15.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_ObjectNull() { TEST_07_15.isAfter(null); } @@ -684,7 +698,7 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { MonthDay a = MonthDay.of(1, 1); MonthDay b = MonthDay.of(1, 1); @@ -712,17 +726,17 @@ public class TCKMonthDay extends AbstractDateTimeTest { assertEquals(d.equals(d), true); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_07_15.equals(TEST_07_15), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_07_15.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_07_15.equals(null), false); } @@ -730,7 +744,7 @@ public class TCKMonthDay extends AbstractDateTimeTest { //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_hashCode(int m, int d) { MonthDay a = MonthDay.of(m, d); assertEquals(a.hashCode(), a.hashCode()); @@ -738,7 +752,7 @@ public class TCKMonthDay extends AbstractDateTimeTest { assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_hashCode_unique() { int leapYear = 2008; Set uniques = new HashSet(366); @@ -763,26 +777,11 @@ public class TCKMonthDay extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int m, int d, String expected) { MonthDay test = MonthDay.of(m, d); String str = test.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("M d"); - String t = MonthDay.of(12, 3).toString(f); - assertEquals(t, "12 3"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - MonthDay.of(12, 3).toString(null); - } - } diff --git a/jdk/test/java/time/tck/java/time/TCKOffsetDateTime.java b/jdk/test/java/time/tck/java/time/TCKOffsetDateTime.java index ee0832e7ff0..a6bb7c30418 100644 --- a/jdk/test/java/time/tck/java/time/TCKOffsetDateTime.java +++ b/jdk/test/java/time/tck/java/time/TCKOffsetDateTime.java @@ -71,7 +71,6 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.HOUR_OF_AMPM; import static java.time.temporal.ChronoField.HOUR_OF_DAY; @@ -86,6 +85,7 @@ import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.NANO_OF_DAY; import static java.time.temporal.ChronoField.NANO_OF_SECOND; import static java.time.temporal.ChronoField.OFFSET_SECONDS; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.SECOND_OF_DAY; import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; import static java.time.temporal.ChronoField.YEAR; @@ -95,6 +95,7 @@ import static java.time.temporal.ChronoUnit.NANOS; import static java.time.temporal.ChronoUnit.SECONDS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -120,7 +121,6 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -149,9 +149,9 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { private static final ZoneOffset OFFSET_MTWO = ZoneOffset.ofHours(-2); private OffsetDateTime TEST_2008_6_30_11_30_59_000000500; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { - TEST_2008_6_30_11_30_59_000000500 = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 500), OFFSET_PONE); + TEST_2008_6_30_11_30_59_000000500 = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 500, OFFSET_PONE); } //----------------------------------------------------------------------- @@ -188,7 +188,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { ALIGNED_WEEK_OF_MONTH, ALIGNED_WEEK_OF_YEAR, MONTH_OF_YEAR, - EPOCH_MONTH, + PROLEPTIC_MONTH, YEAR_OF_ERA, YEAR, ERA, @@ -261,7 +261,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { OffsetDateTime expected = OffsetDateTime.now(Clock.systemDefaultZone()); OffsetDateTime test = OffsetDateTime.now(); @@ -278,7 +278,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_utc() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); @@ -295,7 +295,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_offset() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); @@ -312,7 +312,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { @@ -328,7 +328,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_offsets() { OffsetDateTime base = OffsetDateTime.of(1970, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC); for (int i = -9; i < 15; i++) { @@ -343,12 +343,12 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullZoneId() { OffsetDateTime.now((ZoneId) null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { OffsetDateTime.now((Clock) null); } @@ -371,14 +371,14 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // factories //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_intsHMSN() { OffsetDateTime test = OffsetDateTime.of(2008, 6, 30, 11, 30, 10, 500, OFFSET_PONE); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_PONE); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateLocalTimeZoneOffset() { LocalDate date = LocalDate.of(2008, 6, 30); LocalTime time = LocalTime.of(11, 30, 10, 500); @@ -386,19 +386,19 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTimeZoneOffset_nullLocalDate() { LocalTime time = LocalTime.of(11, 30, 10, 500); OffsetDateTime.of((LocalDate) null, time, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTimeZoneOffset_nullLocalTime() { LocalDate date = LocalDate.of(2008, 6, 30); OffsetDateTime.of(date, (LocalTime) null, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTimeZoneOffset_nullOffset() { LocalDate date = LocalDate.of(2008, 6, 30); LocalTime time = LocalTime.of(11, 30, 10, 500); @@ -406,19 +406,19 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateTimeZoneOffset() { LocalDateTime dt = LocalDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 10, 500)); OffsetDateTime test = OffsetDateTime.of(dt, OFFSET_PONE); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateTimeZoneOffset_nullProvider() { OffsetDateTime.of((LocalDateTime) null, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateTimeZoneOffset_nullOffset() { LocalDateTime dt = LocalDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 10, 500)); OffsetDateTime.of(dt, (ZoneOffset) null); @@ -427,19 +427,19 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // from() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(OffsetDateTime.from( OffsetDateTime.of(LocalDate.of(2007, 7, 15), LocalTime.of(17, 30), OFFSET_PONE)), OffsetDateTime.of(LocalDate.of(2007, 7, 15), LocalTime.of(17, 30), OFFSET_PONE)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { OffsetDateTime.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_Calendricals_null() { OffsetDateTime.from((TemporalAccessor) null); } @@ -447,7 +447,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse() //----------------------------------------------------------------------- - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_parse(int y, int month, int d, int h, int m, int s, int n, String offsetId, String text) { OffsetDateTime t = OffsetDateTime.parse(text); assertEquals(t.getYear(), y); @@ -460,17 +460,17 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(t.getOffset().getId(), offsetId); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue() { OffsetDateTime.parse("2008-06-32T11:15+01:00"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_invalidValue() { OffsetDateTime.parse("2008-06-31T11:15+01:00"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { OffsetDateTime.parse((String) null); } @@ -478,26 +478,26 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s XXX"); OffsetDateTime test = OffsetDateTime.parse("2010 12 3 11 30 0 +01:00", f); assertEquals(test, OffsetDateTime.of(LocalDate.of(2010, 12, 3), LocalTime.of(11, 30), ZoneOffset.ofHours(1))); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); OffsetDateTime.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { OffsetDateTime.parse("ANY", null); } //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void constructor_nullTime() throws Throwable { Constructor con = OffsetDateTime.class.getDeclaredConstructor(LocalDateTime.class, ZoneOffset.class); con.setAccessible(true); @@ -508,7 +508,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void constructor_nullOffset() throws Throwable { Constructor con = OffsetDateTime.class.getDeclaredConstructor(LocalDateTime.class, ZoneOffset.class); con.setAccessible(true); @@ -532,7 +532,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_get(int y, int o, int d, int h, int m, int s, int n, ZoneOffset offset) { LocalDate localDate = LocalDate.of(y, o, d); LocalTime localTime = LocalTime.of(h, m, s, n); @@ -602,13 +602,13 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2008_6_30_11_30_59_000000500, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_2008_6_30_11_30_59_000000500, Queries.zoneId(), null}, - {TEST_2008_6_30_11_30_59_000000500, Queries.precision(), ChronoUnit.NANOS}, - {TEST_2008_6_30_11_30_59_000000500, Queries.zone(), OFFSET_PONE}, - {TEST_2008_6_30_11_30_59_000000500, Queries.offset(), OFFSET_PONE}, - {TEST_2008_6_30_11_30_59_000000500, Queries.localDate(), LocalDate.of(2008, 6, 30)}, - {TEST_2008_6_30_11_30_59_000000500, Queries.localTime(), LocalTime.of(11, 30, 59, 500)}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.zoneId(), null}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.precision(), ChronoUnit.NANOS}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.zone(), OFFSET_PONE}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.offset(), OFFSET_PONE}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.localDate(), LocalDate.of(2008, 6, 30)}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.localTime(), LocalTime.of(11, 30, 59, 500)}, }; } @@ -627,10 +627,50 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { TEST_2008_6_30_11_30_59_000000500.query(null); } + //----------------------------------------------------------------------- + // adjustInto(Temporal) + //----------------------------------------------------------------------- + @DataProvider(name="adjustInto") + Object[][] data_adjustInto() { + return new Object[][]{ + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetDateTime.of(2012, 3, 4, 1, 1, 1, 100, ZoneOffset.UTC), OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetDateTime.MAX, OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetDateTime.MIN, OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null}, + {OffsetDateTime.MAX, OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetDateTime.of(OffsetDateTime.MAX.toLocalDateTime(), ZoneOffset.ofHours(-18)), null}, + {OffsetDateTime.MIN, OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetDateTime.of(OffsetDateTime.MIN.toLocalDateTime(), ZoneOffset.ofHours(18)), null}, + + + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), + ZonedDateTime.of(2012, 3, 4, 1, 1, 1, 100, ZONE_GAZA), ZonedDateTime.of(2012, 3, 4, 23, 5, 0, 0, ZONE_GAZA), null}, + + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), null, DateTimeException.class}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), LocalDate.of(2210, 2, 2), null, DateTimeException.class}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), LocalTime.of(22, 3, 0), null, DateTimeException.class}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), OffsetTime.of(22, 3, 0, 0, ZoneOffset.UTC), null, DateTimeException.class}, + {OffsetDateTime.of(2012, 3, 4, 23, 5, 0, 0, OFFSET_PONE), null, null, NullPointerException.class}, + + }; + } + + @Test(dataProvider="adjustInto") + public void test_adjustInto(OffsetDateTime test, Temporal temporal, Temporal expected, Class expectedEx) { + if (expectedEx == null) { + Temporal result = test.adjustInto(temporal); + assertEquals(result, expected); + } else { + try { + Temporal result = test.adjustInto(temporal); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + //----------------------------------------------------------------------- // with(WithAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_adjustment() { final OffsetDateTime sample = OffsetDateTime.of(LocalDate.of(2012, 3, 4), LocalTime.of(23, 5), OFFSET_PONE); TemporalAdjuster adjuster = new TemporalAdjuster() { @@ -642,54 +682,54 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(TEST_2008_6_30_11_30_59_000000500.with(adjuster), sample); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_LocalDate() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(LocalDate.of(2012, 9, 3)); assertEquals(test, OffsetDateTime.of(LocalDate.of(2012, 9, 3), LocalTime.of(11, 30, 59, 500), OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_LocalTime() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(LocalTime.of(19, 15)); assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(19, 15), OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_LocalDateTime() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(LocalDateTime.of(LocalDate.of(2012, 9, 3), LocalTime.of(19, 15))); assertEquals(test, OffsetDateTime.of(LocalDate.of(2012, 9, 3), LocalTime.of(19, 15), OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_OffsetTime() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(OffsetTime.of(LocalTime.of(19, 15), OFFSET_PTWO)); assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(19, 15), OFFSET_PTWO)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_OffsetDateTime() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(OffsetDateTime.of(LocalDate.of(2012, 9, 3), LocalTime.of(19, 15), OFFSET_PTWO)); assertEquals(test, OffsetDateTime.of(LocalDate.of(2012, 9, 3), LocalTime.of(19, 15), OFFSET_PTWO)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_Month() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(DECEMBER); assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 12, 30),LocalTime.of(11, 30, 59, 500), OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_ZoneOffset() { OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(OFFSET_PTWO); assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 500), OFFSET_PTWO)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_adjustment_null() { TEST_2008_6_30_11_30_59_000000500.with((TemporalAdjuster) null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withOffsetSameLocal_null() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); base.withOffsetSameLocal(null); @@ -698,7 +738,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withOffsetSameInstant() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withOffsetSameInstant() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withOffsetSameInstant(OFFSET_PTWO); @@ -706,16 +746,40 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(test, expected); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withOffsetSameInstant_null() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); base.withOffsetSameInstant(null); } + //----------------------------------------------------------------------- + // with(long,TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name = "withFieldLong") + Object[][] data_withFieldLong() { + return new Object[][] { + {TEST_2008_6_30_11_30_59_000000500, YEAR, 2009, + OffsetDateTime.of(2009, 6, 30, 11, 30, 59, 500, OFFSET_PONE)}, + {TEST_2008_6_30_11_30_59_000000500, MONTH_OF_YEAR, 7, + OffsetDateTime.of(2008, 7, 30, 11, 30, 59, 500, OFFSET_PONE)}, + {TEST_2008_6_30_11_30_59_000000500, DAY_OF_MONTH, 15, + OffsetDateTime.of(2008, 6, 15, 11, 30, 59, 500, OFFSET_PONE)}, + {TEST_2008_6_30_11_30_59_000000500, HOUR_OF_DAY, 14, + OffsetDateTime.of(2008, 6, 30, 14, 30, 59, 500, OFFSET_PONE)}, + {TEST_2008_6_30_11_30_59_000000500, OFFSET_SECONDS, -3600, + OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 500, OFFSET_MONE)}, + }; + }; + + @Test(dataProvider = "withFieldLong") + public void test_with_fieldLong(OffsetDateTime base, TemporalField setField, long setValue, OffsetDateTime expected) { + assertEquals(base.with(setField, setValue), expected); + } + //----------------------------------------------------------------------- // withYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withYear_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withYear(2007); @@ -725,7 +789,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withMonth(1); @@ -735,7 +799,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withDayOfMonth(15); @@ -745,18 +809,18 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withDayOfYear(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfYear_normal() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.withDayOfYear(33); assertEquals(t, OffsetDateTime.of(LocalDate.of(2008, 2, 2), LocalTime.of(11, 30, 59, 500), OFFSET_PONE)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_illegal() { TEST_2008_6_30_11_30_59_000000500.withDayOfYear(367); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_invalid() { OffsetDateTime.of(LocalDate.of(2007, 2, 2), LocalTime.of(11, 30), OFFSET_PONE).withDayOfYear(366); } @@ -764,7 +828,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withHour() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withHour_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withHour(15); @@ -774,7 +838,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withMinute() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMinute_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withMinute(15); @@ -784,7 +848,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withSecond_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withSecond(15); @@ -794,7 +858,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withNano() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_normal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE); OffsetDateTime test = base.withNano(15); @@ -804,14 +868,14 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // truncatedTo(TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_truncatedTo_normal() { assertEquals(TEST_2008_6_30_11_30_59_000000500.truncatedTo(NANOS), TEST_2008_6_30_11_30_59_000000500); assertEquals(TEST_2008_6_30_11_30_59_000000500.truncatedTo(SECONDS), TEST_2008_6_30_11_30_59_000000500.withNano(0)); assertEquals(TEST_2008_6_30_11_30_59_000000500.truncatedTo(DAYS), TEST_2008_6_30_11_30_59_000000500.with(LocalTime.MIDNIGHT)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_2008_6_30_11_30_59_000000500.truncatedTo(null); } @@ -819,7 +883,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plus(Period) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_Period() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(period); @@ -829,20 +893,20 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plus(Duration) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_Duration() { Duration dur = Duration.ofSeconds(62, 3); OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(dur); assertEquals(t, OffsetDateTime.of(2008, 6, 30, 11, 32, 1, 503, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plus_Duration_zero() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(Duration.ZERO); assertEquals(t, TEST_2008_6_30_11_30_59_000000500); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_Duration_null() { TEST_2008_6_30_11_30_59_000000500.plus((Duration) null); } @@ -850,7 +914,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusYears(1); @@ -860,7 +924,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMonths() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusMonths(1); @@ -870,7 +934,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusWeeks() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusWeeks() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusWeeks(1); @@ -880,7 +944,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusDays() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusDays() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusDays(1); @@ -890,7 +954,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusHours() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusHours(13); @@ -900,7 +964,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMinutes() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusMinutes(30); @@ -910,7 +974,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusSeconds() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusSeconds(1); @@ -920,7 +984,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusNanos() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.plusNanos(1); @@ -930,7 +994,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minus(Period) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_Period() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.minus(period); @@ -940,20 +1004,20 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minus(Duration) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_Duration() { Duration dur = Duration.ofSeconds(62, 3); OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.minus(dur); assertEquals(t, OffsetDateTime.of(2008, 6, 30, 11, 29, 57, 497, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minus_Duration_zero() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.minus(Duration.ZERO); assertEquals(t, TEST_2008_6_30_11_30_59_000000500); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_Duration_null() { TEST_2008_6_30_11_30_59_000000500.minus((Duration) null); } @@ -961,7 +1025,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusYears(1); @@ -971,7 +1035,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMonths() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusMonths(1); @@ -981,7 +1045,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusWeeks() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusWeeks() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusWeeks(1); @@ -991,7 +1055,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusDays() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusDays() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusDays(1); @@ -1001,7 +1065,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusHours() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusHours(13); @@ -1011,7 +1075,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMinutes() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusMinutes(30); @@ -1021,7 +1085,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusSeconds() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusSeconds(1); @@ -1031,24 +1095,39 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusNanos() { OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); OffsetDateTime test = base.minusNanos(1); assertEquals(test, OffsetDateTime.of(2008, 6, 30, 11, 30, 58, 999999999, OFFSET_PONE)); } + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); + String t = OffsetDateTime.of(2010, 12, 3, 11, 30, 0, 0, OFFSET_PONE).format(f); + assertEquals(t, "2010 12 3 11 30 0"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + OffsetDateTime.of(2010, 12, 3, 11, 30, 0, 0, OFFSET_PONE).format(null); + } + //----------------------------------------------------------------------- // atZoneSameInstant() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atZone() { OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_MTWO); assertEquals(t.atZoneSameInstant(ZONE_PARIS), ZonedDateTime.of(2008, 6, 30, 15, 30, 0, 0, ZONE_PARIS)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atZone_nullTimeZone() { OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO); t.atZoneSameInstant((ZoneId) null); @@ -1057,21 +1136,21 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // atZoneSimilarLocal() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atZoneSimilarLocal() { OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_MTWO); assertEquals(t.atZoneSimilarLocal(ZONE_PARIS), ZonedDateTime.of(2008, 6, 30, 11, 30, 0, 0, ZONE_PARIS)); } - @Test(groups={"tck"}) + @Test public void test_atZoneSimilarLocal_dstGap() { OffsetDateTime t = OffsetDateTime.of(2007, 4, 1, 0, 0, 0, 0, OFFSET_MTWO); assertEquals(t.atZoneSimilarLocal(ZONE_GAZA), ZonedDateTime.of(2007, 4, 1, 1, 0, 0, 0, ZONE_GAZA)); } - @Test(groups={"tck"}) + @Test public void test_atZone_dstOverlapSummer() { OffsetDateTime t = OffsetDateTime.of(2007, 10, 28, 2, 30, 0, 0, OFFSET_PTWO); assertEquals(t.atZoneSimilarLocal(ZONE_PARIS).toLocalDateTime(), t.toLocalDateTime()); @@ -1079,7 +1158,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(t.atZoneSimilarLocal(ZONE_PARIS).getZone(), ZONE_PARIS); } - @Test(groups={"tck"}) + @Test public void test_atZone_dstOverlapWinter() { OffsetDateTime t = OffsetDateTime.of(2007, 10, 28, 2, 30, 0, 0, OFFSET_PONE); assertEquals(t.atZoneSimilarLocal(ZONE_PARIS).toLocalDateTime(), t.toLocalDateTime()); @@ -1087,7 +1166,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(t.atZoneSimilarLocal(ZONE_PARIS).getZone(), ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_atZoneSimilarLocal_nullTimeZone() { OffsetDateTime t = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO); t.atZoneSimilarLocal((ZoneId) null); @@ -1096,7 +1175,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // toEpochSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_afterEpoch() { for (int i = 0; i < 100000; i++) { OffsetDateTime a = OffsetDateTime.of(1970, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC).plusSeconds(i); @@ -1104,7 +1183,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_beforeEpoch() { for (int i = 0; i < 100000; i++) { OffsetDateTime a = OffsetDateTime.of(1970, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC).minusSeconds(i); @@ -1115,7 +1194,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo_timeMins() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 29, 3, 0, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 2, 0, OFFSET_PONE); // a is before b due to time @@ -1126,7 +1205,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_timeSecs() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 29, 2, 0, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 29, 3, 0, OFFSET_PONE); // a is before b due to time @@ -1137,7 +1216,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_timeNanos() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 29, 40, 4, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 29, 40, 5, OFFSET_PONE); // a is before b due to time @@ -1148,7 +1227,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_offset() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PONE); // a is before b due to offset @@ -1159,7 +1238,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_offsetNanos() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 40, 6, OFFSET_PTWO); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 40, 5, OFFSET_PONE); // a is before b due to offset @@ -1170,7 +1249,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_both() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 50, 0, 0, OFFSET_PTWO); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 20, 0, 0, OFFSET_PONE); // a is before b on instant scale @@ -1181,7 +1260,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_bothNanos() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 20, 40, 4, OFFSET_PTWO); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 10, 20, 40, 5, OFFSET_PONE); // a is before b on instant scale @@ -1192,7 +1271,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_hourDifference() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 10, 0, 0, 0, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 0, 0, 0, OFFSET_PTWO); // a is before b despite being same time-line time @@ -1203,7 +1282,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(a.toInstant().compareTo(b.toInstant()) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_max() { OffsetDateTime a = OffsetDateTime.of(Year.MAX_VALUE, 12, 31, 23, 59, 0, 0, OFFSET_MONE); OffsetDateTime b = OffsetDateTime.of(Year.MAX_VALUE, 12, 31, 23, 59, 0, 0, OFFSET_MTWO); // a is before b due to offset @@ -1213,7 +1292,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_min() { OffsetDateTime a = OffsetDateTime.of(Year.MIN_VALUE, 1, 1, 0, 0, 0, 0, OFFSET_PTWO); OffsetDateTime b = OffsetDateTime.of(Year.MIN_VALUE, 1, 1, 0, 0, 0, 0, OFFSET_PONE); // a is before b due to offset @@ -1223,13 +1302,13 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(b.compareTo(b) == 0, true); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_null() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); a.compareTo(null); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({"unchecked", "rawtypes"}) public void compareToNonOffsetDateTime() { Comparable c = TEST_2008_6_30_11_30_59_000000500; @@ -1239,7 +1318,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // isAfter() / isBefore() / isEqual() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual1() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 58, 3, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 2, OFFSET_PONE); // a is before b due to time @@ -1261,7 +1340,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual2() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 2, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 3, OFFSET_PONE); // a is before b due to time @@ -1283,7 +1362,7 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual_instantComparison() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 10, 0, 0, 0, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 0, 0, 0, OFFSET_PTWO); // a is same instant as b @@ -1305,19 +1384,19 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { assertEquals(b.isAfter(b), false); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_null() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); a.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isEqual_null() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); a.isEqual(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_null() { OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE); a.isAfter(null); @@ -1326,65 +1405,65 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_true(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); assertEquals(a.equals(b), true); assertEquals(a.hashCode() == b.hashCode(), true); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_year_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y + 1, o, d, h, m, s, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_hour_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { h = (h == 23 ? 22 : h); OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h + 1, m, s, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_minute_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { m = (m == 59 ? 58 : m); OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m + 1, s, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_second_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { s = (s == 59 ? 58 : s); OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m, s + 1, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_nano_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { n = (n == 999999999 ? 999999998 : n); OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m, s, n + 1, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_offset_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) { OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE); OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PTWO); assertEquals(a.equals(b), false); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_2008_6_30_11_30_59_000000500.equals(TEST_2008_6_30_11_30_59_000000500), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_2008_6_30_11_30_59_000000500.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_2008_6_30_11_30_59_000000500.equals(null), false); } @@ -1406,26 +1485,11 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int y, int o, int d, int h, int m, int s, int n, String offsetId, String expected) { OffsetDateTime t = OffsetDateTime.of(y, o, d, h, m, s, n, ZoneOffset.of(offsetId)); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); - String t = OffsetDateTime.of(2010, 12, 3, 11, 30, 0, 0, OFFSET_PONE).toString(f); - assertEquals(t, "2010 12 3 11 30 0"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - OffsetDateTime.of(2010, 12, 3, 11, 30, 0, 0, OFFSET_PONE).toString(null); - } - } diff --git a/jdk/test/java/time/tck/java/time/TCKOffsetTime.java b/jdk/test/java/time/tck/java/time/TCKOffsetTime.java index 83117099be2..ff8ec88502e 100644 --- a/jdk/test/java/time/tck/java/time/TCKOffsetTime.java +++ b/jdk/test/java/time/tck/java/time/TCKOffsetTime.java @@ -81,6 +81,7 @@ import static java.time.temporal.ChronoUnit.SECONDS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -92,6 +93,7 @@ import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.OffsetDateTime; import java.time.OffsetTime; import java.time.Period; import java.time.ZoneId; @@ -102,7 +104,6 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; @@ -124,12 +125,13 @@ import test.java.time.MockSimplePeriod; @Test public class TCKOffsetTime extends AbstractDateTimeTest { + private static final ZoneId ZONE_GAZA = ZoneId.of("Asia/Gaza"); private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); private static final LocalDate DATE = LocalDate.of(2008, 12, 3); private OffsetTime TEST_11_30_59_500_PONE; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_11_30_59_500_PONE = OffsetTime.of(11, 30, 59, 500, OFFSET_PONE); } @@ -224,7 +226,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { ZonedDateTime nowDT = ZonedDateTime.now(); @@ -238,7 +240,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -252,7 +254,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_beforeEpoch() { for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -266,7 +268,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_offsets() { Instant base = LocalDateTime.of(1970, 1, 1, 12, 0).toInstant(ZoneOffset.UTC); for (int i = -9; i < 15; i++) { @@ -281,12 +283,12 @@ public class TCKOffsetTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullZoneId() { OffsetTime.now((ZoneId) null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { OffsetTime.now((Clock) null); } @@ -309,26 +311,26 @@ public class TCKOffsetTime extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_intsHMSN() { OffsetTime test = OffsetTime.of(11, 30, 10, 500, OFFSET_PONE); check(test, 11, 30, 10, 500, OFFSET_PONE); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_LocalTimeZoneOffset() { LocalTime localTime = LocalTime.of(11, 30, 10, 500); OffsetTime test = OffsetTime.of(localTime, OFFSET_PONE); check(test, 11, 30, 10, 500, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_LocalTimeZoneOffset_nullTime() { OffsetTime.of((LocalTime) null, OFFSET_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_LocalTimeZoneOffset_nullOffset() { LocalTime localTime = LocalTime.of(11, 30, 10, 500); OffsetTime.of(localTime, (ZoneOffset) null); @@ -337,18 +339,18 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // ofInstant() //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_nullInstant() { OffsetTime.ofInstant((Instant) null, ZoneOffset.UTC); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_nullOffset() { Instant instant = Instant.ofEpochSecond(0L); OffsetTime.ofInstant(instant, (ZoneOffset) null); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_allSecsInDay() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -360,7 +362,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_beforeEpoch() { for (int i =-1; i >= -(24 * 60 * 60); i--) { Instant instant = Instant.ofEpochSecond(i, 8); @@ -373,7 +375,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofInstant_maxYear() { OffsetTime test = OffsetTime.ofInstant(Instant.MAX, ZoneOffset.UTC); assertEquals(test.getHour(), 23); @@ -382,7 +384,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(test.getNano(), 999_999_999); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_minYear() { OffsetTime test = OffsetTime.ofInstant(Instant.MIN, ZoneOffset.UTC); assertEquals(test.getHour(), 0); @@ -394,23 +396,23 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // from(TemporalAccessor) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_from_TemporalAccessor_OT() { assertEquals(OffsetTime.from(OffsetTime.of(17, 30, 0, 0, OFFSET_PONE)), OffsetTime.of(17, 30, 0, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_from_TemporalAccessor_ZDT() { ZonedDateTime base = LocalDateTime.of(2007, 7, 15, 11, 30, 59, 500).atZone(OFFSET_PONE); assertEquals(OffsetTime.from(base), TEST_11_30_59_500_PONE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_from_TemporalAccessor_invalid_noDerive() { OffsetTime.from(LocalDate.of(2007, 7, 15)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_from_TemporalAccessor_null() { OffsetTime.from((TemporalAccessor) null); } @@ -418,7 +420,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse() //----------------------------------------------------------------------- - @Test(dataProvider = "sampleToString", groups={"tck"}) + @Test(dataProvider = "sampleToString") public void factory_parse_validText(int h, int m, int s, int n, String offsetId, String parsable) { OffsetTime t = OffsetTime.parse(parsable); assertNotNull(t, parsable); @@ -440,23 +442,23 @@ public class TCKOffsetTime extends AbstractDateTimeTest { }; } - @Test(dataProvider = "sampleBadParse", expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(dataProvider = "sampleBadParse", expectedExceptions={DateTimeParseException.class}) public void factory_parse_invalidText(String unparsable) { OffsetTime.parse(unparsable); } //-----------------------------------------------------------------------s - @Test(expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeParseException.class}) public void factory_parse_illegalHour() { OffsetTime.parse("25:00+01:00"); } - @Test(expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeParseException.class}) public void factory_parse_illegalMinute() { OffsetTime.parse("12:60+01:00"); } - @Test(expectedExceptions={DateTimeParseException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeParseException.class}) public void factory_parse_illegalSecond() { OffsetTime.parse("12:12:60+01:00"); } @@ -464,20 +466,20 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s XXX"); OffsetTime test = OffsetTime.parse("11 30 0 +01:00", f); assertEquals(test, OffsetTime.of(11, 30, 0, 0, ZoneOffset.ofHours(1))); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); OffsetTime.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { OffsetTime.parse("ANY", null); } @@ -485,7 +487,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // constructor //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void constructor_nullTime() throws Throwable { Constructor con = OffsetTime.class.getDeclaredConstructor(LocalTime.class, ZoneOffset.class); con.setAccessible(true); @@ -496,7 +498,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void constructor_nullOffset() throws Throwable { Constructor con = OffsetTime.class.getDeclaredConstructor(LocalTime.class, ZoneOffset.class); con.setAccessible(true); @@ -519,7 +521,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_get(int h, int m, int s, int n, ZoneOffset offset) { LocalTime localTime = LocalTime.of(h, m, s, n); OffsetTime a = OffsetTime.of(localTime, offset); @@ -568,13 +570,13 @@ public class TCKOffsetTime extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_11_30_59_500_PONE, Queries.chronology(), null}, - {TEST_11_30_59_500_PONE, Queries.zoneId(), null}, - {TEST_11_30_59_500_PONE, Queries.precision(), ChronoUnit.NANOS}, - {TEST_11_30_59_500_PONE, Queries.zone(), OFFSET_PONE}, - {TEST_11_30_59_500_PONE, Queries.offset(), OFFSET_PONE}, - {TEST_11_30_59_500_PONE, Queries.localDate(), null}, - {TEST_11_30_59_500_PONE, Queries.localTime(), LocalTime.of(11, 30, 59, 500)}, + {TEST_11_30_59_500_PONE, TemporalQuery.chronology(), null}, + {TEST_11_30_59_500_PONE, TemporalQuery.zoneId(), null}, + {TEST_11_30_59_500_PONE, TemporalQuery.precision(), ChronoUnit.NANOS}, + {TEST_11_30_59_500_PONE, TemporalQuery.zone(), OFFSET_PONE}, + {TEST_11_30_59_500_PONE, TemporalQuery.offset(), OFFSET_PONE}, + {TEST_11_30_59_500_PONE, TemporalQuery.localDate(), null}, + {TEST_11_30_59_500_PONE, TemporalQuery.localTime(), LocalTime.of(11, 30, 59, 500)}, }; } @@ -596,7 +598,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withOffsetSameLocal() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withOffsetSameLocal() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withOffsetSameLocal(OFFSET_PTWO); @@ -604,14 +606,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(test.getOffset(), OFFSET_PTWO); } - @Test(groups={"tck"}) + @Test public void test_withOffsetSameLocal_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withOffsetSameLocal(OFFSET_PONE); assertEquals(test, base); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withOffsetSameLocal_null() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); base.withOffsetSameLocal(null); @@ -620,7 +622,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withOffsetSameInstant() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withOffsetSameInstant() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withOffsetSameInstant(OFFSET_PTWO); @@ -628,23 +630,62 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(test, expected); } - @Test(groups={"tck"}) + @Test public void test_withOffsetSameInstant_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withOffsetSameInstant(OFFSET_PONE); assertEquals(test, base); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withOffsetSameInstant_null() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); base.withOffsetSameInstant(null); } + //----------------------------------------------------------------------- + // adjustInto(Temporal) + //----------------------------------------------------------------------- + @DataProvider(name="adjustInto") + Object[][] data_adjustInto() { + return new Object[][]{ + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.of(LocalTime.of(1, 1, 1, 100), ZoneOffset.UTC), OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), null}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.MAX, OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), null}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.MIN, OffsetTime.of(LocalTime.of(23 , 5), OFFSET_PONE), null}, + {OffsetTime.MAX, OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.of(OffsetTime.MAX.toLocalTime(), ZoneOffset.ofHours(-18)), null}, + {OffsetTime.MIN, OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetTime.of(OffsetTime.MIN.toLocalTime(), ZoneOffset.ofHours(18)), null}, + + + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), ZonedDateTime.of(LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), ZONE_GAZA), ZonedDateTime.of(LocalDateTime.of(2012, 3, 4, 23, 5), ZONE_GAZA), null}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), OffsetDateTime.of(LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), ZoneOffset.UTC), OffsetDateTime.of(LocalDateTime.of(2012, 3, 4, 23, 5), OFFSET_PONE), null}, + + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), LocalDateTime.of(2012, 3, 4, 1, 1, 1, 100), null, DateTimeException.class}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), LocalDate.of(2210, 2, 2), null, DateTimeException.class}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), LocalTime.of(22, 3, 0), null, DateTimeException.class}, + {OffsetTime.of(LocalTime.of(23, 5), OFFSET_PONE), null, null, NullPointerException.class}, + + }; + } + + @Test(dataProvider="adjustInto") + public void test_adjustInto(OffsetTime test, Temporal temporal, Temporal expected, Class expectedEx) { + if (expectedEx == null) { + Temporal result = test.adjustInto(temporal); + assertEquals(result, expected); + } else { + try { + Temporal result = test.adjustInto(temporal); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + //----------------------------------------------------------------------- // with(WithAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_adjustment() { final OffsetTime sample = OffsetTime.of(23, 5, 0, 0, OFFSET_PONE); TemporalAdjuster adjuster = new TemporalAdjuster() { @@ -656,25 +697,25 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(TEST_11_30_59_500_PONE.with(adjuster), sample); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_LocalTime() { OffsetTime test = TEST_11_30_59_500_PONE.with(LocalTime.of(13, 30)); assertEquals(test, OffsetTime.of(13, 30, 0, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_OffsetTime() { OffsetTime test = TEST_11_30_59_500_PONE.with(OffsetTime.of(13, 35, 0, 0, OFFSET_PTWO)); assertEquals(test, OffsetTime.of(13, 35, 0, 0, OFFSET_PTWO)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_ZoneOffset() { OffsetTime test = TEST_11_30_59_500_PONE.with(OFFSET_PTWO); assertEquals(test, OffsetTime.of(11, 30, 59, 500, OFFSET_PTWO)); } - @Test(groups={"tck"}) + @Test public void test_with_adjustment_AmPm() { OffsetTime test = TEST_11_30_59_500_PONE.with(new TemporalAdjuster() { @Override @@ -685,7 +726,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(test, OffsetTime.of(23, 30, 59, 500, OFFSET_PONE)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_adjustment_null() { TEST_11_30_59_500_PONE.with((TemporalAdjuster) null); } @@ -693,7 +734,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // with(TemporalField, long) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_TemporalField() { OffsetTime test = OffsetTime.of(12, 30, 40, 987654321, OFFSET_PONE); assertEquals(test.with(ChronoField.HOUR_OF_DAY, 15), OffsetTime.of(15, 30, 40, 987654321, OFFSET_PONE)); @@ -706,12 +747,12 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(test.with(ChronoField.OFFSET_SECONDS, 7205), OffsetTime.of(12, 30, 40, 987654321, ZoneOffset.ofHoursMinutesSeconds(2, 0, 5))); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"} ) + @Test(expectedExceptions=NullPointerException.class ) public void test_with_TemporalField_null() { TEST_11_30_59_500_PONE.with((TemporalField) null, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"} ) + @Test(expectedExceptions=DateTimeException.class ) public void test_with_TemporalField_invalidField() { TEST_11_30_59_500_PONE.with(ChronoField.YEAR, 0); } @@ -719,14 +760,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withHour() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withHour_normal() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withHour(15); assertEquals(test, OffsetTime.of(15, 30, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_withHour_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withHour(11); @@ -736,14 +777,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withMinute() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMinute_normal() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withMinute(15); assertEquals(test, OffsetTime.of(11, 15, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_withMinute_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withMinute(30); @@ -753,14 +794,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withSecond_normal() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withSecond(15); assertEquals(test, OffsetTime.of(11, 30, 15, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_withSecond_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.withSecond(59); @@ -770,14 +811,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withNano() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_normal() { OffsetTime base = OffsetTime.of(11, 30, 59, 1, OFFSET_PONE); OffsetTime test = base.withNano(15); assertEquals(test, OffsetTime.of(11, 30, 59, 15, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_noChange() { OffsetTime base = OffsetTime.of(11, 30, 59, 1, OFFSET_PONE); OffsetTime test = base.withNano(1); @@ -787,14 +828,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // truncatedTo(TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_truncatedTo_normal() { assertEquals(TEST_11_30_59_500_PONE.truncatedTo(NANOS), TEST_11_30_59_500_PONE); assertEquals(TEST_11_30_59_500_PONE.truncatedTo(SECONDS), TEST_11_30_59_500_PONE.withNano(0)); assertEquals(TEST_11_30_59_500_PONE.truncatedTo(DAYS), TEST_11_30_59_500_PONE.with(LocalTime.MIDNIGHT)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_11_30_59_500_PONE.truncatedTo(null); } @@ -802,26 +843,26 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plus(PlusAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plus_PlusAdjuster() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MINUTES); OffsetTime t = TEST_11_30_59_500_PONE.plus(period); assertEquals(t, OffsetTime.of(11, 37, 59, 500, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plus_PlusAdjuster_noChange() { OffsetTime t = TEST_11_30_59_500_PONE.plus(MockSimplePeriod.of(0, SECONDS)); assertEquals(t, TEST_11_30_59_500_PONE); } - @Test(groups={"tck"}) + @Test public void test_plus_PlusAdjuster_zero() { OffsetTime t = TEST_11_30_59_500_PONE.plus(Period.ZERO); assertEquals(t, TEST_11_30_59_500_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_PlusAdjuster_null() { TEST_11_30_59_500_PONE.plus((TemporalAmount) null); } @@ -829,14 +870,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusHours() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusHours(13); assertEquals(test, OffsetTime.of(0, 30, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plusHours_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusHours(0); @@ -846,14 +887,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMinutes() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusMinutes(30); assertEquals(test, OffsetTime.of(12, 0, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusMinutes(0); @@ -863,14 +904,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusSeconds() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusSeconds(1); assertEquals(test, OffsetTime.of(11, 31, 0, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusSeconds(0); @@ -880,14 +921,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusNanos() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusNanos(1); assertEquals(test, OffsetTime.of(11, 30, 59, 1, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.plusNanos(0); @@ -897,26 +938,26 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minus(MinusAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minus_MinusAdjuster() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MINUTES); OffsetTime t = TEST_11_30_59_500_PONE.minus(period); assertEquals(t, OffsetTime.of(11, 23, 59, 500, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minus_MinusAdjuster_noChange() { OffsetTime t = TEST_11_30_59_500_PONE.minus(MockSimplePeriod.of(0, SECONDS)); assertEquals(t, TEST_11_30_59_500_PONE); } - @Test(groups={"tck"}) + @Test public void test_minus_MinusAdjuster_zero() { OffsetTime t = TEST_11_30_59_500_PONE.minus(Period.ZERO); assertEquals(t, TEST_11_30_59_500_PONE); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_MinusAdjuster_null() { TEST_11_30_59_500_PONE.minus((TemporalAmount) null); } @@ -924,14 +965,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusHours() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusHours(-13); assertEquals(test, OffsetTime.of(0, 30, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minusHours_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusHours(0); @@ -941,14 +982,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMinutes() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusMinutes(50); assertEquals(test, OffsetTime.of(10, 40, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusMinutes(0); @@ -958,14 +999,14 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusSeconds() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusSeconds(60); assertEquals(test, OffsetTime.of(11, 29, 59, 0, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusSeconds(0); @@ -975,24 +1016,39 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusNanos() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusNanos(1); assertEquals(test, OffsetTime.of(11, 30, 58, 999999999, OFFSET_PONE)); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_zero() { OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); OffsetTime test = base.minusNanos(0); assertEquals(test, base); } + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); + String t = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE).format(f); + assertEquals(t, "11 30 0"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + OffsetTime.of(11, 30, 0, 0, OFFSET_PONE).format(null); + } + //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo_time() { OffsetTime a = OffsetTime.of(11, 29, 0, 0, OFFSET_PONE); OffsetTime b = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE); // a is before b due to time @@ -1003,7 +1059,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_offset() { OffsetTime a = OffsetTime.of(11, 30, 0, 0, OFFSET_PTWO); OffsetTime b = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE); // a is before b due to offset @@ -1014,7 +1070,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_both() { OffsetTime a = OffsetTime.of(11, 50, 0, 0, OFFSET_PTWO); OffsetTime b = OffsetTime.of(11, 20, 0, 0, OFFSET_PONE); // a is before b on instant scale @@ -1025,7 +1081,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_bothNearStartOfDay() { OffsetTime a = OffsetTime.of(0, 10, 0, 0, OFFSET_PONE); OffsetTime b = OffsetTime.of(2, 30, 0, 0, OFFSET_PTWO); // a is before b on instant scale @@ -1036,7 +1092,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(convertInstant(a).compareTo(convertInstant(b)) < 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_hourDifference() { OffsetTime a = OffsetTime.of(10, 0, 0, 0, OFFSET_PONE); OffsetTime b = OffsetTime.of(11, 0, 0, 0, OFFSET_PTWO); // a is before b despite being same time-line time @@ -1047,13 +1103,13 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(convertInstant(a).compareTo(convertInstant(b)) == 0, true); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_null() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); a.compareTo(null); } - @Test(expectedExceptions=ClassCastException.class, groups={"tck"}) + @Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({"unchecked", "rawtypes"}) public void compareToNonOffsetTime() { Comparable c = TEST_11_30_59_500_PONE; @@ -1067,7 +1123,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // isAfter() / isBefore() / isEqual() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual1() { OffsetTime a = OffsetTime.of(11, 30, 58, 0, OFFSET_PONE); OffsetTime b = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); // a is before b due to time @@ -1089,7 +1145,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual1nanos() { OffsetTime a = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE); OffsetTime b = OffsetTime.of(11, 30, 59, 4, OFFSET_PONE); // a is before b due to time @@ -1111,7 +1167,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual2() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PTWO); OffsetTime b = OffsetTime.of(11, 30, 58, 0, OFFSET_PONE); // a is before b due to offset @@ -1133,7 +1189,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual2nanos() { OffsetTime a = OffsetTime.of(11, 30, 59, 4, ZoneOffset.ofTotalSeconds(OFFSET_PONE.getTotalSeconds() + 1)); OffsetTime b = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE); // a is before b due to offset @@ -1155,7 +1211,7 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(b.isAfter(b), false); } - @Test(groups={"tck"}) + @Test public void test_isBeforeIsAfterIsEqual_instantComparison() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PTWO); OffsetTime b = OffsetTime.of(10, 30, 59, 0, OFFSET_PONE); // a is same instant as b @@ -1177,19 +1233,19 @@ public class TCKOffsetTime extends AbstractDateTimeTest { assertEquals(b.isAfter(b), false); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_null() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); a.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_null() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); a.isAfter(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isEqual_null() { OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE); a.isEqual(null); @@ -1198,59 +1254,59 @@ public class TCKOffsetTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_true(int h, int m, int s, int n, ZoneOffset ignored) { OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m, s, n, OFFSET_PONE); assertEquals(a.equals(b), true); assertEquals(a.hashCode() == b.hashCode(), true); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_hour_differs(int h, int m, int s, int n, ZoneOffset ignored) { h = (h == 23 ? 22 : h); OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h + 1, m, s, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_minute_differs(int h, int m, int s, int n, ZoneOffset ignored) { m = (m == 59 ? 58 : m); OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m + 1, s, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_second_differs(int h, int m, int s, int n, ZoneOffset ignored) { s = (s == 59 ? 58 : s); OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m, s + 1, n, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_nano_differs(int h, int m, int s, int n, ZoneOffset ignored) { n = (n == 999999999 ? 999999998 : n); OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m, s, n + 1, OFFSET_PONE); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_offset_differs(int h, int m, int s, int n, ZoneOffset ignored) { OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE); OffsetTime b = OffsetTime.of(h, m, s, n, OFFSET_PTWO); assertEquals(a.equals(b), false); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_11_30_59_500_PONE.equals(TEST_11_30_59_500_PONE), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_11_30_59_500_PONE.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_11_30_59_500_PONE.equals(null), false); } @@ -1272,26 +1328,11 @@ public class TCKOffsetTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int h, int m, int s, int n, String offsetId, String expected) { OffsetTime t = OffsetTime.of(h, m, s, n, ZoneOffset.of(offsetId)); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s"); - String t = OffsetTime.of(11, 30, 0, 0, OFFSET_PONE).toString(f); - assertEquals(t, "11 30 0"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - OffsetTime.of(11, 30, 0, 0, OFFSET_PONE).toString(null); - } - } diff --git a/jdk/test/java/time/tck/java/time/TCKPeriod.java b/jdk/test/java/time/tck/java/time/TCKPeriod.java index 7399b50054e..95907b237a7 100644 --- a/jdk/test/java/time/tck/java/time/TCKPeriod.java +++ b/jdk/test/java/time/tck/java/time/TCKPeriod.java @@ -59,14 +59,21 @@ */ package tck.java.time; +import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import java.time.DateTimeException; +import java.time.Duration; import java.time.LocalDate; import java.time.Period; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalUnit; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Locale; @@ -138,6 +145,78 @@ public class TCKPeriod extends AbstractTCKTest { assertPeriod(Period.of(-1, -2, -3), -1, -2, -3); } + //----------------------------------------------------------------------- + // from(TemporalAmount) + //----------------------------------------------------------------------- + @Test + public void factory_from_TemporalAmount_Period() { + TemporalAmount amount = Period.of(1, 2, 3); + assertPeriod(Period.from(amount), 1, 2, 3); + } + + @Test + public void factory_from_TemporalAmount_YearsDays() { + TemporalAmount amount = new TemporalAmount() { + @Override + public long get(TemporalUnit unit) { + if (unit == YEARS) { + return 23; + } else { + return 45; + } + } + @Override + public List getUnits() { + List list = new ArrayList<>(); + list.add(YEARS); + list.add(DAYS); + return list; + } + @Override + public Temporal addTo(Temporal temporal) { + throw new UnsupportedOperationException(); + } + @Override + public Temporal subtractFrom(Temporal temporal) { + throw new UnsupportedOperationException(); + } + }; + assertPeriod(Period.from(amount), 23, 0, 45); + } + + @Test(expectedExceptions = ArithmeticException.class) + public void factory_from_TemporalAmount_Years_tooBig() { + TemporalAmount amount = new TemporalAmount() { + @Override + public long get(TemporalUnit unit) { + return ((long) (Integer.MAX_VALUE)) + 1; + } + @Override + public List getUnits() { + return Collections.singletonList(YEARS); + } + @Override + public Temporal addTo(Temporal temporal) { + throw new UnsupportedOperationException(); + } + @Override + public Temporal subtractFrom(Temporal temporal) { + throw new UnsupportedOperationException(); + } + }; + Period.from(amount); + } + + @Test(expectedExceptions = DateTimeException.class) + public void factory_from_TemporalAmount_Duration() { + Period.from(Duration.ZERO); + } + + @Test(expectedExceptions = NullPointerException.class) + public void factory_from_TemporalAmount_null() { + Period.from(null); + } + //----------------------------------------------------------------------- // parse(String) //----------------------------------------------------------------------- @@ -465,6 +544,32 @@ public class TCKPeriod extends AbstractTCKTest { assertPeriod(Period.of(1, 2, 3).withDays(0), 1, 2, 0); } + //----------------------------------------------------------------------- + // plus(Period) + //----------------------------------------------------------------------- + @DataProvider(name="plus") + Object[][] data_plus() { + return new Object[][] { + {pymd(0, 0, 0), pymd(0, 0, 0), pymd(0, 0, 0)}, + {pymd(0, 0, 0), pymd(5, 0, 0), pymd(5, 0, 0)}, + {pymd(0, 0, 0), pymd(-5, 0, 0), pymd(-5, 0, 0)}, + {pymd(0, 0, 0), pymd(0, 5, 0), pymd(0, 5, 0)}, + {pymd(0, 0, 0), pymd(0, -5, 0), pymd(0, -5, 0)}, + {pymd(0, 0, 0), pymd(0, 0, 5), pymd(0, 0, 5)}, + {pymd(0, 0, 0), pymd(0, 0, -5), pymd(0, 0, -5)}, + {pymd(0, 0, 0), pymd(2, 3, 4), pymd(2, 3, 4)}, + {pymd(0, 0, 0), pymd(-2, -3, -4), pymd(-2, -3, -4)}, + + {pymd(4, 5, 6), pymd(2, 3, 4), pymd(6, 8, 10)}, + {pymd(4, 5, 6), pymd(-2, -3, -4), pymd(2, 2, 2)}, + }; + } + + @Test(dataProvider="plus") + public void test_plus(Period base, Period add, Period expected) { + assertEquals(base.plus(add), expected); + } + //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- @@ -474,6 +579,11 @@ public class TCKPeriod extends AbstractTCKTest { assertPeriod(Period.of(1, 2, 3).plusYears(10), 11, 2, 3); assertPeriod(Period.of(1, 2, 3).plusYears(-10), -9, 2, 3); assertPeriod(Period.of(1, 2, 3).plusYears(-1), 0, 2, 3); + + assertPeriod(Period.of(1, 2, 3).plus(Period.ofYears(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofYears(10)), 11, 2, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofYears(-10)), -9, 2, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofYears(-1)), 0, 2, 3); } @Test(expectedExceptions=ArithmeticException.class) @@ -497,6 +607,11 @@ public class TCKPeriod extends AbstractTCKTest { assertPeriod(Period.of(1, 2, 3).plusMonths(10), 1, 12, 3); assertPeriod(Period.of(1, 2, 3).plusMonths(-10), 1, -8, 3); assertPeriod(Period.of(1, 2, 3).plusMonths(-2), 1, 0, 3); + + assertPeriod(Period.of(1, 2, 3).plus(Period.ofMonths(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofMonths(10)), 1, 12, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofMonths(-10)), 1, -8, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofMonths(-2)), 1, 0, 3); } @Test(expectedExceptions=ArithmeticException.class) @@ -520,6 +635,11 @@ public class TCKPeriod extends AbstractTCKTest { assertPeriod(Period.of(1, 2, 3).plusDays(10), 1, 2, 13); assertPeriod(Period.of(1, 2, 3).plusDays(-10), 1, 2, -7); assertPeriod(Period.of(1, 2, 3).plusDays(-3), 1, 2, 0); + + assertPeriod(Period.of(1, 2, 3).plus(Period.ofDays(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofDays(10)), 1, 2, 13); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofDays(-10)), 1, 2, -7); + assertPeriod(Period.of(1, 2, 3).plus(Period.ofDays(-3)), 1, 2, 0); } @Test(expectedExceptions=ArithmeticException.class) @@ -534,6 +654,116 @@ public class TCKPeriod extends AbstractTCKTest { test.plusDays(-1); } + //----------------------------------------------------------------------- + // minus(Period) + //----------------------------------------------------------------------- + @DataProvider(name="minus") + Object[][] data_minus() { + return new Object[][] { + {pymd(0, 0, 0), pymd(0, 0, 0), pymd(0, 0, 0)}, + {pymd(0, 0, 0), pymd(5, 0, 0), pymd(-5, 0, 0)}, + {pymd(0, 0, 0), pymd(-5, 0, 0), pymd(5, 0, 0)}, + {pymd(0, 0, 0), pymd(0, 5, 0), pymd(0, -5, 0)}, + {pymd(0, 0, 0), pymd(0, -5, 0), pymd(0, 5, 0)}, + {pymd(0, 0, 0), pymd(0, 0, 5), pymd(0, 0, -5)}, + {pymd(0, 0, 0), pymd(0, 0, -5), pymd(0, 0, 5)}, + {pymd(0, 0, 0), pymd(2, 3, 4), pymd(-2, -3, -4)}, + {pymd(0, 0, 0), pymd(-2, -3, -4), pymd(2, 3, 4)}, + + {pymd(4, 5, 6), pymd(2, 3, 4), pymd(2, 2, 2)}, + {pymd(4, 5, 6), pymd(-2, -3, -4), pymd(6, 8, 10)}, + }; + } + + @Test(dataProvider="minus") + public void test_minus(Period base, Period subtract, Period expected) { + assertEquals(base.minus(subtract), expected); + } + + //----------------------------------------------------------------------- + // minusYears() + //----------------------------------------------------------------------- + @Test + public void test_minusYears() { + assertPeriod(Period.of(1, 2, 3).minusYears(0), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minusYears(10), -9, 2, 3); + assertPeriod(Period.of(1, 2, 3).minusYears(-10), 11, 2, 3); + assertPeriod(Period.of(1, 2, 3).minusYears(-1), 2, 2, 3); + + assertPeriod(Period.of(1, 2, 3).minus(Period.ofYears(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofYears(10)), -9, 2, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofYears(-10)), 11, 2, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofYears(-1)), 2, 2, 3); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusYears_overflowTooBig() { + Period test = Period.ofYears(Integer.MAX_VALUE); + test.minusYears(-1); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusYears_overflowTooSmall() { + Period test = Period.ofYears(Integer.MIN_VALUE); + test.minusYears(1); + } + + //----------------------------------------------------------------------- + // minusMonths() + //----------------------------------------------------------------------- + @Test + public void test_minusMonths() { + assertPeriod(Period.of(1, 2, 3).minusMonths(0), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minusMonths(10), 1, -8, 3); + assertPeriod(Period.of(1, 2, 3).minusMonths(-10), 1, 12, 3); + assertPeriod(Period.of(1, 2, 3).minusMonths(-2), 1, 4, 3); + + assertPeriod(Period.of(1, 2, 3).minus(Period.ofMonths(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofMonths(10)), 1, -8, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofMonths(-10)), 1, 12, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofMonths(-2)), 1, 4, 3); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusMonths_overflowTooBig() { + Period test = Period.ofMonths(Integer.MAX_VALUE); + test.minusMonths(-1); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusMonths_overflowTooSmall() { + Period test = Period.ofMonths(Integer.MIN_VALUE); + test.minusMonths(1); + } + + //----------------------------------------------------------------------- + // minusDays() + //----------------------------------------------------------------------- + @Test + public void test_minusDays() { + assertPeriod(Period.of(1, 2, 3).minusDays(0), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minusDays(10), 1, 2, -7); + assertPeriod(Period.of(1, 2, 3).minusDays(-10), 1, 2, 13); + assertPeriod(Period.of(1, 2, 3).minusDays(-3), 1, 2, 6); + + assertPeriod(Period.of(1, 2, 3).minus(Period.ofDays(0)), 1, 2, 3); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofDays(10)), 1, 2, -7); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofDays(-10)), 1, 2, 13); + assertPeriod(Period.of(1, 2, 3).minus(Period.ofDays(-3)), 1, 2, 6); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusDays_overflowTooBig() { + Period test = Period.ofDays(Integer.MAX_VALUE); + test.minusDays(-1); + } + + @Test(expectedExceptions=ArithmeticException.class) + public void test_minusDays_overflowTooSmall() { + Period test = Period.ofDays(Integer.MIN_VALUE); + test.minusDays(1); + } + //----------------------------------------------------------------------- // multipliedBy() //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/tck/java/time/TCKYear.java b/jdk/test/java/time/tck/java/time/TCKYear.java index 3f0e653f8cf..570946f3239 100644 --- a/jdk/test/java/time/tck/java/time/TCKYear.java +++ b/jdk/test/java/time/tck/java/time/TCKYear.java @@ -62,6 +62,14 @@ package tck.java.time; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.ChronoUnit.CENTURIES; +import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.DECADES; +import static java.time.temporal.ChronoUnit.HOURS; +import static java.time.temporal.ChronoUnit.MILLENNIA; +import static java.time.temporal.ChronoUnit.MONTHS; +import static java.time.temporal.ChronoUnit.WEEKS; +import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; @@ -69,12 +77,14 @@ import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.time.Clock; import java.time.DateTimeException; +import java.time.Duration; import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; import java.time.Month; import java.time.MonthDay; import java.time.OffsetDateTime; +import java.time.Period; import java.time.Year; import java.time.YearMonth; import java.time.ZoneId; @@ -85,11 +95,13 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -159,7 +171,7 @@ public class TCKYear extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { Year expected = Year.now(Clock.systemDefaultZone()); Year test = Year.now(); @@ -176,12 +188,12 @@ public class TCKYear extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { Year.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); Year expected = Year.now(Clock.system(zone)); @@ -199,7 +211,7 @@ public class TCKYear extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock() { Instant instant = OffsetDateTime.of(LocalDate.of(2010, 12, 31), LocalTime.of(0, 0), ZoneOffset.UTC).toInstant(); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); @@ -207,13 +219,13 @@ public class TCKYear extends AbstractDateTimeTest { assertEquals(test.getValue(), 2010); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { Year.now((Clock) null); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_singleton() { for (int i = -4; i <= 2104; i++) { Year test = Year.of(i); @@ -222,28 +234,28 @@ public class TCKYear extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_tooLow() { Year.of(Year.MIN_VALUE - 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_tooHigh() { Year.of(Year.MAX_VALUE + 1); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(Year.from(LocalDate.of(2007, 7, 15)), Year.of(2007)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { Year.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { Year.from((TemporalAccessor) null); } @@ -268,7 +280,7 @@ public class TCKYear extends AbstractDateTimeTest { }; } - @Test(dataProvider="goodParseData", groups={"tck"}) + @Test(dataProvider="goodParseData") public void factory_parse_success(String text, Year expected) { Year year = Year.parse(text); assertEquals(year, expected); @@ -295,7 +307,7 @@ public class TCKYear extends AbstractDateTimeTest { }; } - @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class) public void factory_parse_fail(String text, int pos) { try { Year.parse(text); @@ -307,7 +319,7 @@ public class TCKYear extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { Year.parse(null); } @@ -315,20 +327,20 @@ public class TCKYear extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y"); Year test = Year.parse("2010", f); assertEquals(test, Year.of(2010)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y"); Year.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { Year.parse("ANY", null); } @@ -356,13 +368,13 @@ public class TCKYear extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2008, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_2008, Queries.zoneId(), null}, - {TEST_2008, Queries.precision(), ChronoUnit.YEARS}, - {TEST_2008, Queries.zone(), null}, - {TEST_2008, Queries.offset(), null}, - {TEST_2008, Queries.localDate(), null}, - {TEST_2008, Queries.localTime(), null}, + {TEST_2008, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_2008, TemporalQuery.zoneId(), null}, + {TEST_2008, TemporalQuery.precision(), ChronoUnit.YEARS}, + {TEST_2008, TemporalQuery.zone(), null}, + {TEST_2008, TemporalQuery.offset(), null}, + {TEST_2008, TemporalQuery.localDate(), null}, + {TEST_2008, TemporalQuery.localTime(), null}, }; } @@ -384,7 +396,7 @@ public class TCKYear extends AbstractDateTimeTest { //----------------------------------------------------------------------- // isLeap() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isLeap() { assertEquals(Year.of(1999).isLeap(), false); assertEquals(Year.of(2000).isLeap(), true); @@ -422,10 +434,52 @@ public class TCKYear extends AbstractDateTimeTest { assertEquals(Year.of(500).isLeap(), false); } + //----------------------------------------------------------------------- + // plus(Period) + //----------------------------------------------------------------------- + @DataProvider(name="plusValid") + Object[][] data_plusValid() { + return new Object[][] { + {2012, Period.ofYears(0), 2012}, + {2012, Period.ofYears(1), 2013}, + {2012, Period.ofYears(2), 2014}, + {2012, Period.ofYears(-2), 2010}, + }; + } + + @Test(dataProvider="plusValid") + public void test_plusValid(int year, TemporalAmount amount, int expected) { + assertEquals(Year.of(year).plus(amount), Year.of(expected)); + } + + @DataProvider(name="plusInvalidUnit") + Object[][] data_plusInvalidUnit() { + return new Object[][] { + {Period.of(0, 1, 0)}, + {Period.of(0, 0, 1)}, + {Period.of(0, 1, 1)}, + {Period.of(1, 1, 1)}, + {Duration.ofDays(1)}, + {Duration.ofHours(1)}, + {Duration.ofMinutes(1)}, + {Duration.ofSeconds(1)}, + }; + } + + @Test(dataProvider="plusInvalidUnit", expectedExceptions=UnsupportedTemporalTypeException.class) + public void test_plusInvalidUnit(TemporalAmount amount) { + TEST_2008.plus(amount); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_plus_null() { + TEST_2008.plus(null); + } + //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears() { assertEquals(Year.of(2007).plusYears(-1), Year.of(2006)); assertEquals(Year.of(2007).plusYears(0), Year.of(2007)); @@ -439,42 +493,84 @@ public class TCKYear extends AbstractDateTimeTest { assertEquals(Year.of(Year.MIN_VALUE).plusYears(0), Year.of(Year.MIN_VALUE)); } - @Test(groups={"tck"}) + @Test public void test_plusYear_zero_equals() { Year base = Year.of(2007); assertEquals(base.plusYears(0), base); } - @Test(groups={"tck"}) + @Test public void test_plusYears_big() { long years = 20L + Year.MAX_VALUE; assertEquals(Year.of(-40).plusYears(years), Year.of((int) (-40L + years))); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_max() { Year.of(Year.MAX_VALUE).plusYears(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_maxLots() { Year.of(Year.MAX_VALUE).plusYears(1000); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_min() { Year.of(Year.MIN_VALUE).plusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_minLots() { Year.of(Year.MIN_VALUE).plusYears(-1000); } + //----------------------------------------------------------------------- + // minus(Period) + //----------------------------------------------------------------------- + @DataProvider(name="minusValid") + Object[][] data_minusValid() { + return new Object[][] { + {2012, Period.ofYears(0), 2012}, + {2012, Period.ofYears(1), 2011}, + {2012, Period.ofYears(2), 2010}, + {2012, Period.ofYears(-2), 2014}, + }; + } + + @Test(dataProvider="minusValid") + public void test_minusValid(int year, TemporalAmount amount, int expected) { + assertEquals(Year.of(year).minus(amount), Year.of(expected)); + } + + @DataProvider(name="minusInvalidUnit") + Object[][] data_minusInvalidUnit() { + return new Object[][] { + {Period.of(0, 1, 0)}, + {Period.of(0, 0, 1)}, + {Period.of(0, 1, 1)}, + {Period.of(1, 1, 1)}, + {Duration.ofDays(1)}, + {Duration.ofHours(1)}, + {Duration.ofMinutes(1)}, + {Duration.ofSeconds(1)}, + }; + } + + @Test(dataProvider="minusInvalidUnit", expectedExceptions=UnsupportedTemporalTypeException.class) + public void test_minusInvalidUnit(TemporalAmount amount) { + TEST_2008.minus(amount); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_minus_null() { + TEST_2008.minus(null); + } + //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears() { assertEquals(Year.of(2007).minusYears(-1), Year.of(2008)); assertEquals(Year.of(2007).minusYears(0), Year.of(2007)); @@ -488,34 +584,34 @@ public class TCKYear extends AbstractDateTimeTest { assertEquals(Year.of(Year.MIN_VALUE).minusYears(0), Year.of(Year.MIN_VALUE)); } - @Test(groups={"tck"}) + @Test public void test_minusYear_zero_equals() { Year base = Year.of(2007); assertEquals(base.minusYears(0), base); } - @Test(groups={"tck"}) + @Test public void test_minusYears_big() { long years = 20L + Year.MAX_VALUE; assertEquals(Year.of(40).minusYears(years), Year.of((int) (40L - years))); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_max() { Year.of(Year.MAX_VALUE).minusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_maxLots() { Year.of(Year.MAX_VALUE).minusYears(-1000); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_min() { Year.of(Year.MIN_VALUE).minusYears(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_minLots() { Year.of(Year.MIN_VALUE).minusYears(1000); } @@ -523,7 +619,7 @@ public class TCKYear extends AbstractDateTimeTest { //----------------------------------------------------------------------- // adjustInto() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjustDate() { LocalDate base = LocalDate.of(2007, 2, 12); for (int i = -4; i <= 2104; i++) { @@ -532,13 +628,13 @@ public class TCKYear extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_adjustDate_resolve() { Year test = Year.of(2011); assertEquals(test.adjustInto(LocalDate.of(2012, 2, 29)), LocalDate.of(2011, 2, 28)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_adjustDate_nullLocalDate() { Year test = Year.of(1); test.adjustInto((LocalDate) null); @@ -547,7 +643,7 @@ public class TCKYear extends AbstractDateTimeTest { //----------------------------------------------------------------------- // length() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_length() { assertEquals(Year.of(1999).length(), 365); assertEquals(Year.of(2000).length(), 366); @@ -605,6 +701,99 @@ public class TCKYear extends AbstractDateTimeTest { assertEquals(year.isValidMonthDay(monthDay), expected); } + //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + {Year.of(2000), Year.of(-1), YEARS, -2001}, + {Year.of(2000), Year.of(0), YEARS, -2000}, + {Year.of(2000), Year.of(1), YEARS, -1999}, + {Year.of(2000), Year.of(1998), YEARS, -2}, + {Year.of(2000), Year.of(1999), YEARS, -1}, + {Year.of(2000), Year.of(2000), YEARS, 0}, + {Year.of(2000), Year.of(2001), YEARS, 1}, + {Year.of(2000), Year.of(2002), YEARS, 2}, + {Year.of(2000), Year.of(2246), YEARS, 246}, + + {Year.of(2000), Year.of(-1), DECADES, -200}, + {Year.of(2000), Year.of(0), DECADES, -200}, + {Year.of(2000), Year.of(1), DECADES, -199}, + {Year.of(2000), Year.of(1989), DECADES, -1}, + {Year.of(2000), Year.of(1990), DECADES, -1}, + {Year.of(2000), Year.of(1991), DECADES, 0}, + {Year.of(2000), Year.of(2000), DECADES, 0}, + {Year.of(2000), Year.of(2009), DECADES, 0}, + {Year.of(2000), Year.of(2010), DECADES, 1}, + {Year.of(2000), Year.of(2011), DECADES, 1}, + + {Year.of(2000), Year.of(-1), CENTURIES, -20}, + {Year.of(2000), Year.of(0), CENTURIES, -20}, + {Year.of(2000), Year.of(1), CENTURIES, -19}, + {Year.of(2000), Year.of(1899), CENTURIES, -1}, + {Year.of(2000), Year.of(1900), CENTURIES, -1}, + {Year.of(2000), Year.of(1901), CENTURIES, 0}, + {Year.of(2000), Year.of(2000), CENTURIES, 0}, + {Year.of(2000), Year.of(2099), CENTURIES, 0}, + {Year.of(2000), Year.of(2100), CENTURIES, 1}, + {Year.of(2000), Year.of(2101), CENTURIES, 1}, + + {Year.of(2000), Year.of(-1), MILLENNIA, -2}, + {Year.of(2000), Year.of(0), MILLENNIA, -2}, + {Year.of(2000), Year.of(1), MILLENNIA, -1}, + {Year.of(2000), Year.of(999), MILLENNIA, -1}, + {Year.of(2000), Year.of(1000), MILLENNIA, -1}, + {Year.of(2000), Year.of(1001), MILLENNIA, 0}, + {Year.of(2000), Year.of(2000), MILLENNIA, 0}, + {Year.of(2000), Year.of(2999), MILLENNIA, 0}, + {Year.of(2000), Year.of(3000), MILLENNIA, 1}, + {Year.of(2000), Year.of(3001), MILLENNIA, 1}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(Year year1, Year year2, TemporalUnit unit, long expected) { + long amount = year1.periodUntil(year2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(Year year1, Year year2, TemporalUnit unit, long expected) { + long amount = year2.periodUntil(year1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = UnsupportedTemporalTypeException.class) + public void test_periodUntil_TemporalUnit_unsupportedUnit() { + TEST_2008.periodUntil(TEST_2008, MONTHS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_2008.periodUntil(null, DAYS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_2008.periodUntil(TEST_2008, null); + } + + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y"); + String t = Year.of(2010).format(f); + assertEquals(t, "2010"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + Year.of(2010).format(null); + } + //----------------------------------------------------------------------- // atMonth(Month) //----------------------------------------------------------------------- @@ -636,7 +825,7 @@ public class TCKYear extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - // atMonthDay(Month) + // atMonthDay(MonthDay) //----------------------------------------------------------------------- @DataProvider(name="atMonthDay") Object[][] data_atMonthDay() { @@ -661,7 +850,7 @@ public class TCKYear extends AbstractDateTimeTest { //----------------------------------------------------------------------- // atDay(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_atDay_notLeapYear() { Year test = Year.of(2007); LocalDate expected = LocalDate.of(2007, 1, 1); @@ -671,13 +860,13 @@ public class TCKYear extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atDay_notLeapYear_day366() { Year test = Year.of(2007); test.atDay(366); } - @Test(groups={"tck"}) + @Test public void test_atDay_leapYear() { Year test = Year.of(2008); LocalDate expected = LocalDate.of(2008, 1, 1); @@ -687,13 +876,13 @@ public class TCKYear extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atDay_day0() { Year test = Year.of(2007); test.atDay(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_atDay_day367() { Year test = Year.of(2007); test.atDay(367); @@ -702,7 +891,7 @@ public class TCKYear extends AbstractDateTimeTest { //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo() { for (int i = -4; i <= 2104; i++) { Year a = Year.of(i); @@ -734,7 +923,7 @@ public class TCKYear extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_nullYear() { Year doy = null; Year test = Year.of(1); @@ -744,7 +933,7 @@ public class TCKYear extends AbstractDateTimeTest { //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { for (int i = -4; i <= 2104; i++) { Year a = Year.of(i); @@ -756,20 +945,20 @@ public class TCKYear extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_equals_same() { Year test = Year.of(2011); assertEquals(test.equals(test), true); } - @Test(groups={"tck"}) + @Test public void test_equals_nullYear() { Year doy = null; Year test = Year.of(1); assertEquals(test.equals(doy), false); } - @Test(groups={"tck"}) + @Test public void test_equals_incorrectType() { Year test = Year.of(1); assertEquals(test.equals("Incorrect type"), false); @@ -778,7 +967,7 @@ public class TCKYear extends AbstractDateTimeTest { //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString() { for (int i = -4; i <= 2104; i++) { Year a = Year.of(i); @@ -786,19 +975,4 @@ public class TCKYear extends AbstractDateTimeTest { } } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y"); - String t = Year.of(2010).toString(f); - assertEquals(t, "2010"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - Year.of(2010).toString(null); - } - } diff --git a/jdk/test/java/time/tck/java/time/TCKYearMonth.java b/jdk/test/java/time/tck/java/time/TCKYearMonth.java index 3369daccca2..8cbf6c472ca 100644 --- a/jdk/test/java/time/tck/java/time/TCKYearMonth.java +++ b/jdk/test/java/time/tck/java/time/TCKYearMonth.java @@ -59,11 +59,19 @@ */ package tck.java.time; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.ChronoUnit.CENTURIES; +import static java.time.temporal.ChronoUnit.DAYS; +import static java.time.temporal.ChronoUnit.DECADES; +import static java.time.temporal.ChronoUnit.HOURS; +import static java.time.temporal.ChronoUnit.MILLENNIA; +import static java.time.temporal.ChronoUnit.MONTHS; +import static java.time.temporal.ChronoUnit.WEEKS; +import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -78,6 +86,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.Month; +import java.time.Period; import java.time.Year; import java.time.YearMonth; import java.time.ZoneId; @@ -88,10 +97,11 @@ import java.time.format.DateTimeParseException; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -110,7 +120,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { private YearMonth TEST_2008_06; - @BeforeMethod(groups={"tck", "implementation"}) + @BeforeMethod public void setUp() { TEST_2008_06 = YearMonth.of(2008, 6); } @@ -126,7 +136,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { protected List validFields() { TemporalField[] array = { MONTH_OF_YEAR, - EPOCH_MONTH, + PROLEPTIC_MONTH, YEAR_OF_ERA, YEAR, ERA, @@ -171,7 +181,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { YearMonth expected = YearMonth.now(Clock.systemDefaultZone()); YearMonth test = YearMonth.now(); @@ -188,12 +198,12 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { YearMonth.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); YearMonth expected = YearMonth.now(Clock.system(zone)); @@ -211,7 +221,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now_Clock() { Instant instant = LocalDateTime.of(2010, 12, 31, 0, 0).toInstant(ZoneOffset.UTC); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); @@ -220,72 +230,72 @@ public class TCKYearMonth extends AbstractDateTimeTest { assertEquals(test.getMonth(), Month.DECEMBER); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { YearMonth.now((Clock) null); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_intsMonth() { YearMonth test = YearMonth.of(2008, Month.FEBRUARY); check(test, 2008, 2); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_intsMonth_yearTooLow() { YearMonth.of(Year.MIN_VALUE - 1, Month.JANUARY); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_intsMonth_dayTooHigh() { YearMonth.of(Year.MAX_VALUE + 1, Month.JANUARY); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_intsMonth_nullMonth() { YearMonth.of(2008, null); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ints() { YearMonth test = YearMonth.of(2008, 2); check(test, 2008, 2); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_yearTooLow() { YearMonth.of(Year.MIN_VALUE - 1, 2); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_dayTooHigh() { YearMonth.of(Year.MAX_VALUE + 1, 2); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_monthTooLow() { YearMonth.of(2008, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ints_monthTooHigh() { YearMonth.of(2008, 13); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(YearMonth.from(LocalDate.of(2007, 7, 15)), YearMonth.of(2007, 7)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { YearMonth.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { YearMonth.from((TemporalAccessor) null); } @@ -323,7 +333,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { }; } - @Test(dataProvider="goodParseData", groups={"tck"}) + @Test(dataProvider="goodParseData") public void factory_parse_success(String text, YearMonth expected) { YearMonth yearMonth = YearMonth.parse(text); assertEquals(yearMonth, expected); @@ -351,7 +361,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { }; } - @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class) public void factory_parse_fail(String text, int pos) { try { YearMonth.parse(text); @@ -364,12 +374,12 @@ public class TCKYearMonth extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue_Month() { YearMonth.parse("2008-13"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { YearMonth.parse(null); } @@ -377,20 +387,20 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M"); YearMonth test = YearMonth.parse("2010 12", f); assertEquals(test, YearMonth.of(2010, 12)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M"); YearMonth.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { YearMonth.parse("ANY", null); } @@ -400,19 +410,19 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- @Test public void test_get_TemporalField() { - assertEquals(TEST_2008_06.get(ChronoField.YEAR), 2008); - assertEquals(TEST_2008_06.get(ChronoField.MONTH_OF_YEAR), 6); - assertEquals(TEST_2008_06.get(ChronoField.YEAR_OF_ERA), 2008); - assertEquals(TEST_2008_06.get(ChronoField.ERA), 1); + assertEquals(TEST_2008_06.get(YEAR), 2008); + assertEquals(TEST_2008_06.get(MONTH_OF_YEAR), 6); + assertEquals(TEST_2008_06.get(YEAR_OF_ERA), 2008); + assertEquals(TEST_2008_06.get(ERA), 1); } @Test public void test_getLong_TemporalField() { - assertEquals(TEST_2008_06.getLong(ChronoField.YEAR), 2008); - assertEquals(TEST_2008_06.getLong(ChronoField.MONTH_OF_YEAR), 6); - assertEquals(TEST_2008_06.getLong(ChronoField.YEAR_OF_ERA), 2008); - assertEquals(TEST_2008_06.getLong(ChronoField.ERA), 1); - assertEquals(TEST_2008_06.getLong(ChronoField.EPOCH_MONTH), (2008 - 1970) * 12 + 6 - 1); + assertEquals(TEST_2008_06.getLong(YEAR), 2008); + assertEquals(TEST_2008_06.getLong(MONTH_OF_YEAR), 6); + assertEquals(TEST_2008_06.getLong(YEAR_OF_ERA), 2008); + assertEquals(TEST_2008_06.getLong(ERA), 1); + assertEquals(TEST_2008_06.getLong(PROLEPTIC_MONTH), 2008 * 12 + 6 - 1); } //----------------------------------------------------------------------- @@ -421,13 +431,13 @@ public class TCKYearMonth extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2008_06, Queries.chronology(), IsoChronology.INSTANCE}, - {TEST_2008_06, Queries.zoneId(), null}, - {TEST_2008_06, Queries.precision(), ChronoUnit.MONTHS}, - {TEST_2008_06, Queries.zone(), null}, - {TEST_2008_06, Queries.offset(), null}, - {TEST_2008_06, Queries.localDate(), null}, - {TEST_2008_06, Queries.localTime(), null}, + {TEST_2008_06, TemporalQuery.chronology(), IsoChronology.INSTANCE}, + {TEST_2008_06, TemporalQuery.zoneId(), null}, + {TEST_2008_06, TemporalQuery.precision(), ChronoUnit.MONTHS}, + {TEST_2008_06, TemporalQuery.zone(), null}, + {TEST_2008_06, TemporalQuery.offset(), null}, + {TEST_2008_06, TemporalQuery.localDate(), null}, + {TEST_2008_06, TemporalQuery.localTime(), null}, }; } @@ -470,19 +480,19 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // with(Year) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_Year() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.with(Year.of(2000)), YearMonth.of(2000, 6)); } - @Test(groups={"tck"}) + @Test public void test_with_Year_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.with(Year.of(2008)), test); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_Year_null() { YearMonth test = YearMonth.of(2008, 6); test.with((Year) null); @@ -491,19 +501,19 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // with(Month) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_with_Month() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.with(Month.JANUARY), YearMonth.of(2008, 1)); } - @Test(groups={"tck"}) + @Test public void test_with_Month_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.with(Month.JUNE), test); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_with_Month_null() { YearMonth test = YearMonth.of(2008, 6); test.with((Month) null); @@ -512,25 +522,25 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withYear() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.withYear(1999), YearMonth.of(1999, 6)); } - @Test(groups={"tck"}) + @Test public void test_withYear_int_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.withYear(2008), test); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withYear_tooLow() { YearMonth test = YearMonth.of(2008, 6); test.withYear(Year.MIN_VALUE - 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withYear_tooHigh() { YearMonth test = YearMonth.of(2008, 6); test.withYear(Year.MAX_VALUE + 1); @@ -539,25 +549,25 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.withMonth(1), YearMonth.of(2008, 1)); } - @Test(groups={"tck"}) + @Test public void test_withMonth_int_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.withMonth(6), test); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooLow() { YearMonth test = YearMonth.of(2008, 6); test.withMonth(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooHigh() { YearMonth test = YearMonth.of(2008, 6); test.withMonth(13); @@ -566,49 +576,49 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears_long() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusYears(1), YearMonth.of(2009, 6)); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusYears(0), test); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_negative() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusYears(-1), YearMonth.of(2007, 6)); } - @Test(groups={"tck"}) + @Test public void test_plusYears_long_big() { YearMonth test = YearMonth.of(-40, 6); assertEquals(test.plusYears(20L + Year.MAX_VALUE), YearMonth.of((int) (-40L + 20L + Year.MAX_VALUE), 6)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLarge() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 6); test.plusYears(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLargeMaxAddMax() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.plusYears(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooLargeMaxAddMin() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.plusYears(Long.MIN_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusYears_long_invalidTooSmall() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 6); test.plusYears(-1); @@ -617,62 +627,62 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMonths_long() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusMonths(1), YearMonth.of(2008, 7)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusMonths(0), test); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_overYears() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusMonths(7), YearMonth.of(2009, 1)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_negative() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusMonths(-1), YearMonth.of(2008, 5)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_negativeOverYear() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.plusMonths(-6), YearMonth.of(2007, 12)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_long_big() { YearMonth test = YearMonth.of(-40, 6); long months = 20L + Integer.MAX_VALUE; assertEquals(test.plusMonths(months), YearMonth.of((int) (-40L + months / 12), 6 + (int) (months % 12))); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusMonths_long_invalidTooLarge() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.plusMonths(1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_long_invalidTooLargeMaxAddMax() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.plusMonths(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_plusMonths_long_invalidTooLargeMaxAddMin() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.plusMonths(Long.MIN_VALUE); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_plusMonths_long_invalidTooSmall() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 1); test.plusMonths(-1); @@ -681,49 +691,49 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears_long() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusYears(1), YearMonth.of(2007, 6)); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusYears(0), test); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_negative() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusYears(-1), YearMonth.of(2009, 6)); } - @Test(groups={"tck"}) + @Test public void test_minusYears_long_big() { YearMonth test = YearMonth.of(40, 6); assertEquals(test.minusYears(20L + Year.MAX_VALUE), YearMonth.of((int) (40L - 20L - Year.MAX_VALUE), 6)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLarge() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 6); test.minusYears(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLargeMaxSubtractMax() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 12); test.minusYears(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooLargeMaxSubtractMin() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 12); test.minusYears(Long.MIN_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusYears_long_invalidTooSmall() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 6); test.minusYears(1); @@ -732,62 +742,62 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMonths_long() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusMonths(1), YearMonth.of(2008, 5)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_noChange_equal() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusMonths(0), test); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_overYears() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusMonths(6), YearMonth.of(2007, 12)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_negative() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusMonths(-1), YearMonth.of(2008, 7)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_negativeOverYear() { YearMonth test = YearMonth.of(2008, 6); assertEquals(test.minusMonths(-7), YearMonth.of(2009, 1)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_long_big() { YearMonth test = YearMonth.of(40, 6); long months = 20L + Integer.MAX_VALUE; assertEquals(test.minusMonths(months), YearMonth.of((int) (40L - months / 12), 6 - (int) (months % 12))); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusMonths_long_invalidTooLarge() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.minusMonths(-1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_long_invalidTooLargeMaxSubtractMax() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.minusMonths(Long.MAX_VALUE); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_minusMonths_long_invalidTooLargeMaxSubtractMin() { YearMonth test = YearMonth.of(Year.MAX_VALUE, 12); test.minusMonths(Long.MIN_VALUE); } - @Test(expectedExceptions={DateTimeException.class}, groups={"tck"}) + @Test(expectedExceptions={DateTimeException.class}) public void test_minusMonths_long_invalidTooSmall() { YearMonth test = YearMonth.of(Year.MIN_VALUE, 1); test.minusMonths(1); @@ -796,35 +806,35 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // adjustInto() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjustDate() { YearMonth test = YearMonth.of(2008, 6); LocalDate date = LocalDate.of(2007, 1, 1); assertEquals(test.adjustInto(date), LocalDate.of(2008, 6, 1)); } - @Test(groups={"tck"}) + @Test public void test_adjustDate_preserveDoM() { YearMonth test = YearMonth.of(2011, 3); LocalDate date = LocalDate.of(2008, 2, 29); assertEquals(test.adjustInto(date), LocalDate.of(2011, 3, 29)); } - @Test(groups={"tck"}) + @Test public void test_adjustDate_resolve() { YearMonth test = YearMonth.of(2007, 2); LocalDate date = LocalDate.of(2008, 3, 31); assertEquals(test.adjustInto(date), LocalDate.of(2007, 2, 28)); } - @Test(groups={"tck"}) + @Test public void test_adjustDate_equal() { YearMonth test = YearMonth.of(2008, 6); LocalDate date = LocalDate.of(2008, 6, 30); assertEquals(test.adjustInto(date), date); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_adjustDate_null() { TEST_2008_06.adjustInto((LocalDate) null); } @@ -832,7 +842,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // isLeapYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isLeapYear() { assertEquals(YearMonth.of(2007, 6).isLeapYear(), false); assertEquals(YearMonth.of(2008, 6).isLeapYear(), true); @@ -841,19 +851,19 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // lengthOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_lengthOfMonth_june() { YearMonth test = YearMonth.of(2007, 6); assertEquals(test.lengthOfMonth(), 30); } - @Test(groups={"tck"}) + @Test public void test_lengthOfMonth_febNonLeap() { YearMonth test = YearMonth.of(2007, 2); assertEquals(test.lengthOfMonth(), 28); } - @Test(groups={"tck"}) + @Test public void test_lengthOfMonth_febLeap() { YearMonth test = YearMonth.of(2008, 2); assertEquals(test.lengthOfMonth(), 29); @@ -862,7 +872,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // lengthOfYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_lengthOfYear() { assertEquals(YearMonth.of(2007, 6).lengthOfYear(), 365); assertEquals(YearMonth.of(2008, 6).lengthOfYear(), 366); @@ -871,7 +881,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // isValidDay(int) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isValidDay_int_june() { YearMonth test = YearMonth.of(2007, 6); assertEquals(test.isValidDay(1), true); @@ -883,7 +893,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { assertEquals(test.isValidDay(32), false); } - @Test(groups={"tck"}) + @Test public void test_isValidDay_int_febNonLeap() { YearMonth test = YearMonth.of(2007, 2); assertEquals(test.isValidDay(1), true); @@ -895,7 +905,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { assertEquals(test.isValidDay(32), false); } - @Test(groups={"tck"}) + @Test public void test_isValidDay_int_febLeap() { YearMonth test = YearMonth.of(2008, 2); assertEquals(test.isValidDay(1), true); @@ -907,6 +917,127 @@ public class TCKYearMonth extends AbstractDateTimeTest { assertEquals(test.isValidDay(32), false); } + //----------------------------------------------------------------------- + // periodUntil(Temporal, TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name="periodUntilUnit") + Object[][] data_periodUntilUnit() { + return new Object[][] { + {ym(2000, 1), ym(-1, 12), MONTHS, -2000 * 12 - 1}, + {ym(2000, 1), ym(0, 1), MONTHS, -2000 * 12}, + {ym(2000, 1), ym(0, 12), MONTHS, -1999 * 12 - 1}, + {ym(2000, 1), ym(1, 1), MONTHS, -1999 * 12}, + {ym(2000, 1), ym(1999, 12), MONTHS, -1}, + {ym(2000, 1), ym(2000, 1), MONTHS, 0}, + {ym(2000, 1), ym(2000, 2), MONTHS, 1}, + {ym(2000, 1), ym(2000, 3), MONTHS, 2}, + {ym(2000, 1), ym(2000, 12), MONTHS, 11}, + {ym(2000, 1), ym(2001, 1), MONTHS, 12}, + {ym(2000, 1), ym(2246, 5), MONTHS, 246 * 12 + 4}, + + {ym(2000, 1), ym(-1, 12), YEARS, -2000}, + {ym(2000, 1), ym(0, 1), YEARS, -2000}, + {ym(2000, 1), ym(0, 12), YEARS, -1999}, + {ym(2000, 1), ym(1, 1), YEARS, -1999}, + {ym(2000, 1), ym(1998, 12), YEARS, -1}, + {ym(2000, 1), ym(1999, 1), YEARS, -1}, + {ym(2000, 1), ym(1999, 2), YEARS, 0}, + {ym(2000, 1), ym(1999, 12), YEARS, 0}, + {ym(2000, 1), ym(2000, 1), YEARS, 0}, + {ym(2000, 1), ym(2000, 2), YEARS, 0}, + {ym(2000, 1), ym(2000, 12), YEARS, 0}, + {ym(2000, 1), ym(2001, 1), YEARS, 1}, + {ym(2000, 1), ym(2246, 5), YEARS, 246}, + + {ym(2000, 5), ym(-1, 5), DECADES, -200}, + {ym(2000, 5), ym(0, 4), DECADES, -200}, + {ym(2000, 5), ym(0, 5), DECADES, -200}, + {ym(2000, 5), ym(0, 6), DECADES, -199}, + {ym(2000, 5), ym(1, 5), DECADES, -199}, + {ym(2000, 5), ym(1990, 4), DECADES, -1}, + {ym(2000, 5), ym(1990, 5), DECADES, -1}, + {ym(2000, 5), ym(1990, 6), DECADES, 0}, + {ym(2000, 5), ym(2000, 4), DECADES, 0}, + {ym(2000, 5), ym(2000, 5), DECADES, 0}, + {ym(2000, 5), ym(2000, 6), DECADES, 0}, + {ym(2000, 5), ym(2010, 4), DECADES, 0}, + {ym(2000, 5), ym(2010, 5), DECADES, 1}, + {ym(2000, 5), ym(2010, 6), DECADES, 1}, + + {ym(2000, 5), ym(-1, 5), CENTURIES, -20}, + {ym(2000, 5), ym(0, 4), CENTURIES, -20}, + {ym(2000, 5), ym(0, 5), CENTURIES, -20}, + {ym(2000, 5), ym(0, 6), CENTURIES, -19}, + {ym(2000, 5), ym(1, 5), CENTURIES, -19}, + {ym(2000, 5), ym(1900, 4), CENTURIES, -1}, + {ym(2000, 5), ym(1900, 5), CENTURIES, -1}, + {ym(2000, 5), ym(1900, 6), CENTURIES, 0}, + {ym(2000, 5), ym(2000, 4), CENTURIES, 0}, + {ym(2000, 5), ym(2000, 5), CENTURIES, 0}, + {ym(2000, 5), ym(2000, 6), CENTURIES, 0}, + {ym(2000, 5), ym(2100, 4), CENTURIES, 0}, + {ym(2000, 5), ym(2100, 5), CENTURIES, 1}, + {ym(2000, 5), ym(2100, 6), CENTURIES, 1}, + + {ym(2000, 5), ym(-1, 5), MILLENNIA, -2}, + {ym(2000, 5), ym(0, 4), MILLENNIA, -2}, + {ym(2000, 5), ym(0, 5), MILLENNIA, -2}, + {ym(2000, 5), ym(0, 6), MILLENNIA, -1}, + {ym(2000, 5), ym(1, 5), MILLENNIA, -1}, + {ym(2000, 5), ym(1000, 4), MILLENNIA, -1}, + {ym(2000, 5), ym(1000, 5), MILLENNIA, -1}, + {ym(2000, 5), ym(1000, 6), MILLENNIA, 0}, + {ym(2000, 5), ym(2000, 4), MILLENNIA, 0}, + {ym(2000, 5), ym(2000, 5), MILLENNIA, 0}, + {ym(2000, 5), ym(2000, 6), MILLENNIA, 0}, + {ym(2000, 5), ym(3000, 4), MILLENNIA, 0}, + {ym(2000, 5), ym(3000, 5), MILLENNIA, 1}, + {ym(2000, 5), ym(3000, 5), MILLENNIA, 1}, + }; + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) { + long amount = ym1.periodUntil(ym2, unit); + assertEquals(amount, expected); + } + + @Test(dataProvider="periodUntilUnit") + public void test_periodUntil_TemporalUnit_negated(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) { + long amount = ym2.periodUntil(ym1, unit); + assertEquals(amount, -expected); + } + + @Test(expectedExceptions = UnsupportedTemporalTypeException.class) + public void test_periodUntil_TemporalUnit_unsupportedUnit() { + TEST_2008_06.periodUntil(TEST_2008_06, HOURS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullEnd() { + TEST_2008_06.periodUntil(null, DAYS); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_periodUntil_TemporalUnit_nullUnit() { + TEST_2008_06.periodUntil(TEST_2008_06, null); + } + + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y M"); + String t = YearMonth.of(2010, 12).format(f); + assertEquals(t, "2010 12"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + YearMonth.of(2010, 12).format(null); + } + //----------------------------------------------------------------------- // atDay(int) //----------------------------------------------------------------------- @@ -975,7 +1106,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_comparisons() { doTest_comparisons_YearMonth( YearMonth.of(-1, 1), @@ -1015,17 +1146,17 @@ public class TCKYearMonth extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { TEST_2008_06.compareTo(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_ObjectNull() { TEST_2008_06.isBefore(null); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_ObjectNull() { TEST_2008_06.isAfter(null); } @@ -1033,7 +1164,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { YearMonth a = YearMonth.of(2008, 6); YearMonth b = YearMonth.of(2008, 6); @@ -1061,17 +1192,17 @@ public class TCKYearMonth extends AbstractDateTimeTest { assertEquals(d.equals(d), true); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_2008_06.equals(TEST_2008_06), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_2008_06.equals("2007-07-15"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { assertEquals(TEST_2008_06.equals(null), false); } @@ -1079,7 +1210,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"tck"}) + @Test(dataProvider="sampleDates") public void test_hashCode(int y, int m) { YearMonth a = YearMonth.of(y, m); assertEquals(a.hashCode(), a.hashCode()); @@ -1087,7 +1218,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_hashCode_unique() { Set uniques = new HashSet(201 * 12); for (int i = 1900; i <= 2100; i++) { @@ -1111,26 +1242,15 @@ public class TCKYearMonth extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int y, int m, String expected) { YearMonth test = YearMonth.of(y, m); String str = test.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y M"); - String t = YearMonth.of(2010, 12).toString(f); - assertEquals(t, "2010 12"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - YearMonth.of(2010, 12).toString(null); + private YearMonth ym(int year, int month) { + return YearMonth.of(year, month); } } diff --git a/jdk/test/java/time/tck/java/time/TCKZoneId.java b/jdk/test/java/time/tck/java/time/TCKZoneId.java index bc6944a8854..dd37d804dff 100644 --- a/jdk/test/java/time/tck/java/time/TCKZoneId.java +++ b/jdk/test/java/time/tck/java/time/TCKZoneId.java @@ -64,23 +64,24 @@ import static org.testng.Assert.fail; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; import java.io.DataOutputStream; -import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectStreamConstants; import java.lang.reflect.Field; import java.time.DateTimeException; +import java.time.Instant; import java.time.LocalTime; import java.time.ZoneId; import java.time.ZoneOffset; -import java.time.temporal.Queries; +import java.time.format.TextStyle; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; import java.time.zone.ZoneRulesException; import java.util.HashMap; +import java.util.Locale; import java.util.Map; +import java.util.Set; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -114,9 +115,12 @@ public class TCKZoneId extends AbstractTCKTest { // an ID can be loaded without validation during deserialization String id = "QWERTYUIOPASDFGHJKLZXCVBNM~/._+-"; ZoneId deser = deserialize(id); - // getting the ID and string are OK + // getId, equals, hashCode, toString and normalized are OK assertEquals(deser.getId(), id); assertEquals(deser.toString(), id); + assertEquals(deser, deser); + assertEquals(deser.hashCode(), deser.hashCode()); + assertEquals(deser.normalized(), deser); // getting the rules is not try { deser.getRules(); @@ -133,32 +137,32 @@ public class TCKZoneId extends AbstractTCKTest { deserialize("|!?"); } - @Test(dataProvider="offsetBasedValid", expectedExceptions=DateTimeException.class) + @Test(dataProvider="offsetBasedValid") public void test_deserialization_lenient_offsetNotAllowed_noPrefix(String input, String resolvedId) throws Exception { - // an ID can be loaded without validation during deserialization - // but there is a check to ensure the ID format is valid - deserialize(input); + ZoneId deserialized = deserialize(input); + assertEquals(deserialized, ZoneId.of(input)); + assertEquals(deserialized, ZoneId.of(resolvedId)); } - @Test(dataProvider="offsetBasedValid", expectedExceptions=DateTimeException.class) - public void test_deserialization_lenient_offsetNotAllowed_prefixUTC(String input, String resolvedId) throws Exception { - // an ID can be loaded without validation during deserialization - // but there is a check to ensure the ID format is valid - deserialize("UTC" + input); + @Test(dataProvider="offsetBasedValidPrefix") + public void test_deserialization_lenient_offsetNotAllowed_prefixUTC(String input, String resolvedId, String offsetId) throws Exception { + ZoneId deserialized = deserialize("UTC" + input); + assertEquals(deserialized, ZoneId.of("UTC" + input)); + assertEquals(deserialized, ZoneId.of("UTC" + resolvedId)); } - @Test(dataProvider="offsetBasedValid", expectedExceptions=DateTimeException.class) - public void test_deserialization_lenient_offsetNotAllowed_prefixGMT(String input, String resolvedId) throws Exception { - // an ID can be loaded without validation during deserialization - // but there is a check to ensure the ID format is valid - deserialize("GMT" + input); + @Test(dataProvider="offsetBasedValidPrefix") + public void test_deserialization_lenient_offsetNotAllowed_prefixGMT(String input, String resolvedId, String offsetId) throws Exception { + ZoneId deserialized = deserialize("GMT" + input); + assertEquals(deserialized, ZoneId.of("GMT" + input)); + assertEquals(deserialized, ZoneId.of("GMT" + resolvedId)); } - @Test(dataProvider="offsetBasedValid", expectedExceptions=DateTimeException.class) - public void test_deserialization_lenient_offsetNotAllowed_prefixUT(String input, String resolvedId) throws Exception { - // an ID can be loaded without validation during deserialization - // but there is a check to ensure the ID format is valid - deserialize("UT" + input); + @Test(dataProvider="offsetBasedValidPrefix") + public void test_deserialization_lenient_offsetNotAllowed_prefixUT(String input, String resolvedId, String offsetId) throws Exception { + ZoneId deserialized = deserialize("UT" + input); + assertEquals(deserialized, ZoneId.of("UT" + input)); + assertEquals(deserialized, ZoneId.of("UT" + resolvedId)); } private ZoneId deserialize(String id) throws Exception { @@ -193,10 +197,10 @@ public class TCKZoneId extends AbstractTCKTest { } //----------------------------------------------------------------------- - // OLD_IDS_PRE_2005 + // OLD_SHORT_IDS //----------------------------------------------------------------------- public void test_constant_OLD_IDS_PRE_2005() { - Map ids = ZoneId.OLD_IDS_PRE_2005; + Map ids = ZoneId.OLD_SHORT_IDS; assertEquals(ids.get("EST"), "America/New_York"); assertEquals(ids.get("MST"), "America/Denver"); assertEquals(ids.get("HST"), "Pacific/Honolulu"); @@ -229,15 +233,15 @@ public class TCKZoneId extends AbstractTCKTest { @Test(expectedExceptions=UnsupportedOperationException.class) public void test_constant_OLD_IDS_PRE_2005_immutable() { - Map ids = ZoneId.OLD_IDS_PRE_2005; + Map ids = ZoneId.OLD_SHORT_IDS; ids.clear(); } //----------------------------------------------------------------------- - // OLD_IDS_POST_2005 + // SHORT_IDS //----------------------------------------------------------------------- public void test_constant_OLD_IDS_POST_2005() { - Map ids = ZoneId.OLD_IDS_POST_2005; + Map ids = ZoneId.SHORT_IDS; assertEquals(ids.get("EST"), "-05:00"); assertEquals(ids.get("MST"), "-07:00"); assertEquals(ids.get("HST"), "-10:00"); @@ -270,10 +274,23 @@ public class TCKZoneId extends AbstractTCKTest { @Test(expectedExceptions=UnsupportedOperationException.class) public void test_constant_OLD_IDS_POST_2005_immutable() { - Map ids = ZoneId.OLD_IDS_POST_2005; + Map ids = ZoneId.SHORT_IDS; ids.clear(); } + //----------------------------------------------------------------------- + // getAvailableZoneIds() + //----------------------------------------------------------------------- + @Test + public void test_getAvailableGroupIds() { + Set zoneIds = ZoneId.getAvailableZoneIds(); + assertEquals(zoneIds.contains("Europe/London"), true); + zoneIds.clear(); + assertEquals(zoneIds.size(), 0); + Set zoneIds2 = ZoneId.getAvailableZoneIds(); + assertEquals(zoneIds2.contains("Europe/London"), true); + } + //----------------------------------------------------------------------- // mapped factory //----------------------------------------------------------------------- @@ -315,65 +332,41 @@ public class TCKZoneId extends AbstractTCKTest { } //----------------------------------------------------------------------- - // regular factory - //----------------------------------------------------------------------- - @DataProvider(name="offsetBasedZero") - Object[][] data_offsetBasedZero() { - return new Object[][] { - {""}, {"0"}, - {"+00"},{"+0000"},{"+00:00"},{"+000000"},{"+00:00:00"}, - {"-00"},{"-0000"},{"-00:00"},{"-000000"},{"-00:00:00"}, - }; - } - - @Test(dataProvider="offsetBasedZero") - public void factory_of_String_offsetBasedZero_noPrefix(String id) { - if (id.length() > 0 && id.equals("0") == false) { - ZoneId test = ZoneId.of(id); - assertEquals(test, ZoneOffset.UTC); - } - } - - @Test(dataProvider="offsetBasedZero") - public void factory_of_String_offsetBasedZero_prefixUTC(String id) { - ZoneId test = ZoneId.of("UTC" + id); - assertEquals(test, ZoneOffset.UTC); - } - - @Test(dataProvider="offsetBasedZero") - public void factory_of_String_offsetBasedZero_prefixGMT(String id) { - ZoneId test = ZoneId.of("GMT" + id); - assertEquals(test, ZoneOffset.UTC); - } - - @Test(dataProvider="offsetBasedZero") - public void factory_of_String_offsetBasedZero_prefixUT(String id) { - ZoneId test = ZoneId.of("UT" + id); - assertEquals(test, ZoneOffset.UTC); - } - - @Test - public void factory_of_String_offsetBasedZero_z() { - ZoneId test = ZoneId.of("Z"); - assertEquals(test, ZoneOffset.UTC); - } - + // regular factory and .normalized() //----------------------------------------------------------------------- @DataProvider(name="offsetBasedValid") Object[][] data_offsetBasedValid() { return new Object[][] { + {"Z", "Z"}, {"+0", "Z"}, + {"-0", "Z"}, + {"+00", "Z"}, + {"+0000", "Z"}, + {"+00:00", "Z"}, + {"+000000", "Z"}, + {"+00:00:00", "Z"}, + {"-00", "Z"}, + {"-0000", "Z"}, + {"-00:00", "Z"}, + {"-000000", "Z"}, + {"-00:00:00", "Z"}, {"+5", "+05:00"}, {"+01", "+01:00"}, - {"+0100", "+01:00"},{"+01:00", "+01:00"}, - {"+010000", "+01:00"},{"+01:00:00", "+01:00"}, + {"+0100", "+01:00"}, + {"+01:00", "+01:00"}, + {"+010000", "+01:00"}, + {"+01:00:00", "+01:00"}, {"+12", "+12:00"}, - {"+1234", "+12:34"},{"+12:34", "+12:34"}, - {"+123456", "+12:34:56"},{"+12:34:56", "+12:34:56"}, + {"+1234", "+12:34"}, + {"+12:34", "+12:34"}, + {"+123456", "+12:34:56"}, + {"+12:34:56", "+12:34:56"}, {"-02", "-02:00"}, {"-5", "-05:00"}, - {"-0200", "-02:00"},{"-02:00", "-02:00"}, - {"-020000", "-02:00"},{"-02:00:00", "-02:00"}, + {"-0200", "-02:00"}, + {"-02:00", "-02:00"}, + {"-020000", "-02:00"}, + {"-02:00:00", "-02:00"}, }; } @@ -382,27 +375,126 @@ public class TCKZoneId extends AbstractTCKTest { ZoneId test = ZoneId.of(input); assertEquals(test.getId(), id); assertEquals(test, ZoneOffset.of(id)); + assertEquals(test.normalized(), ZoneOffset.of(id)); + assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), id); + assertEquals(test.getRules().isFixedOffset(), true); + assertEquals(test.getRules().getOffset(Instant.EPOCH), ZoneOffset.of(id)); } - @Test(dataProvider="offsetBasedValid") - public void factory_of_String_offsetBasedValid_prefixUTC(String input, String id) { + //----------------------------------------------------------------------- + @DataProvider(name="offsetBasedValidPrefix") + Object[][] data_offsetBasedValidPrefix() { + return new Object[][] { + {"", "", "Z"}, + {"+0", "", "Z"}, + {"-0", "", "Z"}, + {"+00", "", "Z"}, + {"+0000", "", "Z"}, + {"+00:00", "", "Z"}, + {"+000000", "", "Z"}, + {"+00:00:00", "", "Z"}, + {"-00", "", "Z"}, + {"-0000", "", "Z"}, + {"-00:00", "", "Z"}, + {"-000000", "", "Z"}, + {"-00:00:00", "", "Z"}, + {"+5", "+05:00", "+05:00"}, + {"+01", "+01:00", "+01:00"}, + {"+0100", "+01:00", "+01:00"}, + {"+01:00", "+01:00", "+01:00"}, + {"+010000", "+01:00", "+01:00"}, + {"+01:00:00", "+01:00", "+01:00"}, + {"+12", "+12:00", "+12:00"}, + {"+1234", "+12:34", "+12:34"}, + {"+12:34", "+12:34", "+12:34"}, + {"+123456", "+12:34:56", "+12:34:56"}, + {"+12:34:56", "+12:34:56", "+12:34:56"}, + {"-02", "-02:00", "-02:00"}, + {"-5", "-05:00", "-05:00"}, + {"-0200", "-02:00", "-02:00"}, + {"-02:00", "-02:00", "-02:00"}, + {"-020000", "-02:00", "-02:00"}, + {"-02:00:00", "-02:00", "-02:00"}, + }; + } + + @Test(dataProvider="offsetBasedValidPrefix") + public void factory_of_String_offsetBasedValid_prefixUTC(String input, String id, String offsetId) { ZoneId test = ZoneId.of("UTC" + input); - assertEquals(test.getId(), id); - assertEquals(test, ZoneOffset.of(id)); + assertEquals(test.getId(), "UTC" + id); + assertEquals(test.getRules(), ZoneOffset.of(offsetId).getRules()); + assertEquals(test.normalized(), ZoneOffset.of(offsetId)); + assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), displayName("UTC" + id)); + assertEquals(test.getRules().isFixedOffset(), true); + assertEquals(test.getRules().getOffset(Instant.EPOCH), ZoneOffset.of(offsetId)); } - @Test(dataProvider="offsetBasedValid") - public void factory_of_String_offsetBasedValid_prefixGMT(String input, String id) { + @Test(dataProvider="offsetBasedValidPrefix") + public void factory_of_String_offsetBasedValid_prefixGMT(String input, String id, String offsetId) { ZoneId test = ZoneId.of("GMT" + input); - assertEquals(test.getId(), id); - assertEquals(test, ZoneOffset.of(id)); + assertEquals(test.getId(), "GMT" + id); + assertEquals(test.getRules(), ZoneOffset.of(offsetId).getRules()); + assertEquals(test.normalized(), ZoneOffset.of(offsetId)); + assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), displayName("GMT" + id)); + assertEquals(test.getRules().isFixedOffset(), true); + assertEquals(test.getRules().getOffset(Instant.EPOCH), ZoneOffset.of(offsetId)); } - @Test(dataProvider="offsetBasedValid") - public void factory_of_String_offsetBasedValid_prefixUT(String input, String id) { + @Test(dataProvider="offsetBasedValidPrefix") + public void factory_of_String_offsetBasedValid_prefixUT(String input, String id, String offsetId) { ZoneId test = ZoneId.of("UT" + input); - assertEquals(test.getId(), id); - assertEquals(test, ZoneOffset.of(id)); + assertEquals(test.getId(), "UT" + id); + assertEquals(test.getRules(), ZoneOffset.of(offsetId).getRules()); + assertEquals(test.normalized(), ZoneOffset.of(offsetId)); + assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), displayName("UT" + id)); + assertEquals(test.getRules().isFixedOffset(), true); + assertEquals(test.getRules().getOffset(Instant.EPOCH), ZoneOffset.of(offsetId)); + } + + private String displayName(String id) { + if (id.equals("GMT")) { + return "Greenwich Mean Time"; + } + if (id.equals("GMT0")) { + return "Greenwich Mean Time"; + } + if (id.equals("UTC")) { + return "Coordinated Universal Time"; + } + return id; + } + + //----------------------------------------------------------------------- + @DataProvider(name="offsetBasedValidOther") + Object[][] data_offsetBasedValidOther() { + return new Object[][] { + {"GMT", "Z"}, + {"GMT0", "Z"}, + {"UCT", "Z"}, + {"Greenwich", "Z"}, + {"Universal", "Z"}, + {"Zulu", "Z"}, + {"Etc/GMT", "Z"}, + {"Etc/GMT+0", "Z"}, + {"Etc/GMT+1", "-01:00"}, + {"Etc/GMT-1", "+01:00"}, + {"Etc/GMT+9", "-09:00"}, + {"Etc/GMT-9", "+09:00"}, + {"Etc/GMT0", "Z"}, + {"Etc/UCT", "Z"}, + {"Etc/UTC", "Z"}, + {"Etc/Greenwich", "Z"}, + {"Etc/Universal", "Z"}, + {"Etc/Zulu", "Z"}, + }; + } + + @Test(dataProvider="offsetBasedValidOther") + public void factory_of_String_offsetBasedValidOther(String input, String offsetId) { + ZoneId test = ZoneId.of(input); + assertEquals(test.getId(), input); + assertEquals(test.getRules(), ZoneOffset.of(offsetId).getRules()); + assertEquals(test.normalized(), ZoneOffset.of(offsetId)); } //----------------------------------------------------------------------- @@ -422,6 +514,12 @@ public class TCKZoneId extends AbstractTCKTest { {"-19"}, {"-19:00"}, {"-18:01"}, {"-18:00:01"}, {"-1801"}, {"-180001"}, {"-01_00"}, {"-01;00"}, {"-01@00"}, {"-01:AA"}, {"@01:00"}, + {"0"}, + {"UT0"}, + {"UTZ"}, + {"UTC0"}, + {"UTCZ"}, + {"GMTZ"}, // GMT0 is valid in ZoneRulesProvider }; } @@ -440,6 +538,9 @@ public class TCKZoneId extends AbstractTCKTest { @Test(dataProvider="offsetBasedInvalid", expectedExceptions=DateTimeException.class) public void factory_of_String_offsetBasedInvalid_prefixGMT(String id) { + if (id.equals("0")) { + throw new DateTimeException("Fake exception: GMT0 is valid, not invalid"); + } ZoneId.of("GMT" + id); } @@ -479,6 +580,7 @@ public class TCKZoneId extends AbstractTCKTest { ZoneId test = ZoneId.of("Europe/London"); assertEquals(test.getId(), "Europe/London"); assertEquals(test.getRules().isFixedOffset(), false); + assertEquals(test.normalized(), test); } //----------------------------------------------------------------------- @@ -514,7 +616,7 @@ public class TCKZoneId extends AbstractTCKTest { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { + if (query == TemporalQuery.zoneId()) { return (R) ZoneId.of("Europe/Paris"); } return TemporalAccessor.super.query(query); @@ -578,8 +680,10 @@ public class TCKZoneId extends AbstractTCKTest { {"Europe/London", "Europe/London"}, {"Europe/Paris", "Europe/Paris"}, {"Europe/Berlin", "Europe/Berlin"}, - {"UTC", "Z"}, - {"UTC+01:00", "+01:00"}, + {"Z", "Z"}, + {"+01:00", "+01:00"}, + {"UTC", "UTC"}, + {"UTC+01:00", "UTC+01:00"}, }; } diff --git a/jdk/test/java/time/tck/java/time/TCKZoneOffset.java b/jdk/test/java/time/tck/java/time/TCKZoneOffset.java index c8fb56bf63b..18882df474e 100644 --- a/jdk/test/java/time/tck/java/time/TCKZoneOffset.java +++ b/jdk/test/java/time/tck/java/time/TCKZoneOffset.java @@ -77,7 +77,6 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.temporal.ChronoField; import java.time.temporal.JulianFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -183,7 +182,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { //----------------------------------------------------------------------- // of(String) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_string_UTC() { String[] values = new String[] { "Z", "+0", @@ -196,7 +195,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_factory_string_invalid() { String[] values = new String[] { "","A","B","C","D","E","F","G","H","I","J","K","L","M", @@ -223,13 +222,13 @@ public class TCKZoneOffset extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_string_null() { ZoneOffset.of((String) null); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_string_singleDigitHours() { for (int i = -9; i <= 9; i++) { String str = (i < 0 ? "-" : "+") + Math.abs(i); @@ -238,7 +237,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_factory_string_hours() { for (int i = -18; i <= 18; i++) { String str = (i < 0 ? "-" : "+") + Integer.toString(Math.abs(i) + 100).substring(1); @@ -247,7 +246,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_factory_string_hours_minutes_noColon() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -266,7 +265,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { doTestOffset(test2, 18, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_factory_string_hours_minutes_colon() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -285,7 +284,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { doTestOffset(test2, 18, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_factory_string_hours_minutes_seconds_noColon() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -308,7 +307,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { doTestOffset(test2, 18, 0, 0); } - @Test(groups={"tck"}) + @Test public void test_factory_string_hours_minutes_seconds_colon() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -332,7 +331,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_hours() { for (int i = -18; i <= 18; i++) { ZoneOffset test = ZoneOffset.ofHours(i); @@ -340,18 +339,18 @@ public class TCKZoneOffset extends AbstractDateTimeTest { } } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_tooBig() { ZoneOffset.ofHours(19); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_tooSmall() { ZoneOffset.ofHours(-19); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_hours_minutes() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -367,18 +366,18 @@ public class TCKZoneOffset extends AbstractDateTimeTest { doTestOffset(test2, 18, 0, 0); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_tooBig() { ZoneOffset.ofHoursMinutes(19, 0); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_tooSmall() { ZoneOffset.ofHoursMinutes(-19, 0); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_int_hours_minutes_seconds() { for (int i = -17; i <= 17; i++) { for (int j = -59; j <= 59; j++) { @@ -397,80 +396,80 @@ public class TCKZoneOffset extends AbstractDateTimeTest { doTestOffset(test2, 18, 0, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_plusHoursMinusMinutes() { ZoneOffset.ofHoursMinutesSeconds(1, -1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_plusHoursMinusSeconds() { ZoneOffset.ofHoursMinutesSeconds(1, 0, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_minusHoursPlusMinutes() { ZoneOffset.ofHoursMinutesSeconds(-1, 1, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_minusHoursPlusSeconds() { ZoneOffset.ofHoursMinutesSeconds(-1, 0, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_zeroHoursMinusMinutesPlusSeconds() { ZoneOffset.ofHoursMinutesSeconds(0, -1, 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_zeroHoursPlusMinutesMinusSeconds() { ZoneOffset.ofHoursMinutesSeconds(0, 1, -1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_minutesTooLarge() { ZoneOffset.ofHoursMinutesSeconds(0, 60, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_minutesTooSmall() { ZoneOffset.ofHoursMinutesSeconds(0, -60, 0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_secondsTooLarge() { ZoneOffset.ofHoursMinutesSeconds(0, 0, 60); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_secondsTooSmall() { ZoneOffset.ofHoursMinutesSeconds(0, 0, 60); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_hoursTooBig() { ZoneOffset.ofHoursMinutesSeconds(19, 0, 0); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_int_hours_minutes_seconds_hoursTooSmall() { ZoneOffset.ofHoursMinutesSeconds(-19, 0, 0); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_ofTotalSeconds() { assertEquals(ZoneOffset.ofTotalSeconds(60 * 60 + 1), ZoneOffset.ofHoursMinutesSeconds(1, 0, 1)); assertEquals(ZoneOffset.ofTotalSeconds(18 * 60 * 60), ZoneOffset.ofHours(18)); assertEquals(ZoneOffset.ofTotalSeconds(-18 * 60 * 60), ZoneOffset.ofHours(-18)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ofTotalSeconds_tooLarge() { ZoneOffset.ofTotalSeconds(18 * 60 * 60 + 1); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_ofTotalSeconds_tooSmall() { ZoneOffset.ofTotalSeconds(-18 * 60 * 60 - 1); } @@ -478,18 +477,18 @@ public class TCKZoneOffset extends AbstractDateTimeTest { //----------------------------------------------------------------------- // from() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_factory_CalendricalObject() { assertEquals(ZoneOffset.from(ZonedDateTime.of(LocalDateTime.of(LocalDate.of(2007, 7, 15), LocalTime.of(17, 30)), ZoneOffset.ofHours(2))), ZoneOffset.ofHours(2)); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_factory_CalendricalObject_invalid_noDerive() { ZoneOffset.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_CalendricalObject_null() { ZoneOffset.from((TemporalAccessor) null); } @@ -497,7 +496,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { //----------------------------------------------------------------------- // getTotalSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getTotalSeconds() { ZoneOffset offset = ZoneOffset.ofTotalSeconds(60 * 60 + 1); assertEquals(offset.getTotalSeconds(), 60 * 60 + 1); @@ -506,7 +505,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { //----------------------------------------------------------------------- // getId() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getId() { ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(1, 0, 0); assertEquals(offset.getId(), "+01:00"); @@ -519,7 +518,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { //----------------------------------------------------------------------- // getRules() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getRules() { ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3); assertEquals(offset.getRules().isFixedOffset(), true); @@ -562,13 +561,13 @@ public class TCKZoneOffset extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {ZoneOffset.UTC, Queries.chronology(), null}, - {ZoneOffset.UTC, Queries.zoneId(), null}, - {ZoneOffset.UTC, Queries.precision(), null}, - {ZoneOffset.UTC, Queries.zone(), ZoneOffset.UTC}, - {ZoneOffset.UTC, Queries.offset(), ZoneOffset.UTC}, - {ZoneOffset.UTC, Queries.localDate(), null}, - {ZoneOffset.UTC, Queries.localTime(), null}, + {ZoneOffset.UTC, TemporalQuery.chronology(), null}, + {ZoneOffset.UTC, TemporalQuery.zoneId(), null}, + {ZoneOffset.UTC, TemporalQuery.precision(), null}, + {ZoneOffset.UTC, TemporalQuery.zone(), ZoneOffset.UTC}, + {ZoneOffset.UTC, TemporalQuery.offset(), ZoneOffset.UTC}, + {ZoneOffset.UTC, TemporalQuery.localDate(), null}, + {ZoneOffset.UTC, TemporalQuery.localTime(), null}, }; } @@ -590,7 +589,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo() { ZoneOffset offset1 = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3); ZoneOffset offset2 = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4); @@ -603,7 +602,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { ZoneOffset offset1 = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3); ZoneOffset offset2 = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4); @@ -623,7 +622,7 @@ public class TCKZoneOffset extends AbstractDateTimeTest { //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString() { ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(1, 0, 0); assertEquals(offset.toString(), "+01:00"); diff --git a/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java b/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java index 9841fc8e849..3bf1dbfa6e6 100644 --- a/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java +++ b/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java @@ -59,8 +59,6 @@ */ package tck.java.time; -import java.time.*; - import static java.time.Month.JANUARY; import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; @@ -73,7 +71,6 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.HOUR_OF_AMPM; import static java.time.temporal.ChronoField.HOUR_OF_DAY; @@ -88,6 +85,7 @@ import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.NANO_OF_DAY; import static java.time.temporal.ChronoField.NANO_OF_SECOND; import static java.time.temporal.ChronoField.OFFSET_SECONDS; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.SECOND_OF_DAY; import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; import static java.time.temporal.ChronoField.YEAR; @@ -103,29 +101,36 @@ import static org.testng.Assert.assertTrue; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.time.Clock; +import java.time.DateTimeException; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.Month; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.Period; +import java.time.Year; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.chrono.IsoChronology; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.time.temporal.ChronoField; +import java.time.temporal.ChronoUnit; +import java.time.temporal.JulianFields; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAdjuster; +import java.time.temporal.TemporalAmount; +import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.time.temporal.ChronoField; -import java.time.temporal.ChronoUnit; -import java.time.temporal.Queries; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalAdjuster; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalQuery; -import java.time.temporal.TemporalField; -import java.time.chrono.IsoChronology; -import java.time.temporal.JulianFields; -import test.java.time.temporal.MockFieldNoValue; - -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeParseException; -import java.time.OffsetDateTime; -import java.time.Year; - import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -153,7 +158,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { private ZonedDateTime TEST_DATE_TIME; private ZonedDateTime TEST_DATE_TIME_PARIS; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_LOCAL_2008_06_30_11_30_59_500 = LocalDateTime.of(2008, 6, 30, 11, 30, 59, 500); TEST_DATE_TIME = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); @@ -196,7 +201,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { ALIGNED_WEEK_OF_MONTH, ALIGNED_WEEK_OF_YEAR, MONTH_OF_YEAR, - EPOCH_MONTH, + PROLEPTIC_MONTH, YEAR_OF_ERA, YEAR, ERA, @@ -267,7 +272,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void now() { ZonedDateTime expected = ZonedDateTime.now(Clock.systemDefaultZone()); ZonedDateTime test = ZonedDateTime.now(); @@ -284,12 +289,12 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(ZoneId) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_ZoneId_nullZoneId() { ZonedDateTime.now((ZoneId) null); } - @Test(groups={"tck"}) + @Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); ZonedDateTime expected = ZonedDateTime.now(Clock.system(zone)); @@ -307,12 +312,12 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // now(Clock) //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void now_Clock_nullClock() { - ZonedDateTime.now((Clock)null); + ZonedDateTime.now((Clock) null); } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_utc() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L); @@ -330,7 +335,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_zone() { ZoneId zone = ZoneId.of("Europe/London"); for (int i = 0; i < (2 * 24 * 60 * 60); i++) { @@ -342,7 +347,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_allSecsInDay_beforeEpoch() { LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L); for (int i =-1; i >= -(24 * 60 * 60); i--) { @@ -359,7 +364,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void now_Clock_offsets() { ZonedDateTime base = ZonedDateTime.of(LocalDateTime.of(1970, 1, 1, 12, 0), ZoneOffset.UTC); for (int i = -9; i < 15; i++) { @@ -393,35 +398,35 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // of(LocalDate, LocalTime, ZoneId) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateLocalTime() { ZonedDateTime test = ZonedDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 10, 500), ZONE_PARIS); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateLocalTime_inGap() { ZonedDateTime test = ZonedDateTime.of(TEST_PARIS_GAP_2008_03_30_02_30.toLocalDate(), TEST_PARIS_GAP_2008_03_30_02_30.toLocalTime(), ZONE_PARIS); check(test, 2008, 3, 30, 3, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // one hour later in summer offset } - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateLocalTime_inOverlap() { ZonedDateTime test = ZonedDateTime.of(TEST_PARIS_OVERLAP_2008_10_26_02_30.toLocalDate(), TEST_PARIS_OVERLAP_2008_10_26_02_30.toLocalTime(), ZONE_PARIS); check(test, 2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // same time in summer offset } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTime_nullDate() { ZonedDateTime.of((LocalDate) null, LocalTime.of(11, 30, 10, 500), ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTime_nullTime() { ZonedDateTime.of(LocalDate.of(2008, 6, 30), (LocalTime) null, ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateLocalTime_nullZone() { ZonedDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 10, 500), null); } @@ -429,31 +434,31 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // of(LocalDateTime, ZoneId) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateTime() { LocalDateTime base = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500); ZonedDateTime test = ZonedDateTime.of(base, ZONE_PARIS); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateTime_inGap() { ZonedDateTime test = ZonedDateTime.of(TEST_PARIS_GAP_2008_03_30_02_30, ZONE_PARIS); check(test, 2008, 3, 30, 3, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // one hour later in summer offset } - @Test(groups={"tck"}) + @Test public void factory_of_LocalDateTime_inOverlap() { ZonedDateTime test = ZonedDateTime.of(TEST_PARIS_OVERLAP_2008_10_26_02_30, ZONE_PARIS); check(test, 2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // same time in summer offset } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateTime_nullDateTime() { ZonedDateTime.of((LocalDateTime) null, ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_of_LocalDateTime_nullZone() { LocalDateTime base = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500); ZonedDateTime.of(base, null); @@ -462,7 +467,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // of(int..., ZoneId) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_of_ints() { ZonedDateTime test = ZonedDateTime.of(2008, 6, 30, 11, 30, 10, 500, ZONE_PARIS); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_0200, ZONE_PARIS); @@ -471,49 +476,49 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // ofInstant(Instant, ZoneId) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_ZR() { Instant instant = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 35).toInstant(OFFSET_0200); ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS); check(test, 2008, 6, 30, 11, 30, 10, 35, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_ZO() { Instant instant = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 45).toInstant(OFFSET_0200); ZonedDateTime test = ZonedDateTime.ofInstant(instant, OFFSET_0200); check(test, 2008, 6, 30, 11, 30, 10, 45, OFFSET_0200, OFFSET_0200); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_inGap() { Instant instant = TEST_PARIS_GAP_2008_03_30_02_30.toInstant(OFFSET_0100); ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS); check(test, 2008, 3, 30, 3, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // one hour later in summer offset } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_inOverlap_earlier() { Instant instant = TEST_PARIS_OVERLAP_2008_10_26_02_30.toInstant(OFFSET_0200); ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS); check(test, 2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // same time and offset } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_inOverlap_later() { Instant instant = TEST_PARIS_OVERLAP_2008_10_26_02_30.toInstant(OFFSET_0100); ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS); check(test, 2008, 10, 26, 2, 30, 0, 0, OFFSET_0100, ZONE_PARIS); // same time and offset } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_Instant_invalidOffset() { Instant instant = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500).toInstant(OFFSET_0130); ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS); check(test, 2008, 6, 30, 12, 0, 10, 500, OFFSET_0200, ZONE_PARIS); // corrected offset, thus altered time } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_allSecsInDay() { for (int i = 0; i < (24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i); @@ -527,7 +532,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_allDaysInCycle() { // sanity check using different algorithm ZonedDateTime expected = LocalDateTime.of(1970, 1, 1, 0, 0, 0, 0).atZone(ZoneOffset.UTC); @@ -539,7 +544,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_minWithMinOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MIN_VALUE; @@ -556,7 +561,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_minWithMaxOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MIN_VALUE; @@ -573,7 +578,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_maxWithMinOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MAX_VALUE; @@ -590,7 +595,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.getNano(), 0); } - @Test(groups={"tck"}) + @Test public void factory_ofInstant_maxWithMaxOffset() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MAX_VALUE; @@ -608,19 +613,19 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_maxInstantWithMaxOffset() { Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); ZonedDateTime.ofInstant(instant, OFFSET_MAX); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_maxInstantWithMinOffset() { Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE); ZonedDateTime.ofInstant(instant, OFFSET_MIN); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_tooBig() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); long year = Year.MAX_VALUE + 1L; @@ -629,7 +634,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { ZonedDateTime.ofInstant(instant, ZoneOffset.UTC); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofInstant_tooLow() { long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7); int year = Year.MIN_VALUE - 1; @@ -638,12 +643,12 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { ZonedDateTime.ofInstant(instant, ZoneOffset.UTC); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_Instant_nullInstant() { ZonedDateTime.ofInstant((Instant) null, ZONE_0100); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofInstant_Instant_nullZone() { ZonedDateTime.ofInstant(Instant.EPOCH, null); } @@ -651,14 +656,14 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // ofStrict(LocalDateTime, ZoneId, ZoneOffset) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_ofStrict_LDT_ZI_ZO() { LocalDateTime normal = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500); ZonedDateTime test = ZonedDateTime.ofStrict(normal, OFFSET_0200, ZONE_PARIS); check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_0200, ZONE_PARIS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofStrict_LDT_ZI_ZO_inGap() { try { ZonedDateTime.ofStrict(TEST_PARIS_GAP_2008_03_30_02_30, OFFSET_0100, ZONE_PARIS); @@ -668,7 +673,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofStrict_LDT_ZI_ZO_inOverlap_invalidOfset() { try { ZonedDateTime.ofStrict(TEST_PARIS_OVERLAP_2008_10_26_02_30, OFFSET_0130, ZONE_PARIS); @@ -678,7 +683,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_ofStrict_LDT_ZI_ZO_invalidOffset() { try { ZonedDateTime.ofStrict(TEST_LOCAL_2008_06_30_11_30_59_500, OFFSET_0130, ZONE_PARIS); @@ -688,17 +693,17 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofStrict_LDT_ZI_ZO_nullLDT() { ZonedDateTime.ofStrict((LocalDateTime) null, OFFSET_0100, ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofStrict_LDT_ZI_ZO_nullZO() { ZonedDateTime.ofStrict(TEST_LOCAL_2008_06_30_11_30_59_500, null, ZONE_PARIS); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_ofStrict_LDT_ZI_ZO_nullZI() { ZonedDateTime.ofStrict(TEST_LOCAL_2008_06_30_11_30_59_500, OFFSET_0100, null); } @@ -706,12 +711,12 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // from(TemporalAccessor) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_from_TemporalAccessor_ZDT() { assertEquals(ZonedDateTime.from(TEST_DATE_TIME_PARIS), TEST_DATE_TIME_PARIS); } - @Test(groups={"tck"}) + @Test public void factory_from_TemporalAccessor_LDT_ZoneId() { assertEquals(ZonedDateTime.from(new TemporalAccessor() { @Override @@ -725,7 +730,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { + if (query == TemporalQuery.zoneId()) { return (R) TEST_DATE_TIME_PARIS.getZone(); } return TemporalAccessor.super.query(query); @@ -733,7 +738,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { }), TEST_DATE_TIME_PARIS); } - @Test(groups={"tck"}) + @Test public void factory_from_TemporalAccessor_Instant_ZoneId() { assertEquals(ZonedDateTime.from(new TemporalAccessor() { @Override @@ -749,7 +754,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { + if (query == TemporalQuery.zoneId()) { return (R) TEST_DATE_TIME_PARIS.getZone(); } return TemporalAccessor.super.query(query); @@ -757,12 +762,12 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { }), TEST_DATE_TIME_PARIS); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void factory_from_TemporalAccessor_invalid_noDerive() { ZonedDateTime.from(LocalTime.of(12, 30)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_from_TemporalAccessor_null() { ZonedDateTime.from((TemporalAccessor) null); } @@ -814,17 +819,17 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(t.getZone().getId(), zoneId); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_illegalValue() { ZonedDateTime.parse("2008-06-32T11:15+01:00[Europe/Paris]"); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void factory_parse_invalidValue() { ZonedDateTime.parse("2008-06-31T11:15+01:00[Europe/Paris]"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_nullText() { ZonedDateTime.parse((String) null); } @@ -832,20 +837,20 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // parse(DateTimeFormatter) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_parse_formatter() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s VV"); ZonedDateTime test = ZonedDateTime.parse("2010 12 3 11 30 0 Europe/London", f); assertEquals(test, ZonedDateTime.of(LocalDateTime.of(2010, 12, 3, 11, 30), ZoneId.of("Europe/London"))); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullText() { DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); ZonedDateTime.parse((String) null, f); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_parse_formatter_nullFormatter() { ZonedDateTime.parse("ANY", null); } @@ -865,7 +870,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_get(int y, int o, int d, int h, int m, int s, int n, ZoneId zone) { LocalDate localDate = LocalDate.of(y, o, d); LocalTime localTime = LocalTime.of(h, m, s, n); @@ -941,32 +946,32 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- @Test public void test_query_chrono() { - assertEquals(TEST_DATE_TIME.query(Queries.chronology()), IsoChronology.INSTANCE); - assertEquals(Queries.chronology().queryFrom(TEST_DATE_TIME), IsoChronology.INSTANCE); + assertEquals(TEST_DATE_TIME.query(TemporalQuery.chronology()), IsoChronology.INSTANCE); + assertEquals(TemporalQuery.chronology().queryFrom(TEST_DATE_TIME), IsoChronology.INSTANCE); } @Test public void test_query_zoneId() { - assertEquals(TEST_DATE_TIME.query(Queries.zoneId()), TEST_DATE_TIME.getZone()); - assertEquals(Queries.zoneId().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); + assertEquals(TEST_DATE_TIME.query(TemporalQuery.zoneId()), TEST_DATE_TIME.getZone()); + assertEquals(TemporalQuery.zoneId().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); } @Test public void test_query_precision() { - assertEquals(TEST_DATE_TIME.query(Queries.precision()), NANOS); - assertEquals(Queries.precision().queryFrom(TEST_DATE_TIME), NANOS); + assertEquals(TEST_DATE_TIME.query(TemporalQuery.precision()), NANOS); + assertEquals(TemporalQuery.precision().queryFrom(TEST_DATE_TIME), NANOS); } @Test public void test_query_offset() { - assertEquals(TEST_DATE_TIME.query(Queries.offset()), TEST_DATE_TIME.getOffset()); - assertEquals(Queries.offset().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getOffset()); + assertEquals(TEST_DATE_TIME.query(TemporalQuery.offset()), TEST_DATE_TIME.getOffset()); + assertEquals(TemporalQuery.offset().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getOffset()); } @Test public void test_query_zone() { - assertEquals(TEST_DATE_TIME.query(Queries.zone()), TEST_DATE_TIME.getZone()); - assertEquals(Queries.zone().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); + assertEquals(TEST_DATE_TIME.query(TemporalQuery.zone()), TEST_DATE_TIME.getZone()); + assertEquals(TemporalQuery.zone().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); } @Test(expectedExceptions=NullPointerException.class) @@ -977,14 +982,14 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withEarlierOffsetAtOverlap() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withEarlierOffsetAtOverlap_notAtOverlap() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_LOCAL_2008_06_30_11_30_59_500, OFFSET_0200, ZONE_PARIS); ZonedDateTime test = base.withEarlierOffsetAtOverlap(); assertEquals(test, base); // not changed } - @Test(groups={"tck"}) + @Test public void test_withEarlierOffsetAtOverlap_atOverlap() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_PARIS_OVERLAP_2008_10_26_02_30, OFFSET_0100, ZONE_PARIS); ZonedDateTime test = base.withEarlierOffsetAtOverlap(); @@ -992,7 +997,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.toLocalDateTime(), base.toLocalDateTime()); // date-time not changed } - @Test(groups={"tck"}) + @Test public void test_withEarlierOffsetAtOverlap_atOverlap_noChange() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_PARIS_OVERLAP_2008_10_26_02_30, OFFSET_0200, ZONE_PARIS); ZonedDateTime test = base.withEarlierOffsetAtOverlap(); @@ -1002,14 +1007,14 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withLaterOffsetAtOverlap() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withLaterOffsetAtOverlap_notAtOverlap() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_LOCAL_2008_06_30_11_30_59_500, OFFSET_0200, ZONE_PARIS); ZonedDateTime test = base.withLaterOffsetAtOverlap(); assertEquals(test, base); // not changed } - @Test(groups={"tck"}) + @Test public void test_withLaterOffsetAtOverlap_atOverlap() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_PARIS_OVERLAP_2008_10_26_02_30, OFFSET_0200, ZONE_PARIS); ZonedDateTime test = base.withLaterOffsetAtOverlap(); @@ -1017,7 +1022,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.toLocalDateTime(), base.toLocalDateTime()); // date-time not changed } - @Test(groups={"tck"}) + @Test public void test_withLaterOffsetAtOverlap_atOverlap_noChange() { ZonedDateTime base = ZonedDateTime.ofStrict(TEST_PARIS_OVERLAP_2008_10_26_02_30, OFFSET_0100, ZONE_PARIS); ZonedDateTime test = base.withLaterOffsetAtOverlap(); @@ -1027,7 +1032,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withZoneSameLocal(ZoneId) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withZoneSameLocal() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1035,7 +1040,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.toLocalDateTime(), base.toLocalDateTime()); } - @Test(groups={"tck","implementation"}) + @Test public void test_withZoneSameLocal_noChange() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1043,7 +1048,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test, base); } - @Test(groups={"tck"}) + @Test public void test_withZoneSameLocal_retainOffset1() { LocalDateTime ldt = LocalDateTime.of(2008, 11, 2, 1, 30, 59, 0); // overlap ZonedDateTime base = ZonedDateTime.of(ldt, ZoneId.of("UTC-04:00") ); @@ -1052,7 +1057,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.getOffset(), ZoneOffset.ofHours(-4)); } - @Test(groups={"tck"}) + @Test public void test_withZoneSameLocal_retainOffset2() { LocalDateTime ldt = LocalDateTime.of(2008, 11, 2, 1, 30, 59, 0); // overlap ZonedDateTime base = ZonedDateTime.of(ldt, ZoneId.of("UTC-05:00") ); @@ -1061,7 +1066,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.getOffset(), ZoneOffset.ofHours(-5)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withZoneSameLocal_null() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1071,7 +1076,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withZoneSameInstant() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withZoneSameInstant() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withZoneSameInstant(ZONE_0200); @@ -1079,14 +1084,14 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test, expected); } - @Test(groups={"tck"}) + @Test public void test_withZoneSameInstant_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withZoneSameInstant(ZONE_0100); assertEquals(test, base); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_withZoneSameInstant_null() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); base.withZoneSameInstant(null); @@ -1095,7 +1100,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withFixedOffsetZone() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withZoneLocked() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_PARIS); ZonedDateTime test = base.withFixedOffsetZone(); @@ -1104,67 +1109,67 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } //----------------------------------------------------------------------- - // with(WithAdjuster) + // with(TemporalAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalDateTime_sameOffset() { + @Test + public void test_with_adjuster_LocalDateTime_sameOffset() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_PARIS); ZonedDateTime test = base.with(LocalDateTime.of(2012, 7, 15, 14, 30)); check(test, 2012, 7, 15, 14, 30, 0, 0, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalDateTime_adjustedOffset() { + @Test + public void test_with_adjuster_LocalDateTime_adjustedOffset() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_PARIS); ZonedDateTime test = base.with(LocalDateTime.of(2012, 1, 15, 14, 30)); check(test, 2012, 1, 15, 14, 30, 0, 0, OFFSET_0100, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalDate() { + @Test + public void test_with_adjuster_LocalDate() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_PARIS); ZonedDateTime test = base.with(LocalDate.of(2012, 7, 28)); check(test, 2012, 7, 28, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalTime() { + @Test + public void test_with_adjuster_LocalTime() { ZonedDateTime base = ZonedDateTime.of(TEST_PARIS_OVERLAP_2008_10_26_02_30, ZONE_PARIS); ZonedDateTime test = base.with(LocalTime.of(2, 29)); check(test, 2008, 10, 26, 2, 29, 0, 0, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_Year() { + @Test + public void test_with_adjuster_Year() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); ZonedDateTime test = base.with(Year.of(2007)); assertEquals(test, ZonedDateTime.of(ldt.withYear(2007), ZONE_0100)); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_Month_adjustedDayOfMonth() { + @Test + public void test_with_adjuster_Month_adjustedDayOfMonth() { ZonedDateTime base = ZonedDateTime.of(LocalDateTime.of(2012, 7, 31, 0, 0), ZONE_PARIS); ZonedDateTime test = base.with(Month.JUNE); check(test, 2012, 6, 30, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_Offset_same() { + @Test + public void test_with_adjuster_Offset_same() { ZonedDateTime base = ZonedDateTime.of(LocalDateTime.of(2012, 7, 31, 0, 0), ZONE_PARIS); ZonedDateTime test = base.with(ZoneOffset.ofHours(2)); check(test, 2012, 7, 31, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_Offset_timeAdjust() { + @Test + public void test_with_adjuster_Offset_timeAdjust() { ZonedDateTime base = ZonedDateTime.of(LocalDateTime.of(2012, 7, 31, 0, 0), ZONE_PARIS); ZonedDateTime test = base.with(ZoneOffset.ofHours(1)); - check(test, 2012, 7, 31, 1, 0, 0, 0, OFFSET_0200, ZONE_PARIS); // time adjusted + check(test, 2012, 7, 31, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); // invalid offset ignored } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalDate_retainOffset1() { + @Test + public void test_with_adjuster_LocalDate_retainOffset1() { ZoneId newYork = ZoneId.of("America/New_York"); LocalDateTime ldt = LocalDateTime.of(2008, 11, 1, 1, 30); ZonedDateTime base = ZonedDateTime.of(ldt, newYork); @@ -1173,8 +1178,8 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.getOffset(), ZoneOffset.ofHours(-4)); } - @Test(groups={"tck"}) - public void test_with_WithAdjuster_LocalDate_retainOffset2() { + @Test + public void test_with_adjuster_LocalDate_retainOffset2() { ZoneId newYork = ZoneId.of("America/New_York"); LocalDateTime ldt = LocalDateTime.of(2008, 11, 3, 1, 30); ZonedDateTime base = ZonedDateTime.of(ldt, newYork); @@ -1183,23 +1188,176 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.getOffset(), ZoneOffset.ofHours(-5)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_with_WithAdjuster_null() { + @Test + public void test_with_adjuster_OffsetDateTime_validOffsetNotInOverlap() { + // ODT will be a valid ZDT for the zone, so must be retained exactly + OffsetDateTime odt = TEST_LOCAL_2008_06_30_11_30_59_500.atOffset(OFFSET_0200); + ZonedDateTime zdt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS); + ZonedDateTime test = zdt.with(odt); + assertEquals(test.toOffsetDateTime(), odt); + } + + @Test + public void test_with_adjuster_OffsetDateTime_invalidOffsetIgnored() { + // ODT has invalid offset for ZDT, so only LDT is set + OffsetDateTime odt = TEST_LOCAL_2008_06_30_11_30_59_500.atOffset(OFFSET_0130); + ZonedDateTime zdt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS); + ZonedDateTime test = zdt.with(odt); + assertEquals(test.toLocalDateTime(), TEST_LOCAL_2008_06_30_11_30_59_500); + assertEquals(test.getOffset(), zdt.getOffset()); + } + + @Test + public void test_with_adjuster_OffsetDateTime_retainOffsetInOverlap1() { + // ODT will be a valid ZDT for the zone, so must be retained exactly + OffsetDateTime odt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atOffset(OFFSET_0100); + ZonedDateTime zdt = TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS); + ZonedDateTime test = zdt.with(odt); + assertEquals(test.toOffsetDateTime(), odt); + } + + @Test + public void test_with_adjuster_OffsetDateTime_retainOffsetInOverlap2() { + // ODT will be a valid ZDT for the zone, so must be retained exactly + OffsetDateTime odt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atOffset(OFFSET_0200); + ZonedDateTime zdt = TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS); + ZonedDateTime test = zdt.with(odt); + assertEquals(test.toOffsetDateTime(), odt); + } + + @Test + public void test_with_adjuster_OffsetTime_validOffsetNotInOverlap() { + // OT has valid offset for resulting time + OffsetTime ot = OffsetTime.of(15, 50, 30, 40, OFFSET_0100); + ZonedDateTime zdt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS); + ZonedDateTime test = zdt.with(ot); + assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 15, 50, 30, 40)); + assertEquals(test.getOffset(), OFFSET_0100); + } + + @Test + public void test_with_adjuster_OffsetTime_invalidOffsetIgnored1() { + // OT has invalid offset for ZDT, so only LT is set + OffsetTime ot = OffsetTime.of(0, 50, 30, 40, OFFSET_0130); + ZonedDateTime zdt = dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // earlier part of overlap + ZonedDateTime test = zdt.with(ot); + assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 0, 50, 30, 40)); + assertEquals(test.getOffset(), OFFSET_0200); // offset not adjusted + } + + @Test + public void test_with_adjuster_OffsetTime_invalidOffsetIgnored2() { + // OT has invalid offset for ZDT, so only LT is set + OffsetTime ot = OffsetTime.of(15, 50, 30, 40, OFFSET_0130); + ZonedDateTime zdt = dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // earlier part of overlap + ZonedDateTime test = zdt.with(ot); + assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 15, 50, 30, 40)); + assertEquals(test.getOffset(), OFFSET_0100); // offset adjusted because of time change + } + + @Test + public void test_with_adjuster_OffsetTime_validOffsetIntoOverlap1() { + // OT has valid offset for resulting time + OffsetTime ot = OffsetTime.of(2, 30, 30, 40, OFFSET_0100); // valid offset in overlap + ZonedDateTime zdt = dateTime(2008, 10, 26, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); // just before overlap + ZonedDateTime test = zdt.with(ot); + assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 2, 30, 30, 40)); + assertEquals(test.getOffset(), OFFSET_0100); + } + + @Test + public void test_with_adjuster_OffsetTime_validOffsetIntoOverlap2() { + // OT has valid offset for resulting time + OffsetTime ot = OffsetTime.of(2, 30, 30, 40, OFFSET_0200); // valid offset in overlap + ZonedDateTime zdt = dateTime(2008, 10, 26, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); // just before overlap + ZonedDateTime test = zdt.with(ot); + assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 2, 30, 30, 40)); + assertEquals(test.getOffset(), OFFSET_0200); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_with_adjuster_null() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); base.with((TemporalAdjuster) null); } + //----------------------------------------------------------------------- + // with(long,TemporalUnit) + //----------------------------------------------------------------------- + @DataProvider(name = "withFieldLong") + Object[][] data_withFieldLong() { + return new Object[][] { + // set simple fields + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), YEAR, 2009, + dateTime(2009, 6, 30, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), MONTH_OF_YEAR, 7, + dateTime(2008, 7, 30, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), DAY_OF_MONTH, 15, + dateTime(2008, 6, 15, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), HOUR_OF_DAY, 14, + dateTime(2008, 6, 30, 14, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, + + // set around overlap + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withEarlierOffsetAtOverlap(), HOUR_OF_DAY, 0, + dateTime(2008, 10, 26, 0, 30, 0, 0, OFFSET_0200, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withLaterOffsetAtOverlap(), HOUR_OF_DAY, 0, + dateTime(2008, 10, 26, 0, 30, 0, 0, OFFSET_0200, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withEarlierOffsetAtOverlap(), MINUTE_OF_HOUR, 20, + dateTime(2008, 10, 26, 2, 20, 0, 0, OFFSET_0200, ZONE_PARIS)}, // offset unchanged + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withLaterOffsetAtOverlap(), MINUTE_OF_HOUR, 20, + dateTime(2008, 10, 26, 2, 20, 0, 0, OFFSET_0100, ZONE_PARIS)}, // offset unchanged + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withEarlierOffsetAtOverlap(), HOUR_OF_DAY, 3, + dateTime(2008, 10, 26, 3, 30, 0, 0, OFFSET_0100, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withLaterOffsetAtOverlap(), HOUR_OF_DAY, 3, + dateTime(2008, 10, 26, 3, 30, 0, 0, OFFSET_0100, ZONE_PARIS)}, + + // set offset + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), OFFSET_SECONDS, 7200, + dateTime(2008, 6, 30, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, // offset unchanged + {TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS), OFFSET_SECONDS, 3600, + dateTime(2008, 6, 30, 11, 30, 59, 500, OFFSET_0200, ZONE_PARIS)}, // invalid offset ignored + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withEarlierOffsetAtOverlap(), OFFSET_SECONDS, 3600, + dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0100, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withLaterOffsetAtOverlap(), OFFSET_SECONDS, 3600, + dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0100, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withEarlierOffsetAtOverlap(), OFFSET_SECONDS, 7200, + dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS)}, + {TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS).withLaterOffsetAtOverlap(), OFFSET_SECONDS, 7200, + dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS)}, + }; + }; + + @Test(dataProvider = "withFieldLong") + public void test_with_fieldLong(ZonedDateTime base, TemporalField setField, int setValue, ZonedDateTime expected) { + assertEquals(base.with(setField, setValue), expected); + } + + @Test(dataProvider = "withFieldLong") + public void test_with_adjuster_ensureZoneOffsetConsistent(ZonedDateTime base, TemporalField setField, int setValue, ZonedDateTime expected) { + if (setField == OFFSET_SECONDS) { + assertEquals(base.with(ZoneOffset.ofTotalSeconds(setValue)), expected); + } + } + + @Test(dataProvider = "withFieldLong") + public void test_with_adjuster_ensureOffsetDateTimeConsistent(ZonedDateTime base, TemporalField setField, int setValue, ZonedDateTime expected) { + if (setField == OFFSET_SECONDS) { + OffsetDateTime odt = base.toOffsetDateTime().with(setField, setValue); + assertEquals(base.with(odt), expected); + } + } + //----------------------------------------------------------------------- // withYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withYear_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withYear(2007); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withYear(2007), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withYear_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withYear(2008); @@ -1209,14 +1367,14 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // with(Month) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth_Month_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.with(JANUARY); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withMonth(1), ZONE_0100)); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void test_withMonth_Month_null() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); base.with((Month) null); @@ -1225,26 +1383,26 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMonth_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withMonth(1); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withMonth(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withMonth_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withMonth(6); assertEquals(test, base); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooBig() { TEST_DATE_TIME.withMonth(13); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withMonth_tooSmall() { TEST_DATE_TIME.withMonth(0); } @@ -1252,31 +1410,31 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withDayOfMonth(15); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withDayOfMonth(15), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withDayOfMonth_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withDayOfMonth(30); assertEquals(test, base); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_tooBig() { LocalDateTime.of(2007, 7, 2, 11, 30).atZone(ZONE_PARIS).withDayOfMonth(32); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_tooSmall() { TEST_DATE_TIME.withDayOfMonth(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfMonth_invalid31() { LocalDateTime.of(2007, 6, 2, 11, 30).atZone(ZONE_PARIS).withDayOfMonth(31); } @@ -1284,14 +1442,14 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withDayOfYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withDayOfYear_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withDayOfYear(33); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withDayOfYear(33), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withDayOfYear_noChange() { LocalDateTime ldt = LocalDateTime.of(2008, 2, 5, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1299,17 +1457,17 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test, base); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_tooBig() { TEST_DATE_TIME.withDayOfYear(367); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_tooSmall() { TEST_DATE_TIME.withDayOfYear(0); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_withDayOfYear_invalid366() { LocalDateTime.of(2007, 2, 2, 11, 30).atZone(ZONE_PARIS).withDayOfYear(366); } @@ -1317,14 +1475,14 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withHour() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withHour_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withHour(15); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withHour(15), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withHour_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withHour(11); @@ -1334,14 +1492,14 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withMinute() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withMinute_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withMinute(15); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withMinute(15), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withMinute_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withMinute(30); @@ -1351,14 +1509,14 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withSecond_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withSecond(12); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withSecond(12), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withSecond_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withSecond(59); @@ -1368,14 +1526,14 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // withNano() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withNano(15); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withNano(15), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_withNanoOfSecond_noChange() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.withNano(500); @@ -1385,14 +1543,14 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // truncatedTo(TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_truncatedTo_normal() { assertEquals(TEST_DATE_TIME.truncatedTo(NANOS), TEST_DATE_TIME); assertEquals(TEST_DATE_TIME.truncatedTo(SECONDS), TEST_DATE_TIME.withNano(0)); assertEquals(TEST_DATE_TIME.truncatedTo(DAYS), TEST_DATE_TIME.with(LocalTime.MIDNIGHT)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_truncatedTo_null() { TEST_DATE_TIME.truncatedTo(null); } @@ -1444,22 +1602,22 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plus(TemporalAmount) //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_plus_TemporalAmount_Period_days(ZonedDateTime base, int amount, ZonedDateTime expected) { assertEquals(base.plus(Period.ofDays(amount)), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_TemporalAmount_Period_hours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(MockSimplePeriod.of(amount, HOURS)), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_TemporalAmount_Duration_hours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(Duration.ofHours(amount)), expected); } - @Test(groups={"tck"}) + @Test public void test_plus_TemporalAmount() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); ZonedDateTime t = ZonedDateTime.of(LocalDateTime.of(2008, 6, 1, 12, 30, 59, 500), ZONE_0100); @@ -1467,7 +1625,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(t.plus(period), expected); } - @Test(groups={"tck"}) + @Test public void test_plus_TemporalAmount_Duration() { Duration duration = Duration.ofSeconds(4L * 60 * 60 + 5L * 60 + 6L); ZonedDateTime t = ZonedDateTime.of(LocalDateTime.of(2008, 6, 1, 12, 30, 59, 500), ZONE_0100); @@ -1475,19 +1633,19 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(t.plus(duration), expected); } - @Test(groups={"tck"}) + @Test public void test_plus_TemporalAmount_Period_zero() { ZonedDateTime t = TEST_DATE_TIME.plus(MockSimplePeriod.ZERO_DAYS); assertEquals(t, TEST_DATE_TIME); } - @Test(groups={"tck"}) + @Test public void test_plus_TemporalAmount_Duration_zero() { ZonedDateTime t = TEST_DATE_TIME.plus(Duration.ZERO); assertEquals(t, TEST_DATE_TIME); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_TemporalAmount_null() { TEST_DATE_TIME.plus((TemporalAmount) null); } @@ -1495,32 +1653,32 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plus(long,TemporalUnit) //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_plus_longUnit_days(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(amount, DAYS), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_longUnit_hours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(amount, HOURS), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_longUnit_minutes(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(amount * 60, MINUTES), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_longUnit_seconds(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(amount * 3600, SECONDS), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plus_longUnit_nanos(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plus(amount * 3600_000_000_000L, NANOS), expected); } - @Test(groups={"tck"}, expectedExceptions=NullPointerException.class) + @Test(expectedExceptions=NullPointerException.class) public void test_plus_longUnit_null() { TEST_DATE_TIME_PARIS.plus(0, null); } @@ -1528,7 +1686,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusYears() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1536,7 +1694,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test, ZonedDateTime.of(ldt.plusYears(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_plusYears_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1547,7 +1705,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusMonths() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1555,7 +1713,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test, ZonedDateTime.of(ldt.plusMonths(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_plusMonths_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1566,7 +1724,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusWeeks() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_plusWeeks() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1574,7 +1732,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test, ZonedDateTime.of(ldt.plusWeeks(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_plusWeeks_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1585,7 +1743,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusDays() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_plusDays(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plusDays(amount), expected); } @@ -1593,7 +1751,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plusHours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plusHours(amount), expected); } @@ -1601,12 +1759,12 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plusMinutes(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plusMinutes(amount * 60), expected); } - @Test(groups={"tck"}) + @Test public void test_plusMinutes_minutes() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1617,12 +1775,12 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plusSeconds(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plusSeconds(amount * 3600), expected); } - @Test(groups={"tck"}) + @Test public void test_plusSeconds_seconds() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1633,12 +1791,12 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // plusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_plusNanos(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.plusNanos(amount * 3600_000_000_000L), expected); } - @Test(groups={"tck"}) + @Test public void test_plusNanos_nanos() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1649,22 +1807,22 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minus(TemporalAmount) //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_minus_TemporalAmount_Period_days(ZonedDateTime base, int amount, ZonedDateTime expected) { assertEquals(base.minus(Period.ofDays(-amount)), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minus_TemporalAmount_Period_hours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minus(MockSimplePeriod.of(-amount, HOURS)), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minus_TemporalAmount_Duration_hours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minus(Duration.ofHours(-amount)), expected); } - @Test(groups={"tck"}) + @Test public void test_minus_TemporalAmount() { MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS); ZonedDateTime t = ZonedDateTime.of(LocalDateTime.of(2008, 6, 1, 12, 30, 59, 500), ZONE_0100); @@ -1672,7 +1830,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(t.minus(period), expected); } - @Test(groups={"tck"}) + @Test public void test_minus_TemporalAmount_Duration() { Duration duration = Duration.ofSeconds(4L * 60 * 60 + 5L * 60 + 6L); ZonedDateTime t = ZonedDateTime.of(LocalDateTime.of(2008, 6, 1, 12, 30, 59, 500), ZONE_0100); @@ -1680,19 +1838,19 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(t.minus(duration), expected); } - @Test(groups={"tck"}) + @Test public void test_minus_TemporalAmount_Period_zero() { ZonedDateTime t = TEST_DATE_TIME.minus(MockSimplePeriod.ZERO_DAYS); assertEquals(t, TEST_DATE_TIME); } - @Test(groups={"tck"}) + @Test public void test_minus_TemporalAmount_Duration_zero() { ZonedDateTime t = TEST_DATE_TIME.minus(Duration.ZERO); assertEquals(t, TEST_DATE_TIME); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_minus_TemporalAmount_null() { TEST_DATE_TIME.minus((TemporalAmount) null); } @@ -1700,7 +1858,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusYears() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusYears() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1708,7 +1866,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test, ZonedDateTime.of(ldt.minusYears(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_minusYears_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1719,7 +1877,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusMonths() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusMonths() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1727,7 +1885,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test, ZonedDateTime.of(ldt.minusMonths(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_minusMonths_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1738,7 +1896,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusWeeks() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_minusWeeks() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1746,7 +1904,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test, ZonedDateTime.of(ldt.minusWeeks(1), ZONE_0100)); } - @Test(groups={"tck"}) + @Test public void test_minusWeeks_zero() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1757,7 +1915,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusDays() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_minusDays(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minusDays(-amount), expected); } @@ -1765,7 +1923,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusHours() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minusHours(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minusHours(-amount), expected); } @@ -1773,12 +1931,12 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusMinutes() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minusMinutes(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minusMinutes(-amount * 60), expected); } - @Test(groups={"tck"}) + @Test public void test_minusMinutes_minutes() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1789,12 +1947,12 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusSeconds() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minusSeconds(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minusSeconds(-amount * 3600), expected); } - @Test(groups={"tck"}) + @Test public void test_minusSeconds_seconds() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1805,12 +1963,12 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // minusNanos() //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_minusNanos(ZonedDateTime base, long amount, ZonedDateTime expected) { assertEquals(base.minusNanos(-amount * 3600_000_000_000L), expected); } - @Test(groups={"tck"}) + @Test public void test_minusNanos_nanos() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); @@ -1824,32 +1982,35 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { // TODO: more tests for period between two different zones // compare results to OffsetDateTime.periodUntil, especially wrt dates - @Test(groups={"tck"}, dataProvider="plusDays") + @Test(dataProvider="plusDays") public void test_periodUntil_days(ZonedDateTime base, long expected, ZonedDateTime end) { + if (base.toLocalTime().equals(end.toLocalTime()) == false) { + return; // avoid DST gap input values + } assertEquals(base.periodUntil(end, DAYS), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_periodUntil_hours(ZonedDateTime base, long expected, ZonedDateTime end) { assertEquals(base.periodUntil(end, HOURS), expected); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_periodUntil_minutes(ZonedDateTime base, long expected, ZonedDateTime end) { assertEquals(base.periodUntil(end, MINUTES), expected * 60); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_periodUntil_seconds(ZonedDateTime base, long expected, ZonedDateTime end) { assertEquals(base.periodUntil(end, SECONDS), expected * 3600); } - @Test(groups={"tck"}, dataProvider="plusTime") + @Test(dataProvider="plusTime") public void test_periodUntil_nanos(ZonedDateTime base, long expected, ZonedDateTime end) { assertEquals(base.periodUntil(end, NANOS), expected * 3600_000_000_000L); } - @Test(groups={"tck"}) + @Test public void test_periodUntil_parisLondon() { ZonedDateTime midnightLondon = LocalDate.of(2012, 6, 28).atStartOfDay(ZONE_LONDON); ZonedDateTime midnightParis1 = LocalDate.of(2012, 6, 29).atStartOfDay(ZONE_PARIS); @@ -1865,7 +2026,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(midnightLondon.periodUntil(midnightParis2, DAYS), 1); } - @Test(groups={"tck"}) + @Test public void test_periodUntil_gap() { ZonedDateTime before = TEST_PARIS_GAP_2008_03_30_02_30.withHour(0).withMinute(0).atZone(ZONE_PARIS); ZonedDateTime after = TEST_PARIS_GAP_2008_03_30_02_30.withHour(0).withMinute(0).plusDays(1).atZone(ZONE_PARIS); @@ -1874,7 +2035,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(before.periodUntil(after, DAYS), 1); } - @Test(groups={"tck"}) + @Test public void test_periodUntil_overlap() { ZonedDateTime before = TEST_PARIS_OVERLAP_2008_10_26_02_30.withHour(0).withMinute(0).atZone(ZONE_PARIS); ZonedDateTime after = TEST_PARIS_OVERLAP_2008_10_26_02_30.withHour(0).withMinute(0).plusDays(1).atZone(ZONE_PARIS); @@ -1883,25 +2044,40 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(before.periodUntil(after, DAYS), 1); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_periodUntil_differentType() { TEST_DATE_TIME_PARIS.periodUntil(TEST_LOCAL_2008_06_30_11_30_59_500, DAYS); } - @Test(groups={"tck"}, expectedExceptions=NullPointerException.class) + @Test(expectedExceptions=NullPointerException.class) public void test_periodUntil_nullTemporal() { TEST_DATE_TIME_PARIS.periodUntil(null, DAYS); } - @Test(groups={"tck"}, expectedExceptions=NullPointerException.class) + @Test(expectedExceptions=NullPointerException.class) public void test_periodUntil_nullUnit() { TEST_DATE_TIME_PARIS.periodUntil(TEST_DATE_TIME_PARIS, null); } + //----------------------------------------------------------------------- + // format(DateTimeFormatter) + //----------------------------------------------------------------------- + @Test + public void test_format_formatter() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); + String t = ZonedDateTime.of(dateTime(2010, 12, 3, 11, 30), ZONE_PARIS).format(f); + assertEquals(t, "2010 12 3 11 30 0"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_format_formatter_null() { + ZonedDateTime.of(dateTime(2010, 12, 3, 11, 30), ZONE_PARIS).format(null); + } + //----------------------------------------------------------------------- // toOffsetDateTime() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toOffsetDateTime() { assertEquals(TEST_DATE_TIME.toOffsetDateTime(), OffsetDateTime.of(TEST_DATE_TIME.toLocalDateTime(), TEST_DATE_TIME.getOffset())); } @@ -1923,7 +2099,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { }; } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toInstant_UTC(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZoneOffset.UTC); Instant test = dt.toInstant(); @@ -1931,7 +2107,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.getNano(), expectedNos); } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toInstant_P0100(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZONE_0100); Instant test = dt.toInstant(); @@ -1939,7 +2115,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(test.getNano(), expectedNos); } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toInstant_M0100(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZONE_M0100); Instant test = dt.toInstant(); @@ -1950,7 +2126,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // toEpochSecond() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_afterEpoch() { LocalDateTime ldt = LocalDateTime.of(1970, 1, 1, 0, 0).plusHours(1); for (int i = 0; i < 100000; i++) { @@ -1960,7 +2136,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}) + @Test public void test_toEpochSecond_beforeEpoch() { LocalDateTime ldt = LocalDateTime.of(1970, 1, 1, 0, 0).plusHours(1); for (int i = 0; i < 100000; i++) { @@ -1970,19 +2146,19 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { } } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toEpochSecond_UTC(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZoneOffset.UTC); assertEquals(dt.toEpochSecond(), expectedEpSec); } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toEpochSecond_P0100(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZONE_0100); assertEquals(dt.toEpochSecond(), expectedEpSec - 3600); } - @Test(groups={"tck"}, dataProvider="toInstant") + @Test(dataProvider="toInstant") public void test_toEpochSecond_M0100(LocalDateTime ldt, long expectedEpSec, int expectedNos) { ZonedDateTime dt = ldt.atZone(ZONE_M0100); assertEquals(dt.toEpochSecond(), expectedEpSec + 3600); @@ -1991,7 +2167,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo_time1() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 30, 39, 0, ZONE_0100); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 30, 41, 0, ZONE_0100); // a is before b due to time @@ -2001,7 +2177,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_time2() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 30, 40, 4, ZONE_0100); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 30, 40, 5, ZONE_0100); // a is before b due to time @@ -2011,7 +2187,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_offset1() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 30, 41, 0, ZONE_0200); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 30, 39, 0, ZONE_0100); // a is before b due to offset @@ -2021,7 +2197,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_offset2() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 30, 40, 5, ZoneId.of("UTC+01:01")); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 30, 40, 4, ZONE_0100); // a is before b due to offset @@ -2031,7 +2207,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_both() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 50, 0, 0, ZONE_0200); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 20, 0, 0, ZONE_0100); // a is before b on instant scale @@ -2041,7 +2217,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_bothNanos() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 11, 20, 40, 5, ZONE_0200); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 10, 20, 40, 6, ZONE_0100); // a is before b on instant scale @@ -2051,7 +2227,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(b.compareTo(b) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_hourDifference() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 10, 0, 0, 0, ZONE_0100); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, 11, 0, 0, 0, ZONE_0200); // a is before b despite being same time-line time @@ -2061,7 +2237,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(b.compareTo(b) == 0, true); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_compareTo_null() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 23, 30, 59, 0, ZONE_0100); a.compareTo(null); @@ -2079,7 +2255,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="IsBefore", groups={"tck"}) + @Test(dataProvider="IsBefore") public void test_isBefore(int hour1, int minute1, ZoneId zone1, int hour2, int minute2, ZoneId zone2, boolean expected) { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, hour1, minute1, 0, 0, zone1); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, hour2, minute2, 0, 0, zone2); @@ -2089,7 +2265,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(b.isBefore(b), false); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isBefore_null() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 23, 30, 59, 0, ZONE_0100); a.isBefore(null); @@ -2107,7 +2283,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="IsAfter", groups={"tck"}) + @Test(dataProvider="IsAfter") public void test_isAfter(int hour1, int minute1, ZoneId zone1, int hour2, int minute2, ZoneId zone2, boolean expected) { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, hour1, minute1, 0, 0, zone1); ZonedDateTime b = ZonedDateTime.of(2008, 6, 30, hour2, minute2, 0, 0, zone2); @@ -2117,7 +2293,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { assertEquals(b.isAfter(b), false); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_isAfter_null() { ZonedDateTime a = ZonedDateTime.of(2008, 6, 30, 23, 30, 59, 0, ZONE_0100); a.isAfter(null); @@ -2126,60 +2302,60 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_true(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); assertEquals(a.equals(b), true); assertEquals(a.hashCode() == b.hashCode(), true); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_year_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y + 1, o, d, h, m, s, n), ZONE_0100); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_hour_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { h = (h == 23 ? 22 : h); ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h + 1, m, s, n), ZONE_0100); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_minute_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { m = (m == 59 ? 58 : m); ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h, m + 1, s, n), ZONE_0100); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_second_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { s = (s == 59 ? 58 : s); ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h, m, s + 1, n), ZONE_0100); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_nano_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { n = (n == 999999999 ? 999999998 : n); ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n + 1), ZONE_0100); assertEquals(a.equals(b), false); } - @Test(dataProvider="sampleTimes", groups={"tck"}) + @Test(dataProvider="sampleTimes") public void test_equals_false_offset_differs(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) { ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100); ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0200); assertEquals(a.equals(b), false); } - @Test(groups={"tck"}) + @Test public void test_equals_itself_true() { assertEquals(TEST_DATE_TIME.equals(TEST_DATE_TIME), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { assertEquals(TEST_DATE_TIME.equals("2007-07-15"), false); } @@ -2204,28 +2380,13 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { }; } - @Test(dataProvider="sampleToString", groups={"tck"}) + @Test(dataProvider="sampleToString") public void test_toString(int y, int o, int d, int h, int m, int s, int n, String zoneId, String expected) { ZonedDateTime t = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZoneId.of(zoneId)); String str = t.toString(); assertEquals(str, expected); } - //----------------------------------------------------------------------- - // toString(DateTimeFormatter) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_toString_formatter() { - DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s"); - String t = ZonedDateTime.of(dateTime(2010, 12, 3, 11, 30), ZONE_PARIS).toString(f); - assertEquals(t, "2010 12 3 11 30 0"); - } - - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_toString_formatter_null() { - ZonedDateTime.of(dateTime(2010, 12, 3, 11, 30), ZONE_PARIS).toString(null); - } - //------------------------------------------------------------------------- private static LocalDateTime dateTime( int year, int month, int dayOfMonth, diff --git a/jdk/test/java/time/tck/java/time/TestChronology.java b/jdk/test/java/time/tck/java/time/TestChronology.java deleted file mode 100644 index b186cd315eb..00000000000 --- a/jdk/test/java/time/tck/java/time/TestChronology.java +++ /dev/null @@ -1,192 +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. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; -import static org.testng.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.Locale; -import java.util.Set; - -import java.time.chrono.Chronology; -import java.time.temporal.ChronoField; -import java.time.chrono.HijrahChronology; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.MinguoChronology; -import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.IsoChronology; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test Chronology class. - */ -@Test -public class TestChronology { - - //----------------------------------------------------------------------- - // regular data factory for names and descriptions of available calendars - //----------------------------------------------------------------------- - @DataProvider(name = "calendars") - Object[][] data_of_calendars() { - return new Object[][] { - {"Hijrah", "islamicc", "Hijrah calendar"}, - {"ISO", "iso8601", "ISO calendar"}, - {"Japanese", "japanese", "Japanese calendar"}, - {"Minguo", "roc", "Minguo Calendar"}, - {"ThaiBuddhist", "buddhist", "ThaiBuddhist calendar"}, - }; - } - - @Test(dataProvider = "calendars") - public void test_getters(String chronoId, String calendarSystemType, String description) { - Chronology chrono = Chronology.of(chronoId); - assertNotNull(chrono, "Required calendar not found by ID: " + chronoId); - assertEquals(chrono.getId(), chronoId); - assertEquals(chrono.getCalendarType(), calendarSystemType); - } - - @Test(dataProvider = "calendars") - public void test_required_calendars(String chronoId, String calendarSystemType, String description) { - Chronology chrono = Chronology.of(chronoId); - assertNotNull(chrono, "Required calendar not found by ID: " + chronoId); - chrono = Chronology.of(calendarSystemType); - assertNotNull(chrono, "Required calendar not found by type: " + chronoId); - Set cals = Chronology.getAvailableChronologies(); - assertTrue(cals.contains(chrono), "Required calendar not found in set of available calendars"); - } - - @Test(groups="tck") - public void test_calendar_list() { - Set chronos = Chronology.getAvailableChronologies(); - assertNotNull(chronos, "Required list of calendars must be non-null"); - for (Chronology chrono : chronos) { - Chronology lookup = Chronology.of(chrono.getId()); - assertNotNull(lookup, "Required calendar not found: " + chrono); - } - assertEquals(chronos.size() >= data_of_calendars().length, true, "Chronology.getAvailableChronologies().size = " + chronos.size() - + ", expected >= " + data_of_calendars().length); - } - - /** - * Compute the number of days from the Epoch and compute the date from the number of days. - */ - @Test(dataProvider = "calendars", groups="tck") - public void test_epoch(String name, String alias, String description) { - Chronology chrono = Chronology.of(name); // a chronology. In practice this is rarely hardcoded - ChronoLocalDate date1 = chrono.dateNow(); - long epoch1 = date1.getLong(ChronoField.EPOCH_DAY); - ChronoLocalDate date2 = date1.with(ChronoField.EPOCH_DAY, epoch1); - assertEquals(date1, date2, "Date from epoch day is not same date: " + date1 + " != " + date2); - long epoch2 = date1.getLong(ChronoField.EPOCH_DAY); - assertEquals(epoch1, epoch2, "Epoch day not the same: " + epoch1 + " != " + epoch2); - } - - //----------------------------------------------------------------------- - // locale based lookup - //----------------------------------------------------------------------- - @DataProvider(name = "calendarsystemtype") - Object[][] data_CalendarType() { - return new Object[][] { - {HijrahChronology.INSTANCE, "islamicc"}, - {IsoChronology.INSTANCE, "iso8601"}, - {JapaneseChronology.INSTANCE, "japanese"}, - {MinguoChronology.INSTANCE, "roc"}, - {ThaiBuddhistChronology.INSTANCE, "buddhist"}, - }; - } - - @Test(dataProvider = "calendarsystemtype", groups="tck") - public void test_getCalendarType(Chronology chrono, String calendarType) { - assertEquals(chrono.getCalendarType(), calendarType); - } - - @Test(dataProvider = "calendarsystemtype", groups="tck") - public void test_lookupLocale(Chronology chrono, String calendarType) { - Locale locale = new Locale.Builder().setLanguage("en").setRegion("CA").setUnicodeLocaleKeyword("ca", calendarType).build(); - assertEquals(Chronology.ofLocale(locale), chrono); - } - - - //----------------------------------------------------------------------- - // serialization; serialize and check each calendar system - //----------------------------------------------------------------------- - @Test(groups={"tck","implementation"}, dataProvider = "calendarsystemtype") - public void test_chronoSerializationSingleton(Chronology chrono, String calendarType) throws Exception { - Chronology orginal = chrono; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); - out.writeObject(orginal); - out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream in = new ObjectInputStream(bais); - Chronology ser = (Chronology) in.readObject(); - assertSame(ser, chrono, "Deserialized Chronology is not the singleton serialized"); - } - -} diff --git a/jdk/test/java/time/tck/java/time/TestIsoChronology.java b/jdk/test/java/time/tck/java/time/TestIsoChronology.java index aa42e4a0ca0..c99ec2a3ac4 100644 --- a/jdk/test/java/time/tck/java/time/TestIsoChronology.java +++ b/jdk/test/java/time/tck/java/time/TestIsoChronology.java @@ -59,8 +59,8 @@ */ package tck.java.time; -import static java.time.chrono.IsoChronology.ERA_BCE; -import static java.time.chrono.IsoChronology.ERA_CE; +import static java.time.chrono.IsoEra.BCE; +import static java.time.chrono.IsoEra.CE; import static java.time.temporal.ChronoField.ERA; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; @@ -73,13 +73,14 @@ import java.time.DateTimeException; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.Month; -import java.time.temporal.Adjusters; -import java.time.temporal.ChronoField; -import java.time.chrono.HijrahChronology; import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; import java.time.chrono.Era; +import java.time.chrono.HijrahChronology; +import java.time.chrono.HijrahEra; import java.time.chrono.IsoChronology; +import java.time.chrono.IsoEra; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalAdjuster; import org.testng.Assert; import org.testng.annotations.DataProvider; @@ -94,7 +95,7 @@ public class TestIsoChronology { //----------------------------------------------------------------------- // Chronology.ofName("ISO") Lookup by name //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_chrono_byName() { Chronology c = IsoChronology.INSTANCE; Chronology test = Chronology.of("ISO"); @@ -107,7 +108,7 @@ public class TestIsoChronology { //----------------------------------------------------------------------- // Lookup by Singleton //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void instanceNotNull() { assertNotNull(IsoChronology.INSTANCE); } @@ -115,10 +116,10 @@ public class TestIsoChronology { //----------------------------------------------------------------------- // Era creation //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void test_eraOf() { - assertEquals(IsoChronology.INSTANCE.eraOf(0), ERA_BCE); - assertEquals(IsoChronology.INSTANCE.eraOf(1), ERA_CE); + assertEquals(IsoChronology.INSTANCE.eraOf(0), BCE); + assertEquals(IsoChronology.INSTANCE.eraOf(1), CE); } //----------------------------------------------------------------------- @@ -144,12 +145,12 @@ public class TestIsoChronology { }; } - @Test(dataProvider="samples", groups={"tck"}) + @Test(dataProvider="samples") public void test_toLocalDate(LocalDate isoDate, LocalDate iso) { assertEquals(LocalDate.from(isoDate), iso); } - @Test(dataProvider="samples", groups={"tck"}) + @Test(dataProvider="samples") public void test_fromCalendrical(LocalDate isoDate, LocalDate iso) { assertEquals(IsoChronology.INSTANCE.date(iso), isoDate); } @@ -174,18 +175,18 @@ public class TestIsoChronology { }; } - @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) public void test_badDates(int year, int month, int dom) { IsoChronology.INSTANCE.date(year, month, dom); } - @Test(groups="tck") + @Test public void test_date_withEra() { int year = 5; int month = 5; int dayOfMonth = 5; - LocalDate test = IsoChronology.INSTANCE.date(ERA_BCE, year, month, dayOfMonth); - assertEquals(test.getEra(), ERA_BCE); + LocalDate test = IsoChronology.INSTANCE.date(IsoEra.BCE, year, month, dayOfMonth); + assertEquals(test.getEra(), IsoEra.BCE); assertEquals(test.get(ChronoField.YEAR_OF_ERA), year); assertEquals(test.get(ChronoField.MONTH_OF_YEAR), month); assertEquals(test.get(ChronoField.DAY_OF_MONTH), dayOfMonth); @@ -196,39 +197,39 @@ public class TestIsoChronology { } @SuppressWarnings({ "unchecked", "rawtypes" }) - @Test(expectedExceptions=DateTimeException.class, groups="tck") + @Test(expectedExceptions=ClassCastException.class) public void test_date_withEra_withWrongEra() { - IsoChronology.INSTANCE.date((Era) HijrahChronology.ERA_AH, 1, 1, 1); + IsoChronology.INSTANCE.date((Era) HijrahEra.AH, 1, 1, 1); } //----------------------------------------------------------------------- // with(DateTimeAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjust1() { LocalDate base = IsoChronology.INSTANCE.date(1728, 10, 28); - LocalDate test = base.with(Adjusters.lastDayOfMonth()); + LocalDate test = base.with(TemporalAdjuster.lastDayOfMonth()); assertEquals(test, IsoChronology.INSTANCE.date(1728, 10, 31)); } - @Test(groups={"tck"}) + @Test public void test_adjust2() { LocalDate base = IsoChronology.INSTANCE.date(1728, 12, 2); - LocalDate test = base.with(Adjusters.lastDayOfMonth()); + LocalDate test = base.with(TemporalAdjuster.lastDayOfMonth()); assertEquals(test, IsoChronology.INSTANCE.date(1728, 12, 31)); } //----------------------------------------------------------------------- // ISODate.with(Local*) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjust_toLocalDate() { LocalDate isoDate = IsoChronology.INSTANCE.date(1726, 1, 4); LocalDate test = isoDate.with(LocalDate.of(2012, 7, 6)); assertEquals(test, IsoChronology.INSTANCE.date(2012, 7, 6)); } - @Test(groups={"tck"}) + @Test public void test_adjust_toMonth() { LocalDate isoDate = IsoChronology.INSTANCE.date(1726, 1, 4); assertEquals(IsoChronology.INSTANCE.date(1726, 4, 4), isoDate.with(Month.APRIL)); @@ -237,14 +238,14 @@ public class TestIsoChronology { //----------------------------------------------------------------------- // LocalDate.with(ISODate) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_LocalDate_adjustToISODate() { LocalDate isoDate = IsoChronology.INSTANCE.date(1728, 10, 29); LocalDate test = LocalDate.MIN.with(isoDate); assertEquals(test, LocalDate.of(1728, 10, 29)); } - @Test(groups={"tck"}) + @Test public void test_LocalDateTime_adjustToISODate() { LocalDate isoDate = IsoChronology.INSTANCE.date(1728, 10, 29); LocalDateTime test = LocalDateTime.MIN.with(isoDate); @@ -266,7 +267,7 @@ public class TestIsoChronology { }; } - @Test(dataProvider="leapYears", groups="tck") + @Test(dataProvider="leapYears") public void test_isLeapYear(int year, boolean isLeapYear) { assertEquals(IsoChronology.INSTANCE.isLeapYear(year), isLeapYear); } @@ -274,7 +275,7 @@ public class TestIsoChronology { //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void test_now() { assertEquals(LocalDate.from(IsoChronology.INSTANCE.dateNow()), LocalDate.now()); } @@ -293,7 +294,7 @@ public class TestIsoChronology { }; } - @Test(dataProvider="toString", groups={"tck"}) + @Test(dataProvider="toString") public void test_toString(LocalDate isoDate, String expected) { assertEquals(isoDate.toString(), expected); } @@ -301,12 +302,12 @@ public class TestIsoChronology { //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void test_equals_true() { assertTrue(IsoChronology.INSTANCE.equals(IsoChronology.INSTANCE)); } - @Test(groups="tck") + @Test public void test_equals_false() { assertFalse(IsoChronology.INSTANCE.equals(HijrahChronology.INSTANCE)); } diff --git a/jdk/test/java/time/tck/java/time/chrono/CopticChronology.java b/jdk/test/java/time/tck/java/time/chrono/CopticChronology.java index 5c55d7593cc..c111eed3658 100644 --- a/jdk/test/java/time/tck/java/time/chrono/CopticChronology.java +++ b/jdk/test/java/time/tck/java/time/chrono/CopticChronology.java @@ -59,18 +59,17 @@ package tck.java.time.chrono; import static java.time.temporal.ChronoField.EPOCH_DAY; import java.io.Serializable; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.time.DateTimeException; import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; import java.time.temporal.ValueRange; import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; import java.time.chrono.Era; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + /** * The Coptic calendar system. *

    @@ -102,16 +101,6 @@ public final class CopticChronology extends Chronology implements Serializable { * Singleton instance of the Coptic chronology. */ public static final CopticChronology INSTANCE = new CopticChronology(); - /** - * The singleton instance for the era BEFORE_AM. - * This has the numeric value of {@code 0}. - */ - public static final Era ERA_BEFORE_AM = CopticEra.BEFORE_AM; - /** - * The singleton instance for the era AM - 'Era of the Martyrs'. - * This has the numeric value of {@code 1}. - */ - public static final Era ERA_AM = CopticEra.AM; /** * Serialization version. @@ -192,6 +181,11 @@ public final class CopticChronology extends Chronology implements Serializable { return new CopticDate(prolepticYear, (dayOfYear - 1) / 30 + 1, (dayOfYear - 1) % 30 + 1); } + @Override + public CopticDate dateEpochDay(long epochDay) { + return CopticDate.ofEpochDay(epochDay); + } + @Override public CopticDate date(TemporalAccessor dateTime) { if (dateTime instanceof CopticDate) { @@ -219,7 +213,7 @@ public final class CopticChronology extends Chronology implements Serializable { @Override public int prolepticYear(Era era, int yearOfEra) { if (era instanceof CopticEra == false) { - throw new DateTimeException("Era must be CopticEra"); + throw new ClassCastException("Era must be CopticEra"); } return (era == CopticEra.AM ? yearOfEra : 1 - yearOfEra); } @@ -241,7 +235,7 @@ public final class CopticChronology extends Chronology implements Serializable { case DAY_OF_MONTH: return ValueRange.of(1, 5, 30); case ALIGNED_WEEK_OF_MONTH: return ValueRange.of(1, 1, 5); case MONTH_OF_YEAR: return ValueRange.of(1, 13); - case EPOCH_MONTH: return ValueRange.of(-1000, 1000); // TODO + case PROLEPTIC_MONTH: return ValueRange.of(-1000, 1000); // TODO case YEAR_OF_ERA: return ValueRange.of(1, 999, 1000); // TODO case YEAR: return ValueRange.of(-1000, 1000); // TODO } diff --git a/jdk/test/java/time/tck/java/time/chrono/CopticDate.java b/jdk/test/java/time/tck/java/time/chrono/CopticDate.java index d8447eb660f..aa2d627058c 100644 --- a/jdk/test/java/time/tck/java/time/chrono/CopticDate.java +++ b/jdk/test/java/time/tck/java/time/chrono/CopticDate.java @@ -68,6 +68,7 @@ import java.io.Serializable; import java.time.DateTimeException; import java.time.LocalDate; import java.time.Period; +import java.time.Year; import java.time.chrono.ChronoLocalDate; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; @@ -75,7 +76,7 @@ import java.time.temporal.Temporal; import java.time.temporal.TemporalField; import java.time.temporal.TemporalUnit; import java.time.temporal.ValueRange; -import java.time.Year; +import java.time.temporal.UnsupportedTemporalTypeException; /** * A date in the Coptic calendar system. @@ -201,7 +202,7 @@ public final class CopticDate } return getChronology().range(f); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } @@ -223,7 +224,7 @@ public final class CopticDate case YEAR: return prolepticYear; case ERA: return (prolepticYear >= 1 ? 1 : 0); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.getFrom(this); } @@ -248,7 +249,7 @@ public final class CopticDate case YEAR: return resolvePreviousValid(nvalue, month, day); case ERA: return resolvePreviousValid(1 - prolepticYear, month, day); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.adjustInto(this, newValue); } @@ -267,7 +268,7 @@ public final class CopticDate case CENTURIES: return plusYears(Math.multiplyExact(amountToAdd, 100)); case MILLENNIA: return plusYears(Math.multiplyExact(amountToAdd, 1000)); } - throw new DateTimeException(unit.getName() + " not valid for CopticDate"); + throw new UnsupportedTemporalTypeException("Unsupported unit: " + unit.getName()); } return unit.addTo(this, amountToAdd); } diff --git a/jdk/test/java/time/tck/java/time/chrono/CopticEra.java b/jdk/test/java/time/tck/java/time/chrono/CopticEra.java index cfe4bdc9b34..c1d7f56071a 100644 --- a/jdk/test/java/time/tck/java/time/chrono/CopticEra.java +++ b/jdk/test/java/time/tck/java/time/chrono/CopticEra.java @@ -71,7 +71,7 @@ import java.time.chrono.Era; *

    Implementation notes

    * This is an immutable and thread-safe enum. */ -enum CopticEra implements Era { +public enum CopticEra implements Era { /** * The singleton instance for the era BEFORE_AM, 'Before Era of the Martyrs'. @@ -118,21 +118,4 @@ enum CopticEra implements Era { return ordinal(); } - @Override - public CopticChronology getChronology() { - return CopticChronology.INSTANCE; - } - - // JDK8 default methods: - //----------------------------------------------------------------------- - @Override - public CopticDate date(int year, int month, int day) { - return (CopticDate)(getChronology().date(this, year, month, day)); - } - - @Override - public CopticDate dateYearDay(int year, int dayOfYear) { - return (CopticDate)(getChronology().dateYearDay(this, year, dayOfYear)); - } - } diff --git a/jdk/test/java/time/tck/java/time/chrono/TestChronoLocalDate.java b/jdk/test/java/time/tck/java/time/chrono/TCKChronoLocalDate.java similarity index 89% rename from jdk/test/java/time/tck/java/time/chrono/TestChronoLocalDate.java rename to jdk/test/java/time/tck/java/time/chrono/TCKChronoLocalDate.java index 51674e27f90..b30a255995c 100644 --- a/jdk/test/java/time/tck/java/time/chrono/TestChronoLocalDate.java +++ b/jdk/test/java/time/tck/java/time/chrono/TCKChronoLocalDate.java @@ -63,15 +63,18 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.time.DateTimeException; import java.time.Duration; import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneOffset; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; import java.time.chrono.JapaneseChronology; import java.time.chrono.MinguoChronology; import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.IsoChronology; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; @@ -81,6 +84,7 @@ import java.time.temporal.TemporalField; import java.time.temporal.TemporalUnit; import java.time.temporal.ValueRange; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.testng.Assert; @@ -91,7 +95,7 @@ import org.testng.annotations.Test; * Test assertions that must be true for all built-in chronologies. */ @Test -public class TestChronoLocalDate { +public class TCKChronoLocalDate { //----------------------------------------------------------------------- // regular data factory for names and descriptions of available calendars @@ -106,9 +110,9 @@ public class TestChronoLocalDate { {ThaiBuddhistChronology.INSTANCE}}; } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDate date = chrono.date(refDate); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -129,9 +133,9 @@ public class TestChronoLocalDate { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badPlusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDate date = chrono.date(refDate); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -152,9 +156,9 @@ public class TestChronoLocalDate { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badMinusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDate date = chrono.date(refDate); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -175,9 +179,9 @@ public class TestChronoLocalDate { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badPlusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDate date = chrono.date(refDate); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -199,9 +203,9 @@ public class TestChronoLocalDate { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badMinusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDate date = chrono.date(refDate); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -223,9 +227,9 @@ public class TestChronoLocalDate { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDate date = chrono.date(refDate); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -250,16 +254,13 @@ public class TestChronoLocalDate { //----------------------------------------------------------------------- // isBefore, isAfter, isEqual, DATE_COMPARATOR //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_date_comparisons(Chronology chrono) { List dates = new ArrayList<>(); - ChronoLocalDate date = chrono.date(LocalDate.of(1900, 1, 1)); + ChronoLocalDate date = chrono.date(LocalDate.of(2013, 1, 1)); // Insert dates in order, no duplicates - dates.add(date.minus(1000, ChronoUnit.YEARS)); - dates.add(date.minus(100, ChronoUnit.YEARS)); - dates.add(date.minus(10, ChronoUnit.YEARS)); dates.add(date.minus(1, ChronoUnit.YEARS)); dates.add(date.minus(1, ChronoUnit.MONTHS)); dates.add(date.minus(1, ChronoUnit.WEEKS)); @@ -269,9 +270,6 @@ public class TestChronoLocalDate { dates.add(date.plus(1, ChronoUnit.WEEKS)); dates.add(date.plus(1, ChronoUnit.MONTHS)); dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(10, ChronoUnit.YEARS)); - dates.add(date.plus(100, ChronoUnit.YEARS)); - dates.add(date.plus(1000, ChronoUnit.YEARS)); // Check these dates against the corresponding dates for every calendar for (Chronology[] clist : data_of_calendars()) { @@ -286,7 +284,7 @@ public class TestChronoLocalDate { ChronoLocalDate a = dates.get(i); for (int j = 0; j < otherDates.size(); j++) { ChronoLocalDate b = otherDates.get(j); - int cmp = ChronoLocalDate.DATE_COMPARATOR.compare(a, b); + int cmp = ChronoLocalDate.timeLineOrder().compare(a, b); if (i < j) { assertTrue(cmp < 0, a + " compare " + b); assertEquals(a.isBefore(b), true, a + " isBefore " + b); @@ -311,9 +309,9 @@ public class TestChronoLocalDate { //----------------------------------------------------------------------- // Test Serialization of Calendars //----------------------------------------------------------------------- - @Test( groups={"tck"}, dataProvider="calendars") + @Test( dataProvider="calendars") public void test_ChronoSerialization(Chronology chrono) throws Exception { - LocalDate ref = LocalDate.of(1900, 1, 5); + LocalDate ref = LocalDate.of(2013, 1, 5); ChronoLocalDate orginal = chrono.date(ref); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); @@ -326,6 +324,30 @@ public class TestChronoLocalDate { assertEquals(ser, orginal, "deserialized date is wrong"); } + //----------------------------------------------------------------------- + @Test(dataProvider="calendars") + public void test_from_TemporalAccessor(Chronology chrono) { + LocalDate refDate = LocalDate.of(2013, 1, 1); + ChronoLocalDate date = chrono.date(refDate); + ChronoLocalDate test1 = ChronoLocalDate.from(date); + assertEquals(test1, date); + ChronoLocalDate test2 = ChronoLocalDate.from(date.atTime(LocalTime.of(12, 30))); + assertEquals(test2, date); + ChronoLocalDate test3 = ChronoLocalDate.from(date.atTime(LocalTime.of(12, 30)).atZone(ZoneOffset.UTC)); + assertEquals(test3, date); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_from_TemporalAccessor_timeOnly() { + ChronoLocalDate.from(LocalTime.of(12, 30)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_from_TemporalAccessor_null() { + ChronoLocalDate.from(null); + } + + //----------------------------------------------------------------------- /** * FixedAdjusted returns a fixed Temporal in all adjustments. * Construct an adjuster with the Temporal that should be returned from adjust. diff --git a/jdk/test/java/time/tck/java/time/temporal/TestChronoLocalDateTime.java b/jdk/test/java/time/tck/java/time/chrono/TCKChronoLocalDateTime.java similarity index 89% rename from jdk/test/java/time/tck/java/time/temporal/TestChronoLocalDateTime.java rename to jdk/test/java/time/tck/java/time/chrono/TCKChronoLocalDateTime.java index 46335cedb4f..251c071d318 100644 --- a/jdk/test/java/time/tck/java/time/temporal/TestChronoLocalDateTime.java +++ b/jdk/test/java/time/tck/java/time/chrono/TCKChronoLocalDateTime.java @@ -54,7 +54,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package tck.java.time.temporal; +package tck.java.time.chrono; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -63,18 +63,19 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.time.DateTimeException; import java.time.Duration; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.ZoneOffset; +import java.time.chrono.ChronoLocalDateTime; +import java.time.chrono.Chronology; import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; import java.time.chrono.JapaneseChronology; import java.time.chrono.MinguoChronology; import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ChronoLocalDateTime; -import java.time.chrono.Chronology; -import java.time.chrono.IsoChronology; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; @@ -94,7 +95,7 @@ import org.testng.annotations.Test; * Test assertions that must be true for all built-in chronologies. */ @Test -public class TestChronoLocalDateTime { +public class TCKChronoLocalDateTime { //----------------------------------------------------------------------- // regular data factory for names and descriptions of available calendars @@ -109,9 +110,9 @@ public class TestChronoLocalDateTime { {ThaiBuddhistChronology.INSTANCE}}; } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -133,9 +134,9 @@ public class TestChronoLocalDateTime { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badPlusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -157,9 +158,9 @@ public class TestChronoLocalDateTime { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badMinusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -181,9 +182,9 @@ public class TestChronoLocalDateTime { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badPlusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -205,9 +206,9 @@ public class TestChronoLocalDateTime { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badMinusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -229,9 +230,9 @@ public class TestChronoLocalDateTime { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -256,14 +257,13 @@ public class TestChronoLocalDateTime { //----------------------------------------------------------------------- // isBefore, isAfter, isEqual //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_datetime_comparisons(Chronology chrono) { List> dates = new ArrayList<>(); - ChronoLocalDateTime date = chrono.date(LocalDate.of(1900, 1, 1)).atTime(LocalTime.MIN); + ChronoLocalDateTime date = chrono.date(LocalDate.of(2013, 1, 1)).atTime(LocalTime.MIN); // Insert dates in order, no duplicates - dates.add(date.minus(100, ChronoUnit.YEARS)); dates.add(date.minus(1, ChronoUnit.YEARS)); dates.add(date.minus(1, ChronoUnit.MONTHS)); dates.add(date.minus(1, ChronoUnit.WEEKS)); @@ -281,7 +281,6 @@ public class TestChronoLocalDateTime { dates.add(date.plus(1, ChronoUnit.WEEKS)); dates.add(date.plus(1, ChronoUnit.MONTHS)); dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(100, ChronoUnit.YEARS)); // Check these dates against the corresponding dates for every calendar for (Chronology[] clist : data_of_calendars()) { @@ -296,7 +295,7 @@ public class TestChronoLocalDateTime { ChronoLocalDateTime a = dates.get(i); for (int j = 0; j < otherDates.size(); j++) { ChronoLocalDateTime b = otherDates.get(j); - int cmp = ChronoLocalDateTime.DATE_TIME_COMPARATOR.compare(a, b); + int cmp = ChronoLocalDateTime.timeLineOrder().compare(a, b); if (i < j) { assertTrue(cmp < 0, a + " compare " + b); assertEquals(a.isBefore(b), true, a + " isBefore " + b); @@ -321,9 +320,9 @@ public class TestChronoLocalDateTime { //----------------------------------------------------------------------- // Test Serialization of ISO via chrono API //----------------------------------------------------------------------- - @Test( groups={"tck"}, dataProvider="calendars") + @Test( dataProvider="calendars") public void test_ChronoLocalDateTimeSerialization(Chronology chrono) throws Exception { - LocalDateTime ref = LocalDate.of(2000, 1, 5).atTime(12, 1, 2, 3); + LocalDateTime ref = LocalDate.of(2013, 1, 5).atTime(12, 1, 2, 3); ChronoLocalDateTime orginal = chrono.date(ref).atTime(ref.toLocalTime()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); @@ -331,11 +330,37 @@ public class TestChronoLocalDateTime { out.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream in = new ObjectInputStream(bais); - @SuppressWarnings("unchecked") ChronoLocalDateTime ser = (ChronoLocalDateTime) in.readObject(); assertEquals(ser, orginal, "deserialized date is wrong"); } + //----------------------------------------------------------------------- + @Test(dataProvider="calendars") + public void test_from_TemporalAccessor(Chronology chrono) { + LocalDateTime refDateTime = LocalDateTime.of(2013, 1, 1, 12, 30); + ChronoLocalDateTime dateTime = chrono.localDateTime(refDateTime); + ChronoLocalDateTime test1 = ChronoLocalDateTime.from(dateTime); + assertEquals(test1, dateTime); + ChronoLocalDateTime test2 = ChronoLocalDateTime.from(dateTime.atZone(ZoneOffset.UTC)); + assertEquals(test2, dateTime); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_from_TemporalAccessor_dateOnly() { + ChronoLocalDateTime.from(LocalDate.of(2013, 1, 1)); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_from_TemporalAccessor_timeOnly() { + ChronoLocalDateTime.from(LocalTime.of(12, 30)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_from_TemporalAccessor_null() { + ChronoLocalDateTime.from(null); + } + + //----------------------------------------------------------------------- /** * FixedAdjusted returns a fixed Temporal in all adjustments. * Construct an adjuster with the Temporal that should be returned from adjust. diff --git a/jdk/test/java/time/tck/java/time/temporal/TestChronoZonedDateTime.java b/jdk/test/java/time/tck/java/time/chrono/TCKChronoZonedDateTime.java similarity index 90% rename from jdk/test/java/time/tck/java/time/temporal/TestChronoZonedDateTime.java rename to jdk/test/java/time/tck/java/time/chrono/TCKChronoZonedDateTime.java index c97a0181003..611c9258df9 100644 --- a/jdk/test/java/time/tck/java/time/temporal/TestChronoZonedDateTime.java +++ b/jdk/test/java/time/tck/java/time/chrono/TCKChronoZonedDateTime.java @@ -54,7 +54,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package tck.java.time.temporal; +package tck.java.time.chrono; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -63,20 +63,20 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.time.DateTimeException; import java.time.Duration; import java.time.LocalDate; import java.time.LocalTime; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.time.chrono.ChronoZonedDateTime; +import java.time.chrono.Chronology; import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; import java.time.chrono.JapaneseChronology; import java.time.chrono.MinguoChronology; import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ChronoZonedDateTime; -import java.time.chrono.Chronology; -import java.time.chrono.IsoChronology; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; @@ -96,7 +96,7 @@ import org.testng.annotations.Test; * Test assertions that must be true for all built-in chronologies. */ @Test -public class TestChronoZonedDateTime { +public class TCKChronoZonedDateTime { //----------------------------------------------------------------------- // regular data factory for names and descriptions of available calendars @@ -112,9 +112,9 @@ public class TestChronoZonedDateTime { }; } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -135,9 +135,9 @@ public class TestChronoZonedDateTime { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badPlusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -159,9 +159,9 @@ public class TestChronoZonedDateTime { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badMinusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -183,9 +183,9 @@ public class TestChronoZonedDateTime { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badPlusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -207,9 +207,9 @@ public class TestChronoZonedDateTime { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badMinusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -231,9 +231,9 @@ public class TestChronoZonedDateTime { } } - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); + LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoZonedDateTime czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; @@ -258,16 +258,15 @@ public class TestChronoZonedDateTime { //----------------------------------------------------------------------- // isBefore, isAfter, isEqual, INSTANT_COMPARATOR test a Chronology against the other Chronos //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="calendars") + @Test(dataProvider="calendars") public void test_zonedDateTime_comparisons(Chronology chrono) { List> dates = new ArrayList<>(); - ChronoZonedDateTime date = chrono.date(LocalDate.of(1900, 1, 1)) + ChronoZonedDateTime date = chrono.date(LocalDate.of(2013, 1, 1)) .atTime(LocalTime.MIN) .atZone(ZoneOffset.UTC); // Insert dates in order, no duplicates - dates.add(date.minus(100, ChronoUnit.YEARS)); dates.add(date.minus(1, ChronoUnit.YEARS)); dates.add(date.minus(1, ChronoUnit.MONTHS)); dates.add(date.minus(1, ChronoUnit.WEEKS)); @@ -285,7 +284,6 @@ public class TestChronoZonedDateTime { dates.add(date.plus(1, ChronoUnit.WEEKS)); dates.add(date.plus(1, ChronoUnit.MONTHS)); dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(100, ChronoUnit.YEARS)); // Check these dates against the corresponding dates for every calendar for (Chronology[] clist : data_of_calendars()) { @@ -300,7 +298,7 @@ public class TestChronoZonedDateTime { ChronoZonedDateTime a = dates.get(i); for (int j = 0; j < otherDates.size(); j++) { ChronoZonedDateTime b = otherDates.get(j); - int cmp = ChronoZonedDateTime.INSTANT_COMPARATOR.compare(a, b); + int cmp = ChronoZonedDateTime.timeLineOrder().compare(a, b); if (i < j) { assertTrue(cmp < 0, a + " compare " + b); assertEquals(a.isBefore(b), true, a + " isBefore " + b); @@ -325,9 +323,9 @@ public class TestChronoZonedDateTime { //----------------------------------------------------------------------- // Test Serialization of ISO via chrono API //----------------------------------------------------------------------- - @Test( groups={"tck"}, dataProvider="calendars") + @Test( dataProvider="calendars") public void test_ChronoZonedDateTimeSerialization(Chronology chrono) throws Exception { - ZonedDateTime ref = LocalDate.of(2000, 1, 5).atTime(12, 1, 2, 3).atZone(ZoneId.of("GMT+01:23")); + ZonedDateTime ref = LocalDate.of(2013, 1, 5).atTime(12, 1, 2, 3).atZone(ZoneId.of("GMT+01:23")); ChronoZonedDateTime orginal = chrono.date(ref).atTime(ref.toLocalTime()).atZone(ref.getZone()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); @@ -340,7 +338,31 @@ public class TestChronoZonedDateTime { assertEquals(ser, orginal, "deserialized date is wrong"); } + //----------------------------------------------------------------------- + @Test(dataProvider="calendars") + public void test_from_TemporalAccessor(Chronology chrono) { + ZonedDateTime refDateTime = ZonedDateTime.of(2013, 1, 1, 12, 30, 0, 0, ZoneId.of("Europe/Paris")); + ChronoZonedDateTime dateTime = chrono.zonedDateTime(refDateTime); + ChronoZonedDateTime test1 = ChronoZonedDateTime.from(dateTime); + assertEquals(test1, dateTime); + } + @Test(expectedExceptions = DateTimeException.class) + public void test_from_TemporalAccessor_dateOnly() { + ChronoZonedDateTime.from(LocalDate.of(2013, 1, 1)); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_from_TemporalAccessor_timeOnly() { + ChronoZonedDateTime.from(LocalTime.of(12, 30)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_from_TemporalAccessor_null() { + ChronoZonedDateTime.from(null); + } + + //----------------------------------------------------------------------- /** * FixedAdjusted returns a fixed Temporal in all adjustments. * Construct an adjuster with the Temporal that should be returned from adjust. diff --git a/jdk/test/java/time/tck/java/time/chrono/TCKChronology.java b/jdk/test/java/time/tck/java/time/chrono/TCKChronology.java index c1a43093733..17aadcc1cdb 100644 --- a/jdk/test/java/time/tck/java/time/chrono/TCKChronology.java +++ b/jdk/test/java/time/tck/java/time/chrono/TCKChronology.java @@ -4,9 +4,7 @@ * * This code is free software; you can redistribute 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 @@ -24,7 +22,12 @@ */ /* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. * @@ -57,217 +60,189 @@ package tck.java.time.chrono; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertTrue; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.ZoneId; -import java.time.ZonedDateTime; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.time.DateTimeException; import java.time.chrono.ChronoLocalDate; import java.time.chrono.Chronology; -import java.time.chrono.Era; +import java.time.chrono.HijrahChronology; import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.ThaiBuddhistChronology; import java.time.temporal.ChronoField; -import java.time.temporal.Queries; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalField; -import java.time.temporal.TemporalQuery; -import java.time.temporal.ValueRange; -import java.util.List; +import java.util.Locale; +import java.util.Set; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** - * Test. + * Test Chronology class. */ @Test public class TCKChronology { - // Can only work with IsoChronology here - // others may be in separate module - @Test - public void factory_from_TemporalAccessor_dateWithChronlogy() { - assertEquals(Chronology.from(LocalDate.of(2012, 6, 30)), IsoChronology.INSTANCE); + //----------------------------------------------------------------------- + // regular data factory for ID and calendarType of available calendars + //----------------------------------------------------------------------- + @DataProvider(name = "calendarNameAndType") + Object[][] data_of_calendars() { + return new Object[][] { + {"Hijrah-umalqura", "islamic-umalqura"}, + {"ISO", "iso8601"}, + {"Japanese", "japanese"}, + {"Minguo", "roc"}, + {"ThaiBuddhist", "buddhist"}, + }; + } + + @Test(dataProvider = "calendarNameAndType") + public void test_getters(String chronoId, String calendarSystemType) { + Chronology chrono = Chronology.of(chronoId); + assertNotNull(chrono, "Required calendar not found by ID: " + chronoId); + assertEquals(chrono.getId(), chronoId); + assertEquals(chrono.getCalendarType(), calendarSystemType); + } + + @Test(dataProvider = "calendarNameAndType") + public void test_required_calendars(String chronoId, String calendarSystemType) { + Chronology chrono = Chronology.of(chronoId); + assertNotNull(chrono, "Required calendar not found by ID: " + chronoId); + chrono = Chronology.of(calendarSystemType); + assertNotNull(chrono, "Required calendar not found by type: " + chronoId); + Set cals = Chronology.getAvailableChronologies(); + assertTrue(cals.contains(chrono), "Required calendar not found in set of available calendars"); } @Test - public void factory_from_TemporalAccessor_chronology() { - assertEquals(Chronology.from(new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - throw new UnsupportedOperationException(); - } - @Override - public long getLong(TemporalField field) { - throw new UnsupportedOperationException(); - } - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.chronology()) { - return (R) IsoChronology.INSTANCE; - } - throw new UnsupportedOperationException(); - } - }), IsoChronology.INSTANCE); + public void test_calendar_list() { + Set chronos = Chronology.getAvailableChronologies(); + assertNotNull(chronos, "Required list of calendars must be non-null"); + for (Chronology chrono : chronos) { + Chronology lookup = Chronology.of(chrono.getId()); + assertNotNull(lookup, "Required calendar not found: " + chrono); + } + assertEquals(chronos.size() >= data_of_calendars().length, true, "Chronology.getAvailableChronologies().size = " + chronos.size() + + ", expected >= " + data_of_calendars().length); } - @Test - public void factory_from_TemporalAccessor_noChronology() { - assertEquals(Chronology.from(new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - throw new UnsupportedOperationException(); - } - - @Override - public long getLong(TemporalField field) { - throw new UnsupportedOperationException(); - } - - @Override - public R query(TemporalQuery query) { - if (query == Queries.chronology()) { - return null; - } - throw new UnsupportedOperationException(); - } - }), IsoChronology.INSTANCE); + /** + * Compute the number of days from the Epoch and compute the date from the number of days. + */ + @Test(dataProvider = "calendarNameAndType") + public void test_epoch(String name, String alias) { + Chronology chrono = Chronology.of(name); // a chronology. In practice this is rarely hardcoded + ChronoLocalDate date1 = chrono.dateNow(); + long epoch1 = date1.getLong(ChronoField.EPOCH_DAY); + ChronoLocalDate date2 = date1.with(ChronoField.EPOCH_DAY, epoch1); + assertEquals(date1, date2, "Date from epoch day is not same date: " + date1 + " != " + date2); + long epoch2 = date1.getLong(ChronoField.EPOCH_DAY); + assertEquals(epoch1, epoch2, "Epoch day not the same: " + epoch1 + " != " + epoch2); } - @Test(expectedExceptions=NullPointerException.class) - public void factory_from_TemporalAccessor_null() { - Chronology.from(null); + @Test(dataProvider = "calendarNameAndType") + public void test_dateEpochDay(String name, String alias) { + Chronology chrono = Chronology.of(name); + ChronoLocalDate date = chrono.dateNow(); + long epochDay = date.getLong(ChronoField.EPOCH_DAY); + ChronoLocalDate test = chrono.dateEpochDay(epochDay); + assertEquals(test, date); } //----------------------------------------------------------------------- - @Test - public void test_date_TemporalAccessor() { - assertEquals(IsoChronology.INSTANCE.date(new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - if (field == ChronoField.EPOCH_DAY) { - return true; - } - throw new UnsupportedOperationException(); - } - - @Override - public long getLong(TemporalField field) { - if (field == ChronoField.EPOCH_DAY) { - return LocalDate.of(2012, 6, 30).toEpochDay(); - } - throw new UnsupportedOperationException(); - } - - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.localDate()) { - return (R) LocalDate.of(2012, 6, 30); - } - throw new UnsupportedOperationException(); - } - }), LocalDate.of(2012, 6, 30)); + // locale based lookup + //----------------------------------------------------------------------- + @DataProvider(name = "calendarsystemtype") + Object[][] data_CalendarType() { + return new Object[][] { + {HijrahChronology.INSTANCE, "islamic", "umalqura"}, + {IsoChronology.INSTANCE, "iso8601", null}, + {JapaneseChronology.INSTANCE, "japanese", null}, + {MinguoChronology.INSTANCE, "roc", null}, + {ThaiBuddhistChronology.INSTANCE, "buddhist", null}, + }; } - @Test(expectedExceptions=NullPointerException.class) - public void test_date_TemporalAccessor_null() { - IsoChronology.INSTANCE.date(null); + @Test(dataProvider = "calendarsystemtype") + public void test_getCalendarType(Chronology chrono, String calendarType, String variant) { + String type = calendarType; + if (variant != null) { + type += '-'; + type += variant; + } + assertEquals(chrono.getCalendarType(), type); + } + + @Test(dataProvider = "calendarsystemtype") + public void test_lookupLocale(Chronology chrono, String calendarType, String variant) { + Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA"); + builder.setUnicodeLocaleKeyword("ca", calendarType); + if (variant != null) { + builder.setUnicodeLocaleKeyword("cv", variant); + } + Locale locale = builder.build(); + assertEquals(Chronology.ofLocale(locale), chrono); + } + + + /** + * Test lookup by calendarType of each chronology. + * The calendarType is split on "-" to separate the calendar and variant. + * Verify that the calendar can be found by {@link java.time.chrono.Chronology#ofLocale}. + */ + @Test + public void test_ofLocaleByType() { + // Test that all available chronologies can be successfully found using ofLocale + Set chronos = Chronology.getAvailableChronologies(); + for (Chronology chrono : chronos) { + String[] split = chrono.getCalendarType().split("-"); + + Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA"); + builder.setUnicodeLocaleKeyword("ca", split[0]); + if (split.length > 1) { + builder.setUnicodeLocaleKeyword("cv", split[1]); + } + Locale locale = builder.build(); + assertEquals(Chronology.ofLocale(locale), chrono, "Lookup by type and variant"); + } + } + + @Test(expectedExceptions=DateTimeException.class) + public void test_lookupLocale() { + Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA"); + builder.setUnicodeLocaleKeyword("ca", "xxx"); + builder.setUnicodeLocaleKeyword("cv", "yyy"); + + Locale locale = builder.build(); + Chronology.ofLocale(locale); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_noChrono() { + Chronology chrono = Chronology.of("FooFoo"); } //----------------------------------------------------------------------- - @Test - public void test_localDateTime_TemporalAccessor() { - assertEquals(IsoChronology.INSTANCE.localDateTime(new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - if (field == ChronoField.EPOCH_DAY || field == ChronoField.NANO_OF_DAY) { - return true; - } - throw new UnsupportedOperationException(); - } - - @Override - public long getLong(TemporalField field) { - if (field == ChronoField.EPOCH_DAY) { - return LocalDate.of(2012, 6, 30).toEpochDay(); - } - if (field == ChronoField.NANO_OF_DAY) { - return LocalTime.of(12, 30, 40).toNanoOfDay(); - } - throw new UnsupportedOperationException(); - } - - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.localDate()) { - return (R) LocalDate.of(2012, 6, 30); - } - if (query == Queries.localTime()) { - return (R) LocalTime.of(12, 30, 40); - } - throw new UnsupportedOperationException(); - } - }), LocalDateTime.of(2012, 6, 30, 12, 30, 40)); - } - - @Test(expectedExceptions=NullPointerException.class) - public void test_localDateTime_TemporalAccessor_null() { - IsoChronology.INSTANCE.localDateTime(null); - } - + // serialization; serialize and check each calendar system //----------------------------------------------------------------------- - @Test - public void test_zonedDateTime_TemporalAccessor() { - assertEquals(IsoChronology.INSTANCE.zonedDateTime(new TemporalAccessor() { - @Override - public boolean isSupported(TemporalField field) { - if (field == ChronoField.EPOCH_DAY || field == ChronoField.NANO_OF_DAY || - field == ChronoField.INSTANT_SECONDS || field == ChronoField.NANO_OF_SECOND) { - return true; - } - throw new UnsupportedOperationException(); - } - - @Override - public long getLong(TemporalField field) { - if (field == ChronoField.INSTANT_SECONDS) { - return ZonedDateTime.of(2012, 6, 30, 12, 30, 40, 0, ZoneId.of("Europe/London")).toEpochSecond(); - } - if (field == ChronoField.NANO_OF_SECOND) { - return 0; - } - if (field == ChronoField.EPOCH_DAY) { - return LocalDate.of(2012, 6, 30).toEpochDay(); - } - if (field == ChronoField.NANO_OF_DAY) { - return LocalTime.of(12, 30, 40).toNanoOfDay(); - } - throw new UnsupportedOperationException(); - } - - @SuppressWarnings("unchecked") - @Override - public R query(TemporalQuery query) { - if (query == Queries.localDate()) { - return (R) LocalDate.of(2012, 6, 30); - } - if (query == Queries.localTime()) { - return (R) LocalTime.of(12, 30, 40); - } - if (query == Queries.zoneId() || query == Queries.zone()) { - return (R) ZoneId.of("Europe/London"); - } - throw new UnsupportedOperationException(); - } - }), ZonedDateTime.of(2012, 6, 30, 12, 30, 40, 0, ZoneId.of("Europe/London"))); - } - - @Test(expectedExceptions=NullPointerException.class) - public void test_zonedDateTime_TemporalAccessor_null() { - IsoChronology.INSTANCE.zonedDateTime(null); + @Test(dataProvider = "calendarNameAndType") + public void test_chronoSerializationSingleton(String id, String _calendarType) throws Exception { + Chronology original = Chronology.of(id); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(baos); + out.writeObject(original); + out.close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream in = new ObjectInputStream(bais); + Chronology ser = (Chronology) in.readObject(); + assertEquals(ser, original, "Deserialized Chronology is not correct"); } } diff --git a/jdk/test/java/time/tck/java/time/chrono/TCKChronologySerialization.java b/jdk/test/java/time/tck/java/time/chrono/TCKChronologySerialization.java new file mode 100644 index 00000000000..c4e44998139 --- /dev/null +++ b/jdk/test/java/time/tck/java/time/chrono/TCKChronologySerialization.java @@ -0,0 +1,135 @@ +/* + * 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. 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. + */ + +/* + * Copyright (c) 2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static org.testng.Assert.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.PrintStream; +import java.time.chrono.Chronology; +import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.ThaiBuddhistChronology; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +public class TCKChronologySerialization { + + //----------------------------------------------------------------------- + // regular data factory for names and descriptions of available calendars + //----------------------------------------------------------------------- + @DataProvider(name = "calendars") + Chronology[][] data_of_calendars() { + return new Chronology[][]{ + {HijrahChronology.INSTANCE}, + {IsoChronology.INSTANCE}, + {JapaneseChronology.INSTANCE}, + {MinguoChronology.INSTANCE}, + {ThaiBuddhistChronology.INSTANCE}}; + } + + //----------------------------------------------------------------------- + // Test Serialization of Calendars + //----------------------------------------------------------------------- + @Test(dataProvider="calendars") + public void test_ChronoSerialization(Chronology chrono) throws Exception { + System.out.printf(" ChronoSerialization: %s%n", chrono); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(baos); + out.writeObject(chrono); + out.close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + + ObjectInputStream in = new ObjectInputStream(bais); + @SuppressWarnings("unchecked") + Chronology ser = (Chronology) in.readObject(); + assertEquals(ser, chrono, "deserialized Chronology is wrong"); + } + + /** + * Utility method to dump a byte array in a java syntax. + * @param bytes and array of bytes + * @param os the outputstream to receive the output. + */ + static void dumpSerialStream(byte[] bytes, PrintStream os) { + os.printf(" byte[] bytes = {" ); + final int linelen = 10; + for (int i = 0; i < bytes.length; i++) { + if (i % linelen == 0) { + os.printf("%n "); + } + os.printf(" %3d,", bytes[i] & 0xff); + if ((i % linelen) == (linelen-1) || i == bytes.length - 1) { + os.printf(" /*"); + int s = i / linelen * linelen; + int k = i % linelen; + for (int j = 0; j <= k && s + j < bytes.length; j++) { + os.printf(" %c", bytes[s + j] & 0xff); + } + os.printf(" */"); + } + } + os.printf("%n };%n"); + } + +} diff --git a/jdk/test/java/time/tck/java/time/chrono/TestHijrahChronology.java b/jdk/test/java/time/tck/java/time/chrono/TCKHijrahChronology.java similarity index 51% rename from jdk/test/java/time/tck/java/time/chrono/TestHijrahChronology.java rename to jdk/test/java/time/tck/java/time/chrono/TCKHijrahChronology.java index 1938c5e9849..0efd1ab640a 100644 --- a/jdk/test/java/time/tck/java/time/chrono/TestHijrahChronology.java +++ b/jdk/test/java/time/tck/java/time/chrono/TCKHijrahChronology.java @@ -56,20 +56,28 @@ */ package tck.java.time.chrono; +import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.time.DateTimeException; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.Month; +import java.time.Period; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.Era; import java.time.chrono.HijrahChronology; import java.time.chrono.HijrahDate; -import java.time.chrono.ChronoLocalDate; -import java.time.temporal.Adjusters; -import java.time.chrono.Chronology; import java.time.chrono.IsoChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.MinguoDate; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjuster; +import java.util.List; import org.testng.Assert; import org.testng.annotations.DataProvider; @@ -79,18 +87,18 @@ import org.testng.annotations.Test; * Test. */ @Test -public class TestHijrahChronology { +public class TCKHijrahChronology { //----------------------------------------------------------------------- // Chronology.ofName("Hijrah") Lookup by name //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_chrono_byName() { Chronology c = HijrahChronology.INSTANCE; - Chronology test = Chronology.of("Hijrah"); - Assert.assertNotNull(test, "The Hijrah calendar could not be found byName"); - Assert.assertEquals(test.getId(), "Hijrah", "ID mismatch"); - Assert.assertEquals(test.getCalendarType(), "islamicc", "Type mismatch"); + Chronology test = Chronology.of("Hijrah-umalqura"); + Assert.assertNotNull(test, "The Hijrah-umalqura calendar could not be found by name"); + Assert.assertEquals(test.getId(), "Hijrah-umalqura", "ID mismatch"); + Assert.assertEquals(test.getCalendarType(), "islamic-umalqura", "Type mismatch"); Assert.assertEquals(test, c); } @@ -100,106 +108,181 @@ public class TestHijrahChronology { @DataProvider(name="samples") Object[][] data_samples() { return new Object[][] { - {HijrahChronology.INSTANCE.date(1, 1, 1), LocalDate.of(622, 7, 19)}, - {HijrahChronology.INSTANCE.date(1, 1, 2), LocalDate.of(622, 7, 20)}, - {HijrahChronology.INSTANCE.date(1, 1, 3), LocalDate.of(622, 7, 21)}, + //{HijrahChronology.INSTANCE.date(1320, 1, 1), LocalDate.of(1902, 4, 9)}, + //{HijrahChronology.INSTANCE.date(1320, 1, 2), LocalDate.of(1902, 4, 10)}, + //{HijrahChronology.INSTANCE.date(1320, 1, 3), LocalDate.of(1902, 4, 11)}, - {HijrahChronology.INSTANCE.date(2, 1, 1), LocalDate.of(623, 7, 8)}, - {HijrahChronology.INSTANCE.date(3, 1, 1), LocalDate.of(624, 6, 27)}, - {HijrahChronology.INSTANCE.date(3, 12, 6), LocalDate.of(625, 5, 23)}, - {HijrahChronology.INSTANCE.date(4, 1, 1), LocalDate.of(625, 6, 16)}, - {HijrahChronology.INSTANCE.date(4, 7, 3), LocalDate.of(625, 12, 12)}, - {HijrahChronology.INSTANCE.date(4, 7, 4), LocalDate.of(625, 12, 13)}, - {HijrahChronology.INSTANCE.date(5, 1, 1), LocalDate.of(626, 6, 5)}, - {HijrahChronology.INSTANCE.date(1662, 3, 3), LocalDate.of(2234, 4, 3)}, - {HijrahChronology.INSTANCE.date(1728, 10, 28), LocalDate.of(2298, 12, 03)}, - {HijrahChronology.INSTANCE.date(1728, 10, 29), LocalDate.of(2298, 12, 04)}, + //{HijrahChronology.INSTANCE.date(1322, 1, 1), LocalDate.of(1904, 3, 18)}, + //{HijrahChronology.INSTANCE.date(1323, 1, 1), LocalDate.of(1905, 3, 7)}, + //{HijrahChronology.INSTANCE.date(1323, 12, 6), LocalDate.of(1906, 1, 30)}, + //{HijrahChronology.INSTANCE.date(1324, 1, 1), LocalDate.of(1906, 2, 24)}, + //{HijrahChronology.INSTANCE.date(1324, 7, 3), LocalDate.of(1906, 8, 23)}, + //{HijrahChronology.INSTANCE.date(1324, 7, 4), LocalDate.of(1906, 8, 24)}, + //{HijrahChronology.INSTANCE.date(1325, 1, 1), LocalDate.of(1907, 2, 13)}, + {HijrahChronology.INSTANCE.date(1434, 7, 1), LocalDate.of(2013, 5, 11)}, + + //{HijrahChronology.INSTANCE.date(1500, 3, 3), LocalDate.of(2079, 1, 5)}, + //{HijrahChronology.INSTANCE.date(1500, 10, 28), LocalDate.of(2079, 8, 25)}, + //{HijrahChronology.INSTANCE.date(1500, 10, 29), LocalDate.of(2079, 8, 26)}, }; } - @Test(dataProvider="samples", groups={"tck"}) + @Test(dataProvider="samples") public void test_toLocalDate(ChronoLocalDate hijrahDate, LocalDate iso) { assertEquals(LocalDate.from(hijrahDate), iso); } - @Test(dataProvider="samples", groups={"tck"}) + @Test(dataProvider="samples") public void test_fromCalendrical(ChronoLocalDate hijrahDate, LocalDate iso) { assertEquals(HijrahChronology.INSTANCE.date(iso), hijrahDate); } + @Test(dataProvider="samples") + public void test_dayOfWeekEqualIsoDayOfWeek(ChronoLocalDate hijrahDate, LocalDate iso) { + assertEquals(hijrahDate.get(DAY_OF_WEEK), iso.get(DAY_OF_WEEK), "Hijrah day of week should be same as ISO day of week"); + } + @DataProvider(name="badDates") Object[][] data_badDates() { return new Object[][] { - {1728, 0, 0}, + {1434, 0, 0}, - {1728, -1, 1}, - {1728, 0, 1}, - {1728, 14, 1}, - {1728, 15, 1}, + {1434, -1, 1}, + {1434, 0, 1}, + {1434, 14, 1}, + {1434, 15, 1}, - {1728, 1, -1}, - {1728, 1, 0}, - {1728, 1, 32}, + {1434, 1, -1}, + {1434, 1, 0}, + {1434, 1, 32}, - {1728, 12, -1}, - {1728, 12, 0}, - {1728, 12, 32}, + {1434, 12, -1}, + {1434, 12, 0}, + {1434, 12, 32}, }; } - @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) public void test_badDates(int year, int month, int dom) { HijrahChronology.INSTANCE.date(year, month, dom); } //----------------------------------------------------------------------- - // with(WithAdjuster) + // Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...) //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_adjust1() { - ChronoLocalDate base = HijrahChronology.INSTANCE.date(1728, 10, 28); - ChronoLocalDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, HijrahChronology.INSTANCE.date(1728, 10, 29)); + @Test + public void test_InvalidEras() { + // Verify that the eras from every other Chronology are invalid + for (Chronology chrono : Chronology.getAvailableChronologies()) { + if (chrono instanceof HijrahChronology) { + continue; + } + List eras = chrono.eras(); + for (Era era : eras) { + try { + ChronoLocalDate date = HijrahChronology.INSTANCE.date(era, 1, 1, 1); + fail("HijrahChronology.date did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + /* TODO: Test for missing HijrahDate.of(Era, y, m, d) method. + try { + @SuppressWarnings("unused") + HijrahDate jdate = HijrahDate.of(era, 1, 1, 1); + fail("HijrahDate.of did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + */ + + try { + @SuppressWarnings("unused") + int year = HijrahChronology.INSTANCE.prolepticYear(era, 1); + fail("HijrahChronology.prolepticYear did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + } + } } - @Test(groups={"tck"}) + //----------------------------------------------------------------------- + // with(WithAdjuster) + //----------------------------------------------------------------------- + @Test + public void test_adjust1() { + ChronoLocalDate base = HijrahChronology.INSTANCE.date(1434, 5, 15); + ChronoLocalDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, HijrahChronology.INSTANCE.date(1434, 5, 29)); + } + + @Test public void test_adjust2() { - ChronoLocalDate base = HijrahChronology.INSTANCE.date(1728, 12, 2); - ChronoLocalDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, HijrahChronology.INSTANCE.date(1728, 12, 30)); + ChronoLocalDate base = HijrahChronology.INSTANCE.date(1434, 6, 2); + ChronoLocalDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, HijrahChronology.INSTANCE.date(1434, 6, 30)); } //----------------------------------------------------------------------- // HijrahDate.with(Local*) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjust_toLocalDate() { - ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1726, 1, 4); + ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1435, 1, 4); ChronoLocalDate test = hijrahDate.with(LocalDate.of(2012, 7, 6)); assertEquals(test, HijrahChronology.INSTANCE.date(1433, 8, 16)); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_adjust_toMonth() { - ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1726, 1, 4); + ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1435, 1, 4); hijrahDate.with(Month.APRIL); } //----------------------------------------------------------------------- // LocalDate.with(HijrahDate) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_LocalDate_adjustToHijrahDate() { - ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1728, 10, 29); + ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1434, 5, 15); LocalDate test = LocalDate.MIN.with(hijrahDate); - assertEquals(test, LocalDate.of(2298, 12, 4)); + assertEquals(test, LocalDate.of(2013, 3, 27)); } - @Test(groups={"tck"}) + @Test public void test_LocalDateTime_adjustToHijrahDate() { - ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1728, 10, 29); + ChronoLocalDate hijrahDate = HijrahChronology.INSTANCE.date(1435, 5, 15); LocalDateTime test = LocalDateTime.MIN.with(hijrahDate); - assertEquals(test, LocalDateTime.of(2298, 12, 4, 0, 0)); + assertEquals(test, LocalDateTime.of(2014, 3, 16, 0, 0)); + } + + //----------------------------------------------------------------------- + // PeriodUntil() + //----------------------------------------------------------------------- + @Test + public void test_periodUntilDate() { + HijrahDate mdate1 = HijrahDate.of(1434, 1, 1); + HijrahDate mdate2 = HijrahDate.of(1435, 2, 2); + Period period = mdate1.periodUntil(mdate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + @Test + public void test_periodUntilUnit() { + HijrahDate mdate1 = HijrahDate.of(1434, 1, 1); + HijrahDate mdate2 = HijrahDate.of(1435, 2, 2); + long months = mdate1.periodUntil(mdate2, ChronoUnit.MONTHS); + assertEquals(months, 13); + } + + @Test + public void test_periodUntilDiffChrono() { + HijrahDate mdate1 = HijrahDate.of(1434, 1, 1); + HijrahDate mdate2 = HijrahDate.of(1435, 2, 2); + MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2); + Period period = mdate1.periodUntil(ldate2); + assertEquals(period, Period.of(1, 1, 1)); } //----------------------------------------------------------------------- @@ -208,15 +291,15 @@ public class TestHijrahChronology { @DataProvider(name="toString") Object[][] data_toString() { return new Object[][] { - {HijrahChronology.INSTANCE.date(1, 1, 1), "Hijrah AH 1-01-01"}, - {HijrahChronology.INSTANCE.date(1728, 10, 28), "Hijrah AH 1728-10-28"}, - {HijrahChronology.INSTANCE.date(1728, 10, 29), "Hijrah AH 1728-10-29"}, - {HijrahChronology.INSTANCE.date(1727, 12, 5), "Hijrah AH 1727-12-05"}, - {HijrahChronology.INSTANCE.date(1727, 12, 6), "Hijrah AH 1727-12-06"}, + //{HijrahChronology.INSTANCE.date(1320, 1, 1), "Hijrah AH 1320-01-01"}, + //{HijrahChronology.INSTANCE.date(1500, 10, 28), "Hijrah AH 1500-10-28"}, + //{HijrahChronology.INSTANCE.date(1500, 10, 29), "Hijrah AH 1500-10-29"}, + {HijrahChronology.INSTANCE.date(1434, 12, 5), "Hijrah-umalqura AH 1434-12-05"}, + {HijrahChronology.INSTANCE.date(1434, 12, 6), "Hijrah-umalqura AH 1434-12-06"}, }; } - @Test(dataProvider="toString", groups={"tck"}) + @Test(dataProvider="toString") public void test_toString(ChronoLocalDate hijrahDate, String expected) { assertEquals(hijrahDate.toString(), expected); } @@ -224,12 +307,12 @@ public class TestHijrahChronology { //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void test_equals_true() { assertTrue(HijrahChronology.INSTANCE.equals(HijrahChronology.INSTANCE)); } - @Test(groups="tck") + @Test public void test_equals_false() { assertFalse(HijrahChronology.INSTANCE.equals(IsoChronology.INSTANCE)); } diff --git a/jdk/test/java/time/tck/java/time/chrono/TCKHijrahEra.java b/jdk/test/java/time/tck/java/time/chrono/TCKHijrahEra.java new file mode 100644 index 00000000000..569eff0f3f4 --- /dev/null +++ b/jdk/test/java/time/tck/java/time/chrono/TCKHijrahEra.java @@ -0,0 +1,115 @@ +/* + * 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. 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static java.time.temporal.ChronoField.ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.chrono.Era; +import java.time.chrono.HijrahChronology; +import java.time.chrono.HijrahEra; +import java.time.temporal.ValueRange; +import java.util.List; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKHijrahEra { + + @DataProvider(name = "HijrahEras") + Object[][] data_of_eras() { + return new Object[][] { + {HijrahEra.AH, "AH", 1}, + }; + } + + @Test(dataProvider="HijrahEras") + public void test_valueOf(HijrahEra era , String eraName, int eraValue) { + assertEquals(era.getValue(), eraValue); + assertEquals(HijrahEra.of(eraValue), era); + assertEquals(HijrahEra.valueOf(eraName), era); + } + + //----------------------------------------------------------------------- + // values() + //----------------------------------------------------------------------- + @Test + public void test_values() { + List eraList = HijrahChronology.INSTANCE.eras(); + HijrahEra[] eras = HijrahEra.values(); + assertEquals(eraList.size(), eras.length); + for (HijrahEra era : eras) { + assertTrue(eraList.contains(era)); + } + } + + //----------------------------------------------------------------------- + // range() + //----------------------------------------------------------------------- + @Test + public void test_range() { + for (HijrahEra era : HijrahEra.values()) { + assertEquals(era.range(ERA), ValueRange.of(1, 1)); + } + } + +} diff --git a/jdk/test/java/time/tck/java/time/chrono/TCKIsoChronology.java b/jdk/test/java/time/tck/java/time/chrono/TCKIsoChronology.java new file mode 100644 index 00000000000..b30c1ffbfcc --- /dev/null +++ b/jdk/test/java/time/tck/java/time/chrono/TCKIsoChronology.java @@ -0,0 +1,679 @@ +/* + * 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. 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.chrono.Chronology; +import java.time.chrono.IsoChronology; +import java.time.format.ResolverStyle; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; +import java.util.HashMap; +import java.util.Map; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKIsoChronology { + // Can only work with IsoChronology here + // others may be in separate module + + @Test + public void factory_from_TemporalAccessor_dateWithChronlogy() { + assertEquals(Chronology.from(LocalDate.of(2012, 6, 30)), IsoChronology.INSTANCE); + } + + @Test + public void factory_from_TemporalAccessor_chronology() { + assertEquals(Chronology.from(new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + throw new UnsupportedOperationException(); + } + + @Override + public long getLong(TemporalField field) { + throw new UnsupportedOperationException(); + } + + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.chronology()) { + return (R) IsoChronology.INSTANCE; + } + throw new UnsupportedOperationException(); + } + }), IsoChronology.INSTANCE); + } + + @Test + public void factory_from_TemporalAccessor_noChronology() { + assertEquals(Chronology.from(new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + throw new UnsupportedOperationException(); + } + + @Override + public long getLong(TemporalField field) { + throw new UnsupportedOperationException(); + } + + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.chronology()) { + return null; + } + throw new UnsupportedOperationException(); + } + }), IsoChronology.INSTANCE); + } + + @Test(expectedExceptions=NullPointerException.class) + public void factory_from_TemporalAccessor_null() { + Chronology.from(null); + } + + //----------------------------------------------------------------------- + @Test + public void test_date_TemporalAccessor() { + assertEquals(IsoChronology.INSTANCE.date(new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + if (field == ChronoField.EPOCH_DAY) { + return true; + } + throw new UnsupportedOperationException(); + } + + @Override + public long getLong(TemporalField field) { + if (field == ChronoField.EPOCH_DAY) { + return LocalDate.of(2012, 6, 30).toEpochDay(); + } + throw new UnsupportedOperationException(); + } + + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.localDate()) { + return (R) LocalDate.of(2012, 6, 30); + } + throw new UnsupportedOperationException(); + } + }), LocalDate.of(2012, 6, 30)); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_date_TemporalAccessor_null() { + IsoChronology.INSTANCE.date(null); + } + + //----------------------------------------------------------------------- + @Test + public void test_localDateTime_TemporalAccessor() { + assertEquals(IsoChronology.INSTANCE.localDateTime(new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + if (field == ChronoField.EPOCH_DAY || field == ChronoField.NANO_OF_DAY) { + return true; + } + throw new UnsupportedOperationException(); + } + + @Override + public long getLong(TemporalField field) { + if (field == ChronoField.EPOCH_DAY) { + return LocalDate.of(2012, 6, 30).toEpochDay(); + } + if (field == ChronoField.NANO_OF_DAY) { + return LocalTime.of(12, 30, 40).toNanoOfDay(); + } + throw new UnsupportedOperationException(); + } + + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.localDate()) { + return (R) LocalDate.of(2012, 6, 30); + } + if (query == TemporalQuery.localTime()) { + return (R) LocalTime.of(12, 30, 40); + } + throw new UnsupportedOperationException(); + } + }), LocalDateTime.of(2012, 6, 30, 12, 30, 40)); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_localDateTime_TemporalAccessor_null() { + IsoChronology.INSTANCE.localDateTime(null); + } + + //----------------------------------------------------------------------- + @Test + public void test_zonedDateTime_TemporalAccessor() { + assertEquals(IsoChronology.INSTANCE.zonedDateTime(new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + if (field == ChronoField.EPOCH_DAY || field == ChronoField.NANO_OF_DAY || + field == ChronoField.INSTANT_SECONDS || field == ChronoField.NANO_OF_SECOND) { + return true; + } + throw new UnsupportedOperationException(); + } + + @Override + public long getLong(TemporalField field) { + if (field == ChronoField.INSTANT_SECONDS) { + return ZonedDateTime.of(2012, 6, 30, 12, 30, 40, 0, ZoneId.of("Europe/London")).toEpochSecond(); + } + if (field == ChronoField.NANO_OF_SECOND) { + return 0; + } + if (field == ChronoField.EPOCH_DAY) { + return LocalDate.of(2012, 6, 30).toEpochDay(); + } + if (field == ChronoField.NANO_OF_DAY) { + return LocalTime.of(12, 30, 40).toNanoOfDay(); + } + throw new UnsupportedOperationException(); + } + + @SuppressWarnings("unchecked") + @Override + public R query(TemporalQuery query) { + if (query == TemporalQuery.localDate()) { + return (R) LocalDate.of(2012, 6, 30); + } + if (query == TemporalQuery.localTime()) { + return (R) LocalTime.of(12, 30, 40); + } + if (query == TemporalQuery.zoneId() || query == TemporalQuery.zone()) { + return (R) ZoneId.of("Europe/London"); + } + throw new UnsupportedOperationException(); + } + }), ZonedDateTime.of(2012, 6, 30, 12, 30, 40, 0, ZoneId.of("Europe/London"))); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_zonedDateTime_TemporalAccessor_null() { + IsoChronology.INSTANCE.zonedDateTime(null); + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name = "resolve_yearOfEra") + Object[][] data_resolve_yearOfEra() { + return new Object[][] { + {-1, 2012, null, null, false, false}, + {0, 2012, null, -2011, true, true}, + {1, 2012, null, 2012, true, true}, + {2, 2012, null, null, false, false}, + + {null, 2012, null, 2012, true, null}, + {null, 2012, 2012, 2012, true, true}, + {null, 2012, -2011, -2011, true, true}, + {null, 2012, 2013, null, false, false}, + {null, 2012, -2013, null, false, false}, + }; + } + + @Test(dataProvider = "resolve_yearOfEra") + public void test_resolve_yearOfEra_lenient(Integer e, int yoe, Integer y, Integer expected, boolean smart, Boolean strict) { + Map fieldValues = new HashMap<>(); + if (e != null) { + fieldValues.put(ChronoField.ERA, (long) e); + } + fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe); + if (y != null) { + fieldValues.put(ChronoField.YEAR, (long) y); + } + if (smart) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT); + assertEquals(date, null); + assertEquals(fieldValues.get(ChronoField.YEAR), (Long) (long) expected); + assertEquals(fieldValues.size(), 1); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + @Test(dataProvider = "resolve_yearOfEra") + public void test_resolve_yearOfEra_smart(Integer e, int yoe, Integer y, Integer expected, boolean smart, Boolean strict) { + Map fieldValues = new HashMap<>(); + if (e != null) { + fieldValues.put(ChronoField.ERA, (long) e); + } + fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe); + if (y != null) { + fieldValues.put(ChronoField.YEAR, (long) y); + } + if (smart) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + assertEquals(date, null); + assertEquals(fieldValues.get(ChronoField.YEAR), (Long) (long) expected); + assertEquals(fieldValues.size(), 1); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + @Test(dataProvider = "resolve_yearOfEra") + public void test_resolve_yearOfEra_strict(Integer e, int yoe, Integer y, Integer expected, boolean smart, Boolean strict) { + Map fieldValues = new HashMap<>(); + if (e != null) { + fieldValues.put(ChronoField.ERA, (long) e); + } + fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe); + if (y != null) { + fieldValues.put(ChronoField.YEAR, (long) y); + } + if (strict == null) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + assertEquals(date, null); + assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (Long) (long) yoe); + } else if (strict) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + assertEquals(date, null); + assertEquals(fieldValues.get(ChronoField.YEAR), (Long) (long) expected); + assertEquals(fieldValues.size(), 1); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name = "resolve_ymd") + Object[][] data_resolve_ymd() { + return new Object[][] { + {2012, 1, -365, date(2010, 12, 31), false, false}, + {2012, 1, -364, date(2011, 1, 1), false, false}, + {2012, 1, -31, date(2011, 11, 30), false, false}, + {2012, 1, -30, date(2011, 12, 1), false, false}, + {2012, 1, -12, date(2011, 12, 19), false, false}, + {2012, 1, 1, date(2012, 1, 1), true, true}, + {2012, 1, 59, date(2012, 2, 28), false, false}, + {2012, 1, 60, date(2012, 2, 29), false, false}, + {2012, 1, 61, date(2012, 3, 1), false, false}, + {2012, 1, 365, date(2012, 12, 30), false, false}, + {2012, 1, 366, date(2012, 12, 31), false, false}, + {2012, 1, 367, date(2013, 1, 1), false, false}, + {2012, 1, 367 + 364, date(2013, 12, 31), false, false}, + {2012, 1, 367 + 365, date(2014, 1, 1), false, false}, + + {2012, 2, 1, date(2012, 2, 1), true, true}, + {2012, 2, 28, date(2012, 2, 28), true, true}, + {2012, 2, 29, date(2012, 2, 29), true, true}, + {2012, 2, 30, date(2012, 3, 1), date(2012, 2, 29), false}, + {2012, 2, 31, date(2012, 3, 2), date(2012, 2, 29), false}, + {2012, 2, 32, date(2012, 3, 3), false, false}, + + {2012, -12, 1, date(2010, 12, 1), false, false}, + {2012, -11, 1, date(2011, 1, 1), false, false}, + {2012, -1, 1, date(2011, 11, 1), false, false}, + {2012, 0, 1, date(2011, 12, 1), false, false}, + {2012, 1, 1, date(2012, 1, 1), true, true}, + {2012, 12, 1, date(2012, 12, 1), true, true}, + {2012, 13, 1, date(2013, 1, 1), false, false}, + {2012, 24, 1, date(2013, 12, 1), false, false}, + {2012, 25, 1, date(2014, 1, 1), false, false}, + + {2012, 6, -31, date(2012, 4, 30), false, false}, + {2012, 6, -30, date(2012, 5, 1), false, false}, + {2012, 6, -1, date(2012, 5, 30), false, false}, + {2012, 6, 0, date(2012, 5, 31), false, false}, + {2012, 6, 1, date(2012, 6, 1), true, true}, + {2012, 6, 30, date(2012, 6, 30), true, true}, + {2012, 6, 31, date(2012, 7, 1), date(2012, 6, 30), false}, + {2012, 6, 61, date(2012, 7, 31), false, false}, + {2012, 6, 62, date(2012, 8, 1), false, false}, + + {2011, 2, 1, date(2011, 2, 1), true, true}, + {2011, 2, 28, date(2011, 2, 28), true, true}, + {2011, 2, 29, date(2011, 3, 1), date(2011, 2, 28), false}, + {2011, 2, 30, date(2011, 3, 2), date(2011, 2, 28), false}, + {2011, 2, 31, date(2011, 3, 3), date(2011, 2, 28), false}, + {2011, 2, 32, date(2011, 3, 4), false, false}, + }; + } + + @Test(dataProvider = "resolve_ymd") + public void test_resolve_ymd_lenient(int y, int m, int d, LocalDate expected, Object smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d); + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } + + @Test(dataProvider = "resolve_ymd") + public void test_resolve_ymd_smart(int y, int m, int d, LocalDate expected, Object smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d); + if (Boolean.TRUE.equals(smart)) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else if (smart instanceof LocalDate) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + assertEquals(date, smart); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + @Test(dataProvider = "resolve_ymd") + public void test_resolve_ymd_strict(int y, int m, int d, LocalDate expected, Object smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d); + if (strict) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name = "resolve_yd") + Object[][] data_resolve_yd() { + return new Object[][] { + {2012, -365, date(2010, 12, 31), false, false}, + {2012, -364, date(2011, 1, 1), false, false}, + {2012, -31, date(2011, 11, 30), false, false}, + {2012, -30, date(2011, 12, 1), false, false}, + {2012, -12, date(2011, 12, 19), false, false}, + {2012, -1, date(2011, 12, 30), false, false}, + {2012, 0, date(2011, 12, 31), false, false}, + {2012, 1, date(2012, 1, 1), true, true}, + {2012, 2, date(2012, 1, 2), true, true}, + {2012, 31, date(2012, 1, 31), true, true}, + {2012, 32, date(2012, 2, 1), true, true}, + {2012, 59, date(2012, 2, 28), true, true}, + {2012, 60, date(2012, 2, 29), true, true}, + {2012, 61, date(2012, 3, 1), true, true}, + {2012, 365, date(2012, 12, 30), true, true}, + {2012, 366, date(2012, 12, 31), true, true}, + {2012, 367, date(2013, 1, 1), false, false}, + {2012, 367 + 364, date(2013, 12, 31), false, false}, + {2012, 367 + 365, date(2014, 1, 1), false, false}, + + {2011, 59, date(2011, 2, 28), true, true}, + {2011, 60, date(2011, 3, 1), true, true}, + }; + } + + @Test(dataProvider = "resolve_yd") + public void test_resolve_yd_lenient(int y, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d); + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } + + @Test(dataProvider = "resolve_yd") + public void test_resolve_yd_smart(int y, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d); + if (smart) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + @Test(dataProvider = "resolve_yd") + public void test_resolve_yd_strict(int y, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d); + if (strict) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name = "resolve_ymaa") + Object[][] data_resolve_ymaa() { + return new Object[][] { + {2012, 1, 1, -365, date(2010, 12, 31), false, false}, + {2012, 1, 1, -364, date(2011, 1, 1), false, false}, + {2012, 1, 1, -31, date(2011, 11, 30), false, false}, + {2012, 1, 1, -30, date(2011, 12, 1), false, false}, + {2012, 1, 1, -12, date(2011, 12, 19), false, false}, + {2012, 1, 1, 1, date(2012, 1, 1), true, true}, + {2012, 1, 1, 59, date(2012, 2, 28), false, false}, + {2012, 1, 1, 60, date(2012, 2, 29), false, false}, + {2012, 1, 1, 61, date(2012, 3, 1), false, false}, + {2012, 1, 1, 365, date(2012, 12, 30), false, false}, + {2012, 1, 1, 366, date(2012, 12, 31), false, false}, + {2012, 1, 1, 367, date(2013, 1, 1), false, false}, + {2012, 1, 1, 367 + 364, date(2013, 12, 31), false, false}, + {2012, 1, 1, 367 + 365, date(2014, 1, 1), false, false}, + + {2012, 2, 0, 1, date(2012, 1, 25), false, false}, + {2012, 2, 0, 7, date(2012, 1, 31), false, false}, + {2012, 2, 1, 1, date(2012, 2, 1), true, true}, + {2012, 2, 1, 7, date(2012, 2, 7), true, true}, + {2012, 2, 2, 1, date(2012, 2, 8), true, true}, + {2012, 2, 2, 7, date(2012, 2, 14), true, true}, + {2012, 2, 3, 1, date(2012, 2, 15), true, true}, + {2012, 2, 3, 7, date(2012, 2, 21), true, true}, + {2012, 2, 4, 1, date(2012, 2, 22), true, true}, + {2012, 2, 4, 7, date(2012, 2, 28), true, true}, + {2012, 2, 5, 1, date(2012, 2, 29), true, true}, + {2012, 2, 5, 2, date(2012, 3, 1), true, false}, + {2012, 2, 5, 7, date(2012, 3, 6), true, false}, + {2012, 2, 6, 1, date(2012, 3, 7), false, false}, + {2012, 2, 6, 7, date(2012, 3, 13), false, false}, + + {2012, 12, 1, 1, date(2012, 12, 1), true, true}, + {2012, 12, 5, 1, date(2012, 12, 29), true, true}, + {2012, 12, 5, 2, date(2012, 12, 30), true, true}, + {2012, 12, 5, 3, date(2012, 12, 31), true, true}, + {2012, 12, 5, 4, date(2013, 1, 1), true, false}, + {2012, 12, 5, 7, date(2013, 1, 4), true, false}, + + {2012, -12, 1, 1, date(2010, 12, 1), false, false}, + {2012, -11, 1, 1, date(2011, 1, 1), false, false}, + {2012, -1, 1, 1, date(2011, 11, 1), false, false}, + {2012, 0, 1, 1, date(2011, 12, 1), false, false}, + {2012, 1, 1, 1, date(2012, 1, 1), true, true}, + {2012, 12, 1, 1, date(2012, 12, 1), true, true}, + {2012, 13, 1, 1, date(2013, 1, 1), false, false}, + {2012, 24, 1, 1, date(2013, 12, 1), false, false}, + {2012, 25, 1, 1, date(2014, 1, 1), false, false}, + + {2011, 2, 1, 1, date(2011, 2, 1), true, true}, + {2011, 2, 4, 7, date(2011, 2, 28), true, true}, + {2011, 2, 5, 1, date(2011, 3, 1), true, false}, + }; + } + + @Test(dataProvider = "resolve_ymaa") + public void test_resolve_ymaa_lenient(int y, int m, int w, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w); + fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d); + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } + + @Test(dataProvider = "resolve_ymaa") + public void test_resolve_ymaa_smart(int y, int m, int w, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w); + fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d); + if (smart) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + @Test(dataProvider = "resolve_ymaa") + public void test_resolve_ymaa_strict(int y, int m, int w, int d, LocalDate expected, boolean smart, boolean strict) { + Map fieldValues = new HashMap<>(); + fieldValues.put(ChronoField.YEAR, (long) y); + fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); + fieldValues.put(ChronoField.ALIGNED_WEEK_OF_MONTH, (long) w); + fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d); + if (strict) { + LocalDate date = IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + assertEquals(date, expected); + assertEquals(fieldValues.size(), 0); + } else { + try { + IsoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); + fail("Should have failed"); + } catch (DateTimeException ex) { + // expected + } + } + } + + //----------------------------------------------------------------------- + private static LocalDate date(int y, int m, int d) { + return LocalDate.of(y, m, d); + } + +} diff --git a/jdk/test/java/time/tck/java/time/chrono/TCKIsoEra.java b/jdk/test/java/time/tck/java/time/chrono/TCKIsoEra.java new file mode 100644 index 00000000000..e42cbc612db --- /dev/null +++ b/jdk/test/java/time/tck/java/time/chrono/TCKIsoEra.java @@ -0,0 +1,116 @@ +/* + * 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. 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static java.time.temporal.ChronoField.ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.chrono.Era; +import java.time.chrono.IsoChronology; +import java.time.chrono.IsoEra; +import java.time.temporal.ValueRange; +import java.util.List; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKIsoEra { + + @DataProvider(name = "IsoEras") + Object[][] data_of_eras() { + return new Object[][] { + {IsoEra.BCE, "BCE", 0}, + {IsoEra.CE, "CE", 1}, + }; + } + + @Test(dataProvider="IsoEras") + public void test_valueOf(IsoEra era , String eraName, int eraValue) { + assertEquals(era.getValue(), eraValue); + assertEquals(IsoEra.of(eraValue), era); + assertEquals(IsoEra.valueOf(eraName), era); + } + + //----------------------------------------------------------------------- + // values() + //----------------------------------------------------------------------- + @Test + public void test_values() { + List eraList = IsoChronology.INSTANCE.eras(); + IsoEra[] eras = IsoEra.values(); + assertEquals(eraList.size(), eras.length); + for (IsoEra era : eras) { + assertTrue(eraList.contains(era)); + } + } + + //----------------------------------------------------------------------- + // range() + //----------------------------------------------------------------------- + @Test + public void test_range() { + for (IsoEra era : IsoEra.values()) { + assertEquals(era.range(ERA), ValueRange.of(0, 1)); + } + } + +} diff --git a/jdk/test/java/time/tck/java/time/chrono/TestJapaneseChronology.java b/jdk/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java similarity index 60% rename from jdk/test/java/time/tck/java/time/chrono/TestJapaneseChronology.java rename to jdk/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java index b3027dfb6f6..cd5e859d56a 100644 --- a/jdk/test/java/time/tck/java/time/chrono/TestJapaneseChronology.java +++ b/jdk/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java @@ -56,24 +56,34 @@ */ package tck.java.time.chrono; +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.ERA; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.YEAR_OF_ERA; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; -import java.util.List; - import java.time.DateTimeException; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.Month; +import java.time.Period; import java.time.Year; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.JapaneseDate; +import java.time.chrono.ChronoLocalDate; import java.time.chrono.Chronology; import java.time.chrono.Era; import java.time.chrono.IsoChronology; -import java.time.temporal.Adjusters; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.JapaneseDate; +import java.time.chrono.JapaneseEra; +import java.time.chrono.MinguoChronology; +import java.time.chrono.MinguoDate; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjuster; +import java.util.List; import java.util.Locale; import org.testng.Assert; @@ -84,11 +94,11 @@ import org.testng.annotations.Test; * Test. */ @Test -public class TestJapaneseChronology { - private static int YDIFF_HEISEI = 1988; - private static int YDIFF_MEIJI = 1867; - private static int YDIFF_SHOWA = 1925; - private static int YDIFF_TAISHO = 1911; +public class TCKJapaneseChronology { + private static final int YDIFF_HEISEI = 1988; + private static final int YDIFF_MEIJI = 1867; + private static final int YDIFF_SHOWA = 1925; + private static final int YDIFF_TAISHO = 1911; //----------------------------------------------------------------------- // Chronology.of(String) @@ -162,11 +172,11 @@ public class TestJapaneseChronology { {JapaneseChronology.INSTANCE.date(1728, 10, 28), LocalDate.of(1728, 10, 28)}, {JapaneseChronology.INSTANCE.date(1728, 10, 29), LocalDate.of(1728, 10, 29)}, - {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_HEISEI, 1996 - YDIFF_HEISEI, 2, 29), LocalDate.of(1996, 2, 29)}, - {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_HEISEI, 2000 - YDIFF_HEISEI, 2, 29), LocalDate.of(2000, 2, 29)}, - {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_MEIJI, 1868 - YDIFF_MEIJI, 2, 29), LocalDate.of(1868, 2, 29)}, - {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_SHOWA, 1928 - YDIFF_SHOWA, 2, 29), LocalDate.of(1928, 2, 29)}, - {JapaneseChronology.INSTANCE.date(JapaneseChronology.ERA_TAISHO, 1912 - YDIFF_TAISHO, 2, 29), LocalDate.of(1912, 2, 29)}, + {JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 1996 - YDIFF_HEISEI, 2, 29), LocalDate.of(1996, 2, 29)}, + {JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2000 - YDIFF_HEISEI, 2, 29), LocalDate.of(2000, 2, 29)}, + {JapaneseChronology.INSTANCE.date(JapaneseEra.MEIJI, 1868 - YDIFF_MEIJI, 2, 29), LocalDate.of(1868, 2, 29)}, + {JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 12, 25), LocalDate.of(1928, 12, 25)}, + {JapaneseChronology.INSTANCE.date(JapaneseEra.TAISHO, 1912 - YDIFF_TAISHO, 7, 30), LocalDate.of(1912, 7, 30)}, {JapaneseChronology.INSTANCE.dateYearDay(1996, 60), LocalDate.of(1996, 2, 29)}, {JapaneseChronology.INSTANCE.dateYearDay(1868, 60), LocalDate.of(1868, 2, 29)}, @@ -175,12 +185,12 @@ public class TestJapaneseChronology { }; } - @Test(dataProvider="samples", groups={"tck"}) + @Test(dataProvider="samples") public void test_toLocalDate(JapaneseDate jdate, LocalDate iso) { assertEquals(LocalDate.from(jdate), iso); } - @Test(dataProvider="samples", groups={"tck"}) + @Test(dataProvider="samples") public void test_fromCalendrical(JapaneseDate jdate, LocalDate iso) { assertEquals(JapaneseChronology.INSTANCE.date(iso), jdate); } @@ -209,7 +219,7 @@ public class TestJapaneseChronology { }; } - @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) public void test_badDates(int year, int month, int dom) { JapaneseChronology.INSTANCE.date(year, month, dom); } @@ -220,30 +230,23 @@ public class TestJapaneseChronology { @DataProvider(name="prolepticYear") Object[][] data_prolepticYear() { return new Object[][] { - {2, JapaneseChronology.ERA_HEISEI, 1, 1 + YDIFF_HEISEI, false}, - {2, JapaneseChronology.ERA_HEISEI, 100, 100 + YDIFF_HEISEI, true}, - {2, JapaneseChronology.ERA_HEISEI, 0, YDIFF_HEISEI, true}, - {2, JapaneseChronology.ERA_HEISEI, -10, -10 + YDIFF_HEISEI, false}, + {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false}, + {2, JapaneseEra.HEISEI, 100, 100 + YDIFF_HEISEI, true}, + {2, JapaneseEra.HEISEI, 0, YDIFF_HEISEI, true}, + {2, JapaneseEra.HEISEI, -10, -10 + YDIFF_HEISEI, false}, - {-1, JapaneseChronology.ERA_MEIJI, 1, 1 + YDIFF_MEIJI, true}, - {-1, JapaneseChronology.ERA_MEIJI, 100, 100 + YDIFF_MEIJI, false}, - {-1, JapaneseChronology.ERA_MEIJI, 0, YDIFF_MEIJI, false}, - {-1, JapaneseChronology.ERA_MEIJI, -10, -10 + YDIFF_MEIJI, false}, + {-1, JapaneseEra.MEIJI, 1, 1 + YDIFF_MEIJI, true}, + {-1, JapaneseEra.MEIJI, 4, 4 + YDIFF_MEIJI, false}, - {1, JapaneseChronology.ERA_SHOWA, 1, 1 + YDIFF_SHOWA, false}, - {1, JapaneseChronology.ERA_SHOWA, 100, 100 + YDIFF_SHOWA, false}, - {1, JapaneseChronology.ERA_SHOWA, 0, YDIFF_SHOWA, false}, - {1, JapaneseChronology.ERA_SHOWA, -5, -5 + YDIFF_SHOWA, true}, - - {0, JapaneseChronology.ERA_TAISHO, 1, 1 + YDIFF_TAISHO, true}, - {0, JapaneseChronology.ERA_TAISHO, 100, 100 + YDIFF_TAISHO, false}, - {0, JapaneseChronology.ERA_TAISHO, 0, YDIFF_TAISHO, false}, - {0, JapaneseChronology.ERA_TAISHO, -10, -10 + YDIFF_TAISHO, false}, + {1, JapaneseEra.SHOWA, 1, 1 + YDIFF_SHOWA, false}, + {1, JapaneseEra.SHOWA, 7, 7 + YDIFF_SHOWA, true}, + {0, JapaneseEra.TAISHO, 1, 1 + YDIFF_TAISHO, true}, + {0, JapaneseEra.TAISHO, 4, 4 + YDIFF_TAISHO, false}, }; } - @Test(dataProvider="prolepticYear", groups={"tck"}) + @Test(dataProvider="prolepticYear") public void test_prolepticYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) { Era eraObj = JapaneseChronology.INSTANCE.eraOf(eraValue) ; assertTrue(JapaneseChronology.INSTANCE.eras().contains(eraObj)); @@ -253,34 +256,130 @@ public class TestJapaneseChronology { assertEquals(JapaneseChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear).isLeap()) ; } + @DataProvider(name="prolepticYearError") + Object[][] data_prolepticYearError() { + return new Object[][] { + {JapaneseEra.MEIJI, 100}, + {JapaneseEra.MEIJI, 0}, + {JapaneseEra.MEIJI, -10}, + + {JapaneseEra.SHOWA, 100}, + {JapaneseEra.SHOWA, 0}, + {JapaneseEra.SHOWA, -10}, + + {JapaneseEra.TAISHO, 100}, + {JapaneseEra.TAISHO, 0}, + {JapaneseEra.TAISHO, -10}, + }; + } + + @Test(dataProvider="prolepticYearError", expectedExceptions=DateTimeException.class) + public void test_prolepticYearError(Era era, int yearOfEra) { + JapaneseChronology.INSTANCE.prolepticYear(era, yearOfEra); + } + + //----------------------------------------------------------------------- + // Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...) + //----------------------------------------------------------------------- + @Test + public void test_InvalidEras() { + // Verify that the eras from every other Chronology are invalid + for (Chronology chrono : Chronology.getAvailableChronologies()) { + if (chrono instanceof JapaneseChronology) { + continue; + } + List eras = chrono.eras(); + for (Era era : eras) { + try { + ChronoLocalDate date = JapaneseChronology.INSTANCE.date(era, 1, 1, 1); + fail("JapaneseChronology.date did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + try { + @SuppressWarnings("unused") + JapaneseDate jdate = JapaneseDate.of(era, 1, 1, 1); + fail("JapaneseDate.of did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + try { + @SuppressWarnings("unused") + int year = JapaneseChronology.INSTANCE.prolepticYear(era, 1); + fail("JapaneseChronology.prolepticYear did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + } + } + } + + //----------------------------------------------------------------------- + // get(TemporalField) + //----------------------------------------------------------------------- + @Test + public void test_getLong() { + JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 63, 6, 30); + assertEquals(base.getLong(ERA), JapaneseEra.SHOWA.getValue()); + assertEquals(base.getLong(YEAR), 1988L); + assertEquals(base.getLong(YEAR_OF_ERA), 63L); + assertEquals(base.getLong(MONTH_OF_YEAR), 6L); + assertEquals(base.getLong(DAY_OF_MONTH), 30L); + } + + //----------------------------------------------------------------------- + // with(TemporalField, long) + //----------------------------------------------------------------------- + @Test + public void test_with_TemporalField_long() { + JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 63, 6, 30); + JapaneseDate test = base.with(YEAR, 1987); + assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 62, 6, 30)); + + test = test.with(YEAR_OF_ERA, 2); + assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 2, 6, 30)); + + test = test.with(ERA, JapaneseEra.HEISEI.getValue()); + assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 6, 30)); + + test = test.with(MONTH_OF_YEAR, 3); + assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 30)); + + test = test.with(DAY_OF_MONTH, 4); + assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 4)); + } + //----------------------------------------------------------------------- // with(WithAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjust1() { JapaneseDate base = JapaneseChronology.INSTANCE.date(1728, 10, 29); - JapaneseDate test = base.with(Adjusters.lastDayOfMonth()); + JapaneseDate test = base.with(TemporalAdjuster.lastDayOfMonth()); assertEquals(test, JapaneseChronology.INSTANCE.date(1728, 10, 31)); } - @Test(groups={"tck"}) + @Test public void test_adjust2() { JapaneseDate base = JapaneseChronology.INSTANCE.date(1728, 12, 2); - JapaneseDate test = base.with(Adjusters.lastDayOfMonth()); + JapaneseDate test = base.with(TemporalAdjuster.lastDayOfMonth()); assertEquals(test, JapaneseChronology.INSTANCE.date(1728, 12, 31)); } //----------------------------------------------------------------------- // JapaneseDate.with(Local*) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjust_toLocalDate() { JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1726, 1, 4); JapaneseDate test = jdate.with(LocalDate.of(2012, 7, 6)); assertEquals(test, JapaneseChronology.INSTANCE.date(2012, 7, 6)); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_adjust_toMonth() { JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1726, 1, 4); jdate.with(Month.APRIL); @@ -289,14 +388,14 @@ public class TestJapaneseChronology { //----------------------------------------------------------------------- // LocalDate.with(JapaneseDate) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_LocalDate_adjustToJapaneseDate() { JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1728, 10, 29); LocalDate test = LocalDate.MIN.with(jdate); assertEquals(test, LocalDate.of(1728, 10, 29)); } - @Test(groups={"tck"}) + @Test public void test_LocalDateTime_adjustToJapaneseDate() { JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1728, 10, 29); LocalDateTime test = LocalDateTime.MIN.with(jdate); @@ -309,15 +408,15 @@ public class TestJapaneseChronology { @DataProvider(name="japaneseEras") Object[][] data_japanseseEras() { return new Object[][] { - { JapaneseChronology.ERA_SEIREKI, -999, "Seireki"}, - { JapaneseChronology.ERA_MEIJI, -1, "Meiji"}, - { JapaneseChronology.ERA_TAISHO, 0, "Taisho"}, - { JapaneseChronology.ERA_SHOWA, 1, "Showa"}, - { JapaneseChronology.ERA_HEISEI, 2, "Heisei"}, + { JapaneseEra.SEIREKI, -999, "Seireki"}, + { JapaneseEra.MEIJI, -1, "Meiji"}, + { JapaneseEra.TAISHO, 0, "Taisho"}, + { JapaneseEra.SHOWA, 1, "Showa"}, + { JapaneseEra.HEISEI, 2, "Heisei"}, }; } - @Test(groups={"tck"}, dataProvider="japaneseEras") + @Test(dataProvider="japaneseEras") public void test_Japanese_Eras(Era era, int eraValue, String name) { assertEquals(era.getValue(), eraValue, "EraValue"); assertEquals(era.toString(), name, "Era Name"); @@ -326,7 +425,7 @@ public class TestJapaneseChronology { assertTrue(eras.contains(era), "Era is not present in JapaneseChronology.INSTANCE.eras()"); } - @Test(groups="tck") + @Test public void test_Japanese_badEras() { int badEras[] = {-1000, -998, -997, -2, 3, 4, 1000}; for (int badEra : badEras) { @@ -339,6 +438,70 @@ public class TestJapaneseChronology { } } + @Test(dataProvider="japaneseEras") + public void test_JapaneseEra_singletons(Era expectedEra, int eraValue, String name) { + JapaneseEra actualEra = JapaneseEra.valueOf(name); + assertEquals(actualEra, expectedEra, "JapaneseEra.valueOf(name)"); + + actualEra = JapaneseEra.of(eraValue); + assertEquals(actualEra, expectedEra, "JapaneseEra.of(value)"); + + String string = actualEra.toString(); + assertEquals(string, name, "JapaneseEra.toString()"); + } + + @Test + public void test_JapaneseEra_values() { + JapaneseEra[] actualEras = JapaneseEra.values(); + Object[][] erasInfo = data_japanseseEras(); + assertEquals(actualEras.length, erasInfo.length, "Wrong number of Eras"); + + for (int i = 0; i < erasInfo.length; i++) { + Object[] eraInfo = erasInfo[i]; + assertEquals(actualEras[i], eraInfo[0], "Singleton mismatch"); + } + } + + @Test + public void test_JapaneseChronology_eras() { + List actualEras = JapaneseChronology.INSTANCE.eras(); + Object[][] erasInfo = data_japanseseEras(); + assertEquals(actualEras.size(), erasInfo.length, "Wrong number of Eras"); + + for (int i = 0; i < erasInfo.length; i++) { + Object[] eraInfo = erasInfo[i]; + assertEquals(actualEras.get(i), eraInfo[0], "Singleton mismatch"); + } + } + + //----------------------------------------------------------------------- + // PeriodUntil() + //----------------------------------------------------------------------- + @Test + public void test_periodUntilDate() { + JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1); + JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2); + Period period = mdate1.periodUntil(mdate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + @Test + public void test_periodUntilUnit() { + JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1); + JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2); + long months = mdate1.periodUntil(mdate2, ChronoUnit.MONTHS); + assertEquals(months, 13); + } + + @Test + public void test_periodUntilDiffChrono() { + JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1); + JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2); + MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2); + Period period = mdate1.periodUntil(ldate2); + assertEquals(period, Period.of(1, 1, 1)); + } + //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- @@ -361,7 +524,7 @@ public class TestJapaneseChronology { }; } - @Test(dataProvider="toString", groups={"tck"}) + @Test(dataProvider="toString") public void test_toString(JapaneseDate jdate, String expected) { assertEquals(jdate.toString(), expected); } @@ -369,12 +532,12 @@ public class TestJapaneseChronology { //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void test_equals_true() { assertTrue(JapaneseChronology.INSTANCE.equals(JapaneseChronology.INSTANCE)); } - @Test(groups="tck") + @Test public void test_equals_false() { assertFalse(JapaneseChronology.INSTANCE.equals(IsoChronology.INSTANCE)); } diff --git a/jdk/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java b/jdk/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java new file mode 100644 index 00000000000..1aa1df360f6 --- /dev/null +++ b/jdk/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java @@ -0,0 +1,122 @@ +/* + * 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. 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static java.time.temporal.ChronoField.ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.chrono.Era; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.JapaneseEra; +import java.util.List; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKJapaneseEra { + + @DataProvider(name = "JapaneseEras") + Object[][] data_of_eras() { + return new Object[][] { + {JapaneseEra.HEISEI, "Heisei", 2}, + {JapaneseEra.SHOWA, "Showa", 1}, + {JapaneseEra.TAISHO, "Taisho", 0}, + {JapaneseEra.MEIJI, "Meiji", -1}, + {JapaneseEra.SEIREKI, "Seireki", -999}, + }; + } + + @Test(dataProvider="JapaneseEras") + public void test_valueOf(JapaneseEra era , String eraName, int eraValue) { + assertEquals(era.getValue(), eraValue); + assertEquals(JapaneseEra.of(eraValue), era); + assertEquals(JapaneseEra.valueOf(eraName), era); + } + + //----------------------------------------------------------------------- + // values() + //----------------------------------------------------------------------- + @Test + public void test_values() { + List eraList = JapaneseChronology.INSTANCE.eras(); + JapaneseEra[] eras = JapaneseEra.values(); + assertEquals(eraList.size(), eras.length); + for (JapaneseEra era : eras) { + assertTrue(eraList.contains(era)); + } + } + + //----------------------------------------------------------------------- + // range() + //----------------------------------------------------------------------- + @Test + public void test_range() { + // eras may be added after release + for (JapaneseEra era : JapaneseEra.values()) { + assertEquals(era.range(ERA).getMinimum(), -999); + assertEquals(era.range(ERA).getLargestMinimum(), -999); + assertEquals(era.range(ERA).getSmallestMaximum(), era.range(ERA).getMaximum()); + assertEquals(era.range(ERA).getMaximum() >= 2, true); + } + } + +} diff --git a/jdk/test/java/time/tck/java/time/chrono/TCKMinguoChronology.java b/jdk/test/java/time/tck/java/time/chrono/TCKMinguoChronology.java new file mode 100644 index 00000000000..cad29d76f29 --- /dev/null +++ b/jdk/test/java/time/tck/java/time/chrono/TCKMinguoChronology.java @@ -0,0 +1,523 @@ +/* + * 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. 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + +import java.time.Clock; +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.Month; +import java.time.OffsetDateTime; +import java.time.Period; +import java.time.Year; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.ChronoLocalDateTime; +import java.time.chrono.ChronoZonedDateTime; +import java.time.chrono.Chronology; +import java.time.chrono.Era; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseDate; +import java.time.chrono.MinguoChronology; +import java.time.chrono.MinguoDate; +import java.time.chrono.MinguoEra; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistDate; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAdjuster; +import java.util.List; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKMinguoChronology { + + private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); + private static final ZoneId ZONE_PARIS = ZoneId.of("Europe/Paris"); + private static final int YDIFF = 1911; + //----------------------------------------------------------------------- + // Chronology.ofName("Minguo") Lookup by name + //----------------------------------------------------------------------- + @Test + public void test_chrono_byName() { + Chronology c = MinguoChronology.INSTANCE; + Chronology test = Chronology.of("Minguo"); + Assert.assertNotNull(test, "The Minguo calendar could not be found byName"); + Assert.assertEquals(test.getId(), "Minguo", "ID mismatch"); + Assert.assertEquals(test.getCalendarType(), "roc", "Type mismatch"); + Assert.assertEquals(test, c); + } + + //----------------------------------------------------------------------- + // creation, toLocalDate() + //----------------------------------------------------------------------- + @DataProvider(name="samples") + Object[][] data_samples() { + return new Object[][] { + {MinguoChronology.INSTANCE.date(1, 1, 1), LocalDate.of(1 + YDIFF, 1, 1)}, + {MinguoChronology.INSTANCE.date(1, 1, 2), LocalDate.of(1 + YDIFF, 1, 2)}, + {MinguoChronology.INSTANCE.date(1, 1, 3), LocalDate.of(1 + YDIFF, 1, 3)}, + + {MinguoChronology.INSTANCE.date(2, 1, 1), LocalDate.of(2 + YDIFF, 1, 1)}, + {MinguoChronology.INSTANCE.date(3, 1, 1), LocalDate.of(3 + YDIFF, 1, 1)}, + {MinguoChronology.INSTANCE.date(3, 12, 6), LocalDate.of(3 + YDIFF, 12, 6)}, + {MinguoChronology.INSTANCE.date(4, 1, 1), LocalDate.of(4 + YDIFF, 1, 1)}, + {MinguoChronology.INSTANCE.date(4, 7, 3), LocalDate.of(4 + YDIFF, 7, 3)}, + {MinguoChronology.INSTANCE.date(4, 7, 4), LocalDate.of(4 + YDIFF, 7, 4)}, + {MinguoChronology.INSTANCE.date(5, 1, 1), LocalDate.of(5 + YDIFF, 1, 1)}, + {MinguoChronology.INSTANCE.date(100, 3, 3), LocalDate.of(100 + YDIFF, 3, 3)}, + {MinguoChronology.INSTANCE.date(101, 10, 28), LocalDate.of(101 + YDIFF, 10, 28)}, + {MinguoChronology.INSTANCE.date(101, 10, 29), LocalDate.of(101 + YDIFF, 10, 29)}, + + {MinguoChronology.INSTANCE.dateYearDay(1916 - YDIFF, 60), LocalDate.of(1916, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(1908 - YDIFF, 60), LocalDate.of(1908, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(2000 - YDIFF, 60), LocalDate.of(2000, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(2400 - YDIFF, 60), LocalDate.of(2400, 2, 29)}, + + {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 1916 - YDIFF, 60), LocalDate.of(1916, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.BEFORE_ROC, 4, 60), LocalDate.of(1908, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 2000 - YDIFF, 60), LocalDate.of(2000, 2, 29)}, + {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 2400 - YDIFF, 60), LocalDate.of(2400, 2, 29)}, + + {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1916 - YDIFF, 2, 29 ), LocalDate.of(1916, 2, 29)}, + {MinguoChronology.INSTANCE.date(MinguoEra.BEFORE_ROC, 4, 2, 29), LocalDate.of(1908, 2, 29)}, + {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2000 - YDIFF, 2, 29), LocalDate.of(2000, 2, 29)}, + {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2400 - YDIFF, 2, 29), LocalDate.of(2400, 2, 29)}, + }; + } + + @Test(dataProvider="samples") + public void test_toLocalDate(MinguoDate minguo, LocalDate iso) { + assertEquals(LocalDate.from(minguo), iso); + } + + @Test(dataProvider="samples") + public void test_fromCalendrical(MinguoDate minguo, LocalDate iso) { + assertEquals(MinguoChronology.INSTANCE.date(iso), minguo); + } + + @Test + public void test_dateNow(){ + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now()) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(ZoneId.systemDefault())) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone())) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone().getZone())) ; + + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(ZoneId.systemDefault())) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone())) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone())) ; + + ZoneId zoneId = ZoneId.of("Europe/Paris"); + assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId))) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone())) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId))) ; + assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId).getZone())) ; + + assertEquals(MinguoChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), MinguoChronology.INSTANCE.dateNow(Clock.systemUTC())) ; + } + + @SuppressWarnings("unused") + @Test(dataProvider="samples") + public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) { + MinguoDate hd = minguoDate; + ChronoLocalDateTime hdt = hd.atTime(LocalTime.NOON); + ZoneOffset zo = ZoneOffset.ofHours(1); + ChronoZonedDateTime hzdt = hdt.atZone(zo); + hdt = hdt.plus(1, ChronoUnit.YEARS); + hdt = hdt.plus(1, ChronoUnit.MONTHS); + hdt = hdt.plus(1, ChronoUnit.DAYS); + hdt = hdt.plus(1, ChronoUnit.HOURS); + hdt = hdt.plus(1, ChronoUnit.MINUTES); + hdt = hdt.plus(1, ChronoUnit.SECONDS); + hdt = hdt.plus(1, ChronoUnit.NANOS); + ChronoLocalDateTime a2 = hzdt.toLocalDateTime(); + MinguoDate a3 = a2.toLocalDate(); + MinguoDate a5 = hzdt.toLocalDate(); + //System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5); + } + + @Test() + public void test_MinguoChrono() { + MinguoDate h1 = MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1, 2, 3); + MinguoDate h2 = h1; + ChronoLocalDateTime h3 = h2.atTime(LocalTime.NOON); + @SuppressWarnings("unused") + ChronoZonedDateTime h4 = h3.atZone(ZoneOffset.UTC); + } + + @DataProvider(name="badDates") + Object[][] data_badDates() { + return new Object[][] { + {1912, 0, 0}, + + {1912, -1, 1}, + {1912, 0, 1}, + {1912, 14, 1}, + {1912, 15, 1}, + + {1912, 1, -1}, + {1912, 1, 0}, + {1912, 1, 32}, + {1912, 2, 29}, + {1912, 2, 30}, + + {1912, 12, -1}, + {1912, 12, 0}, + {1912, 12, 32}, + + {1907 - YDIFF, 2, 29}, + {100 - YDIFF, 2, 29}, + {2100 - YDIFF, 2, 29}, + {2101 - YDIFF, 2, 29}, + }; + } + + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) + public void test_badDates(int year, int month, int dom) { + MinguoChronology.INSTANCE.date(year, month, dom); + } + + //----------------------------------------------------------------------- + // prolepticYear() and is LeapYear() + //----------------------------------------------------------------------- + @DataProvider(name="prolepticYear") + Object[][] data_prolepticYear() { + return new Object[][] { + {1, MinguoEra.ROC, 1912 - YDIFF, 1912 - YDIFF, true}, + {1, MinguoEra.ROC, 1916 - YDIFF, 1916 - YDIFF, true}, + {1, MinguoEra.ROC, 1914 - YDIFF, 1914 - YDIFF, false}, + {1, MinguoEra.ROC, 2000 - YDIFF, 2000 - YDIFF, true}, + {1, MinguoEra.ROC, 2100 - YDIFF, 2100 - YDIFF, false}, + {1, MinguoEra.ROC, 0, 0, false}, + {1, MinguoEra.ROC, 1908 - YDIFF, 1908 - YDIFF, true}, + {1, MinguoEra.ROC, 1900 - YDIFF, 1900 - YDIFF, false}, + {1, MinguoEra.ROC, 1600 - YDIFF, 1600 - YDIFF, true}, + + {0, MinguoEra.BEFORE_ROC, YDIFF - 1911, 1912 - YDIFF, true}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1915, 1916 - YDIFF, true}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1913, 1914 - YDIFF, false}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1999, 2000 - YDIFF, true}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 2099, 2100 - YDIFF, false}, + {0, MinguoEra.BEFORE_ROC, 1, 0, false}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1907, 1908 - YDIFF, true}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1899, 1900 - YDIFF, false}, + {0, MinguoEra.BEFORE_ROC, YDIFF - 1599, 1600 - YDIFF, true}, + + }; + } + + @Test(dataProvider="prolepticYear") + public void test_prolepticYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) { + Era eraObj = MinguoChronology.INSTANCE.eraOf(eraValue) ; + assertTrue(MinguoChronology.INSTANCE.eras().contains(eraObj)); + assertEquals(eraObj, era); + assertEquals(MinguoChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear); + assertEquals(MinguoChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear) ; + assertEquals(MinguoChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear + YDIFF).isLeap()) ; + } + + //----------------------------------------------------------------------- + // Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...) + //----------------------------------------------------------------------- + @Test + public void test_InvalidEras() { + // Verify that the eras from every other Chronology are invalid + for (Chronology chrono : Chronology.getAvailableChronologies()) { + if (chrono instanceof MinguoChronology) { + continue; + } + List eras = chrono.eras(); + for (Era era : eras) { + try { + ChronoLocalDate date = MinguoChronology.INSTANCE.date(era, 1, 1, 1); + fail("MinguoChronology.date did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + /* Test for missing MinguoDate.of(Era, y, m, d) method. + try { + @SuppressWarnings("unused") + MinguoDate jdate = MinguoDate.of(era, 1, 1, 1); + fail("MinguoDate.of did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + */ + + try { + @SuppressWarnings("unused") + int year = MinguoChronology.INSTANCE.prolepticYear(era, 1); + fail("MinguoChronology.prolepticYear did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + } + } + } + + //----------------------------------------------------------------------- + // with(DateTimeAdjuster) + //----------------------------------------------------------------------- + @Test + public void test_adjust1() { + MinguoDate base = MinguoChronology.INSTANCE.date(2012, 10, 29); + MinguoDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, MinguoChronology.INSTANCE.date(2012, 10, 31)); + } + + @Test + public void test_adjust2() { + MinguoDate base = MinguoChronology.INSTANCE.date(1728, 12, 2); + MinguoDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + assertEquals(test, MinguoChronology.INSTANCE.date(1728, 12, 31)); + } + + //----------------------------------------------------------------------- + // MinguoDate.with(Local*) + //----------------------------------------------------------------------- + @Test + public void test_adjust_toLocalDate() { + MinguoDate minguo = MinguoChronology.INSTANCE.date(99, 1, 4); + MinguoDate test = minguo.with(LocalDate.of(2012, 7, 6)); + assertEquals(test, MinguoChronology.INSTANCE.date(101, 7, 6)); + } + + @Test(expectedExceptions=DateTimeException.class) + public void test_adjust_toMonth() { + MinguoDate minguo = MinguoChronology.INSTANCE.date(1726, 1, 4); + minguo.with(Month.APRIL); + } + + //----------------------------------------------------------------------- + // LocalDate.with(MinguoDate) + //----------------------------------------------------------------------- + @Test + public void test_LocalDate_adjustToMinguoDate() { + MinguoDate minguo = MinguoChronology.INSTANCE.date(101, 10, 29); + LocalDate test = LocalDate.MIN.with(minguo); + assertEquals(test, LocalDate.of(2012, 10, 29)); + } + + @Test + public void test_LocalDateTime_adjustToMinguoDate() { + MinguoDate minguo = MinguoChronology.INSTANCE.date(101, 10, 29); + LocalDateTime test = LocalDateTime.MIN.with(minguo); + assertEquals(test, LocalDateTime.of(2012, 10, 29, 0, 0)); + } + + //----------------------------------------------------------------------- + // localDateTime() + //----------------------------------------------------------------------- + @DataProvider(name="localDateTime") + Object[][] data_localDateTime() { + return new Object[][] { + {LocalDateTime.of(2012, 2, 29, 2, 7), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7), null}, + {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, + {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, + + {JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class}, + {ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class}, + {LocalDate.of(2012, 2, 29), null, null, DateTimeException.class}, + {LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class}, + }; + } + + @Test(dataProvider="localDateTime") + public void test_localDateTime(TemporalAccessor accessor, MinguoDate expectedDate, LocalTime expectedTime, Class expectedEx) { + if (expectedEx == null) { + ChronoLocalDateTime result = MinguoChronology.INSTANCE.localDateTime(accessor); + assertEquals(result.toLocalDate(), expectedDate); + assertEquals(MinguoDate.from(accessor), expectedDate); + assertEquals(result.toLocalTime(), expectedTime); + } else { + try { + ChronoLocalDateTime result = MinguoChronology.INSTANCE.localDateTime(accessor); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- + // zonedDateTime(TemporalAccessor) + //----------------------------------------------------------------------- + @DataProvider(name="zonedDateTime") + Object[][] data_zonedDateTime() { + return new Object[][] { + {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, + {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, + + {LocalDateTime.of(2012, 2, 29, 2, 7), null, null, DateTimeException.class}, + {JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class}, + {ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class}, + {LocalDate.of(2012, 2, 29), null, null, DateTimeException.class}, + {LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class}, + }; + } + + @Test(dataProvider="zonedDateTime") + public void test_zonedDateTime(TemporalAccessor accessor, MinguoDate expectedDate, LocalTime expectedTime, Class expectedEx) { + if (expectedEx == null) { + ChronoZonedDateTime result = MinguoChronology.INSTANCE.zonedDateTime(accessor); + assertEquals(result.toLocalDate(), expectedDate); + assertEquals(MinguoDate.from(accessor), expectedDate); + assertEquals(result.toLocalTime(), expectedTime); + + } else { + try { + ChronoZonedDateTime result = MinguoChronology.INSTANCE.zonedDateTime(accessor); + fail(); + } catch (Exception ex) { + assertTrue(expectedEx.isInstance(ex)); + } + } + } + + //----------------------------------------------------------------------- + // zonedDateTime(Instant, ZoneId ) + //----------------------------------------------------------------------- + @Test + public void test_Instant_zonedDateTime() { + OffsetDateTime offsetDateTime = OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO); + ZonedDateTime zonedDateTime = ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS); + + ChronoZonedDateTime result = MinguoChronology.INSTANCE.zonedDateTime(offsetDateTime.toInstant(), offsetDateTime.getOffset()); + assertEquals(result.toLocalDate(), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29)); + assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1)); + + result = MinguoChronology.INSTANCE.zonedDateTime(zonedDateTime.toInstant(), zonedDateTime.getOffset()); + assertEquals(result.toLocalDate(), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29)); + assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1)); + } + + //----------------------------------------------------------------------- + // PeriodUntil() + //----------------------------------------------------------------------- + @Test + public void test_periodUntilDate() { + MinguoDate mdate1 = MinguoDate.of(1970, 1, 1); + MinguoDate mdate2 = MinguoDate.of(1971, 2, 2); + Period period = mdate1.periodUntil(mdate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + @Test + public void test_periodUntilUnit() { + MinguoDate mdate1 = MinguoDate.of(1970, 1, 1); + MinguoDate mdate2 = MinguoDate.of(1971, 2, 2); + long months = mdate1.periodUntil(mdate2, ChronoUnit.MONTHS); + assertEquals(months, 13); + } + + @Test + public void test_periodUntilDiffChrono() { + MinguoDate mdate1 = MinguoDate.of(1970, 1, 1); + MinguoDate mdate2 = MinguoDate.of(1971, 2, 2); + ThaiBuddhistDate ldate2 = ThaiBuddhistChronology.INSTANCE.date(mdate2); + Period period = mdate1.periodUntil(ldate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + //----------------------------------------------------------------------- + // toString() + //----------------------------------------------------------------------- + @DataProvider(name="toString") + Object[][] data_toString() { + return new Object[][] { + {MinguoChronology.INSTANCE.date(1, 1, 1), "Minguo ROC 1-01-01"}, + {MinguoChronology.INSTANCE.date(1728, 10, 28), "Minguo ROC 1728-10-28"}, + {MinguoChronology.INSTANCE.date(1728, 10, 29), "Minguo ROC 1728-10-29"}, + {MinguoChronology.INSTANCE.date(1727, 12, 5), "Minguo ROC 1727-12-05"}, + {MinguoChronology.INSTANCE.date(1727, 12, 6), "Minguo ROC 1727-12-06"}, + }; + } + + @Test(dataProvider="toString") + public void test_toString(MinguoDate minguo, String expected) { + assertEquals(minguo.toString(), expected); + } + + //----------------------------------------------------------------------- + // equals() + //----------------------------------------------------------------------- + @Test + public void test_equals_true() { + assertTrue(MinguoChronology.INSTANCE.equals(MinguoChronology.INSTANCE)); + } + + @Test + public void test_equals_false() { + assertFalse(MinguoChronology.INSTANCE.equals(IsoChronology.INSTANCE)); + } + +} diff --git a/jdk/test/java/time/tck/java/time/chrono/TCKMinguoEra.java b/jdk/test/java/time/tck/java/time/chrono/TCKMinguoEra.java new file mode 100644 index 00000000000..19e05e80444 --- /dev/null +++ b/jdk/test/java/time/tck/java/time/chrono/TCKMinguoEra.java @@ -0,0 +1,121 @@ +/* + * 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. 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + + +import static java.time.temporal.ChronoField.ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.chrono.Era; +import java.time.chrono.MinguoChronology; +import java.time.chrono.MinguoEra; +import java.time.temporal.ValueRange; +import java.util.List; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKMinguoEra { + + @DataProvider(name = "MinguoEras") + Object[][] data_of_eras() { + return new Object[][] { + {MinguoEra.BEFORE_ROC, "BEFORE_ROC", 0}, + {MinguoEra.ROC, "ROC", 1}, + }; + } + + //----------------------------------------------------------------------- + // valueOf() + //----------------------------------------------------------------------- + @Test(dataProvider="MinguoEras") + public void test_valueOf(MinguoEra era , String eraName, int eraValue) { + assertEquals(era.getValue(), eraValue); + assertEquals(MinguoEra.of(eraValue), era); + assertEquals(MinguoEra.valueOf(eraName), era); + } + + + //----------------------------------------------------------------------- + // values() + //----------------------------------------------------------------------- + @Test + public void test_values() { + List eraList = MinguoChronology.INSTANCE.eras(); + MinguoEra[] eras = MinguoEra.values() ; + assertEquals(eraList.size(), eras.length); + for (MinguoEra era : eras) { + assertTrue(eraList.contains(era)); + } + } + + //----------------------------------------------------------------------- + // range() + //----------------------------------------------------------------------- + @Test + public void test_range() { + for (MinguoEra era : MinguoEra.values()) { + assertEquals(era.range(ERA), ValueRange.of(0, 1)); + } + } + +} diff --git a/jdk/test/java/time/tck/java/time/chrono/TCKTestServiceLoader.java b/jdk/test/java/time/tck/java/time/chrono/TCKTestServiceLoader.java index 0236656aad6..b67f01185aa 100644 --- a/jdk/test/java/time/tck/java/time/chrono/TCKTestServiceLoader.java +++ b/jdk/test/java/time/tck/java/time/chrono/TCKTestServiceLoader.java @@ -60,9 +60,13 @@ package tck.java.time.chrono; import static org.testng.Assert.assertEquals; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.time.LocalDate; -import java.time.chrono.Chronology; import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; import org.testng.annotations.Test; @@ -73,7 +77,7 @@ import org.testng.annotations.Test; @Test public class TCKTestServiceLoader { - @Test(groups={"tck"}) + @Test public void test_CopticServiceLoader() { Chronology chrono = Chronology.of("Coptic"); ChronoLocalDate copticDate = chrono.date(1729, 4, 27); @@ -81,4 +85,22 @@ public class TCKTestServiceLoader { assertEquals(ld, LocalDate.of(2013, 1, 5), "CopticDate does not match LocalDate"); } + + //----------------------------------------------------------------------- + // Test Serialization of Loaded Coptic Calendar + //----------------------------------------------------------------------- + @Test + public void test_ChronoSerialization() throws Exception { + Chronology chrono = Chronology.of("Coptic"); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(baos); + out.writeObject(chrono); + out.close(); + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + + ObjectInputStream in = new ObjectInputStream(bais); + @SuppressWarnings("unchecked") + Chronology ser = (Chronology) in.readObject(); + assertEquals(ser, chrono, "deserialized Chronology is wrong"); + } } diff --git a/jdk/test/java/time/tck/java/time/chrono/TestThaiBuddhistChronology.java b/jdk/test/java/time/tck/java/time/chrono/TCKThaiBuddhistChronology.java similarity index 75% rename from jdk/test/java/time/tck/java/time/chrono/TestThaiBuddhistChronology.java rename to jdk/test/java/time/tck/java/time/chrono/TCKThaiBuddhistChronology.java index 32eae1e073e..04d9dd982ba 100644 --- a/jdk/test/java/time/tck/java/time/chrono/TestThaiBuddhistChronology.java +++ b/jdk/test/java/time/tck/java/time/chrono/TCKThaiBuddhistChronology.java @@ -64,21 +64,28 @@ import static java.time.temporal.ChronoField.YEAR_OF_ERA; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; import java.time.DateTimeException; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.Month; +import java.time.Period; import java.time.Year; -import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ThaiBuddhistDate; -import java.time.chrono.Chronology; import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; import java.time.chrono.Era; import java.time.chrono.IsoChronology; -import java.time.temporal.Adjusters; +import java.time.chrono.MinguoChronology; +import java.time.chrono.MinguoDate; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistDate; +import java.time.chrono.ThaiBuddhistEra; import java.time.temporal.ChronoField; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjuster; import java.time.temporal.ValueRange; +import java.util.List; import java.util.Locale; import org.testng.Assert; @@ -89,7 +96,7 @@ import org.testng.annotations.Test; * Test. */ @Test -public class TestThaiBuddhistChronology { +public class TCKThaiBuddhistChronology { private static final int YDIFF = 543; @@ -173,12 +180,12 @@ public class TestThaiBuddhistChronology { }; } - @Test(dataProvider="samples", groups={"tck"}) + @Test(dataProvider="samples") public void test_toLocalDate(ThaiBuddhistDate jdate, LocalDate iso) { assertEquals(LocalDate.from(jdate), iso); } - @Test(dataProvider="samples", groups={"tck"}) + @Test(dataProvider="samples") public void test_fromCalendrical(ThaiBuddhistDate jdate, LocalDate iso) { assertEquals(ThaiBuddhistChronology.INSTANCE.date(iso), jdate); } @@ -207,7 +214,7 @@ public class TestThaiBuddhistChronology { }; } - @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) public void test_badDates(int year, int month, int dom) { ThaiBuddhistChronology.INSTANCE.date(year, month, dom); } @@ -218,32 +225,32 @@ public class TestThaiBuddhistChronology { @DataProvider(name="prolepticYear") Object[][] data_prolepticYear() { return new Object[][] { - {1, ThaiBuddhistChronology.ERA_BE, 4 + YDIFF, 4 + YDIFF, true}, - {1, ThaiBuddhistChronology.ERA_BE, 7 + YDIFF, 7 + YDIFF, false}, - {1, ThaiBuddhistChronology.ERA_BE, 8 + YDIFF, 8 + YDIFF, true}, - {1, ThaiBuddhistChronology.ERA_BE, 1000 + YDIFF, 1000 + YDIFF, false}, - {1, ThaiBuddhistChronology.ERA_BE, 2000 + YDIFF, 2000 + YDIFF, true}, - {1, ThaiBuddhistChronology.ERA_BE, 0, 0, false}, - {1, ThaiBuddhistChronology.ERA_BE, -4 + YDIFF, -4 + YDIFF, true}, - {1, ThaiBuddhistChronology.ERA_BE, -7 + YDIFF, -7 + YDIFF, false}, - {1, ThaiBuddhistChronology.ERA_BE, -100 + YDIFF, -100 + YDIFF, false}, - {1, ThaiBuddhistChronology.ERA_BE, -800 + YDIFF, -800 + YDIFF, true}, + {1, ThaiBuddhistEra.BE, 4 + YDIFF, 4 + YDIFF, true}, + {1, ThaiBuddhistEra.BE, 7 + YDIFF, 7 + YDIFF, false}, + {1, ThaiBuddhistEra.BE, 8 + YDIFF, 8 + YDIFF, true}, + {1, ThaiBuddhistEra.BE, 1000 + YDIFF, 1000 + YDIFF, false}, + {1, ThaiBuddhistEra.BE, 2000 + YDIFF, 2000 + YDIFF, true}, + {1, ThaiBuddhistEra.BE, 0, 0, false}, + {1, ThaiBuddhistEra.BE, -4 + YDIFF, -4 + YDIFF, true}, + {1, ThaiBuddhistEra.BE, -7 + YDIFF, -7 + YDIFF, false}, + {1, ThaiBuddhistEra.BE, -100 + YDIFF, -100 + YDIFF, false}, + {1, ThaiBuddhistEra.BE, -800 + YDIFF, -800 + YDIFF, true}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, -3 - YDIFF, 4 + YDIFF, true}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, -6 - YDIFF, 7 + YDIFF, false}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, -7 - YDIFF, 8 + YDIFF, true}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, -999 - YDIFF, 1000 + YDIFF, false}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, -1999 - YDIFF, 2000 + YDIFF, true}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, 1, 0, false}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, 5 - YDIFF, -4 + YDIFF, true}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, 8 - YDIFF, -7 + YDIFF, false}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, 101 - YDIFF, -100 + YDIFF, false}, - {0, ThaiBuddhistChronology.ERA_BEFORE_BE, 801 - YDIFF, -800 + YDIFF, true}, + {0, ThaiBuddhistEra.BEFORE_BE, -3 - YDIFF, 4 + YDIFF, true}, + {0, ThaiBuddhistEra.BEFORE_BE, -6 - YDIFF, 7 + YDIFF, false}, + {0, ThaiBuddhistEra.BEFORE_BE, -7 - YDIFF, 8 + YDIFF, true}, + {0, ThaiBuddhistEra.BEFORE_BE, -999 - YDIFF, 1000 + YDIFF, false}, + {0, ThaiBuddhistEra.BEFORE_BE, -1999 - YDIFF, 2000 + YDIFF, true}, + {0, ThaiBuddhistEra.BEFORE_BE, 1, 0, false}, + {0, ThaiBuddhistEra.BEFORE_BE, 5 - YDIFF, -4 + YDIFF, true}, + {0, ThaiBuddhistEra.BEFORE_BE, 8 - YDIFF, -7 + YDIFF, false}, + {0, ThaiBuddhistEra.BEFORE_BE, 101 - YDIFF, -100 + YDIFF, false}, + {0, ThaiBuddhistEra.BEFORE_BE, 801 - YDIFF, -800 + YDIFF, true}, }; } - @Test(dataProvider="prolepticYear", groups={"tck"}) + @Test(dataProvider="prolepticYear") public void test_prolepticYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) { Era eraObj = ThaiBuddhistChronology.INSTANCE.eraOf(eraValue) ; assertTrue(ThaiBuddhistChronology.INSTANCE.eras().contains(eraObj)); @@ -253,34 +260,73 @@ public class TestThaiBuddhistChronology { assertEquals(ThaiBuddhistChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear - YDIFF).isLeap()) ; } + //----------------------------------------------------------------------- + // Bad Era for Chronology.date(era,...) and Chronology.prolepticYear(Era,...) + //----------------------------------------------------------------------- + @Test + public void test_InvalidEras() { + // Verify that the eras from every other Chronology are invalid + for (Chronology chrono : Chronology.getAvailableChronologies()) { + if (chrono instanceof ThaiBuddhistChronology) { + continue; + } + List eras = chrono.eras(); + for (Era era : eras) { + try { + ChronoLocalDate date = ThaiBuddhistChronology.INSTANCE.date(era, 1, 1, 1); + fail("ThaiBuddhistChronology.date did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + + /* TODO: Test for missing ThaiBuddhistDate.of(Era, y, m, d) method. + try { + @SuppressWarnings("unused") + ThaiBuddhistDate jdate = ThaiBuddhistDate.of(era, 1, 1, 1); + fail("ThaiBuddhistDate.of did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } + */ + + try { + @SuppressWarnings("unused") + int year = ThaiBuddhistChronology.INSTANCE.prolepticYear(era, 1); + fail("ThaiBuddhistChronology.prolepticYear did not throw ClassCastException for Era: " + era); + } catch (ClassCastException cex) { + ; // ignore expected exception + } } + } + } + //----------------------------------------------------------------------- // with(WithAdjuster) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjust1() { ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(1728, 10, 29); - ThaiBuddhistDate test = base.with(Adjusters.lastDayOfMonth()); + ThaiBuddhistDate test = base.with(TemporalAdjuster.lastDayOfMonth()); assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(1728, 10, 31)); } - @Test(groups={"tck"}) + @Test public void test_adjust2() { ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(1728, 12, 2); - ThaiBuddhistDate test = base.with(Adjusters.lastDayOfMonth()); + ThaiBuddhistDate test = base.with(TemporalAdjuster.lastDayOfMonth()); assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(1728, 12, 31)); } //----------------------------------------------------------------------- // withYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withYear_BE() { ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29); ThaiBuddhistDate test = base.with(YEAR, 2554); assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2554, 8, 29)); } - @Test(groups={"tck"}) + @Test public void test_withYear_BBE() { ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29); ThaiBuddhistDate test = base.with(YEAR_OF_ERA, 2554); @@ -290,38 +336,38 @@ public class TestThaiBuddhistChronology { //----------------------------------------------------------------------- // withEra() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_withEra_BE() { ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29); - ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistChronology.ERA_BE.getValue()); + ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistEra.BE.getValue()); assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29)); } - @Test(groups={"tck"}) + @Test public void test_withEra_BBE() { ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29); - ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistChronology.ERA_BEFORE_BE.getValue()); + ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistEra.BEFORE_BE.getValue()); assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29)); } - @Test(groups={"tck"}) + @Test public void test_withEra_swap() { ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(-2554, 8, 29); - ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistChronology.ERA_BE.getValue()); + ThaiBuddhistDate test = base.with(ChronoField.ERA, ThaiBuddhistEra.BE.getValue()); assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 8, 29)); } //----------------------------------------------------------------------- // BuddhistDate.with(Local*) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_adjust_toLocalDate() { ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(1726, 1, 4); ThaiBuddhistDate test = jdate.with(LocalDate.of(2012, 7, 6)); assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(2555, 7, 6)); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_adjust_toMonth() { ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(1726, 1, 4); jdate.with(Month.APRIL); @@ -330,20 +376,48 @@ public class TestThaiBuddhistChronology { //----------------------------------------------------------------------- // LocalDate.with(BuddhistDate) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_LocalDate_adjustToBuddhistDate() { ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(2555, 10, 29); LocalDate test = LocalDate.MIN.with(jdate); assertEquals(test, LocalDate.of(2012, 10, 29)); } - @Test(groups={"tck"}) + @Test public void test_LocalDateTime_adjustToBuddhistDate() { ThaiBuddhistDate jdate = ThaiBuddhistChronology.INSTANCE.date(2555, 10, 29); LocalDateTime test = LocalDateTime.MIN.with(jdate); assertEquals(test, LocalDateTime.of(2012, 10, 29, 0, 0)); } + //----------------------------------------------------------------------- + // PeriodUntil() + //----------------------------------------------------------------------- + @Test + public void test_periodUntilDate() { + ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1); + ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2); + Period period = mdate1.periodUntil(mdate2); + assertEquals(period, Period.of(1, 1, 1)); + } + + @Test + public void test_periodUntilUnit() { + ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1); + ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2); + long months = mdate1.periodUntil(mdate2, ChronoUnit.MONTHS); + assertEquals(months, 13); + } + + @Test + public void test_periodUntilDiffChrono() { + ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1); + ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2); + MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2); + Period period = mdate1.periodUntil(ldate2); + assertEquals(period, Period.of(1, 1, 1)); + } + //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- @@ -358,7 +432,7 @@ public class TestThaiBuddhistChronology { }; } - @Test(dataProvider="toString", groups={"tck"}) + @Test(dataProvider="toString") public void test_toString(ThaiBuddhistDate jdate, String expected) { assertEquals(jdate.toString(), expected); } @@ -366,7 +440,7 @@ public class TestThaiBuddhistChronology { //----------------------------------------------------------------------- // chronology range(ChronoField) //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_Chrono_range() { long minYear = LocalDate.MIN.getYear() + YDIFF; long maxYear = LocalDate.MAX.getYear() + YDIFF; @@ -381,12 +455,12 @@ public class TestThaiBuddhistChronology { //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void test_equals_true() { assertTrue(ThaiBuddhistChronology.INSTANCE.equals(ThaiBuddhistChronology.INSTANCE)); } - @Test(groups="tck") + @Test public void test_equals_false() { assertFalse(ThaiBuddhistChronology.INSTANCE.equals(IsoChronology.INSTANCE)); } diff --git a/jdk/test/java/time/tck/java/time/chrono/TCKThaiBuddhistEra.java b/jdk/test/java/time/tck/java/time/chrono/TCKThaiBuddhistEra.java new file mode 100644 index 00000000000..4737edb3d28 --- /dev/null +++ b/jdk/test/java/time/tck/java/time/chrono/TCKThaiBuddhistEra.java @@ -0,0 +1,120 @@ +/* + * 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. 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.chrono; + +import static java.time.temporal.ChronoField.ERA; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.chrono.Era; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistEra; +import java.time.temporal.ValueRange; +import java.util.List; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test. + */ +@Test +public class TCKThaiBuddhistEra { + + @DataProvider(name = "ThaiBuddhistEras") + Object[][] data_of_eras() { + return new Object[][] { + {ThaiBuddhistEra.BEFORE_BE, "BEFORE_BE", 0}, + {ThaiBuddhistEra.BE, "BE", 1}, + }; + } + + + //----------------------------------------------------------------------- + // valueOf() + //----------------------------------------------------------------------- + @Test(dataProvider="ThaiBuddhistEras") + public void test_valueOf(ThaiBuddhistEra era , String eraName, int eraValue) { + assertEquals(era.getValue(), eraValue); + assertEquals(ThaiBuddhistEra.of(eraValue), era); + assertEquals(ThaiBuddhistEra.valueOf(eraName), era); + } + + //----------------------------------------------------------------------- + // values() + //----------------------------------------------------------------------- + @Test + public void test_values() { + List eraList = ThaiBuddhistChronology.INSTANCE.eras(); + ThaiBuddhistEra[] eras = ThaiBuddhistEra.values(); + assertEquals(eraList.size(), eras.length); + for (ThaiBuddhistEra era : eras) { + assertTrue(eraList.contains(era)); + } + } + + //----------------------------------------------------------------------- + // range() + //----------------------------------------------------------------------- + @Test + public void test_range() { + for (ThaiBuddhistEra era : ThaiBuddhistEra.values()) { + assertEquals(era.range(ERA), ValueRange.of(0, 1)); + } + } + +} diff --git a/jdk/test/java/time/tck/java/time/chrono/TestChronoLocalDateTime.java b/jdk/test/java/time/tck/java/time/chrono/TestChronoLocalDateTime.java deleted file mode 100644 index fd72237b8b7..00000000000 --- a/jdk/test/java/time/tck/java/time/chrono/TestChronoLocalDateTime.java +++ /dev/null @@ -1,470 +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. 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.chrono; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.time.Duration; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.chrono.HijrahChronology; -import java.time.chrono.JapaneseChronology; -import java.time.chrono.MinguoChronology; -import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ChronoLocalDateTime; -import java.time.chrono.Chronology; -import java.time.chrono.IsoChronology; -import java.time.temporal.ChronoUnit; -import java.time.temporal.Temporal; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalAdjuster; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalField; -import java.time.temporal.TemporalUnit; -import java.time.temporal.ValueRange; -import java.util.ArrayList; -import java.util.List; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test assertions that must be true for all built-in chronologies. - */ -@Test -public class TestChronoLocalDateTime { - //----------------------------------------------------------------------- - // regular data factory for names and descriptions of available calendars - //----------------------------------------------------------------------- - @DataProvider(name = "calendars") - Chronology[][] data_of_calendars() { - return new Chronology[][]{ - {HijrahChronology.INSTANCE}, - {IsoChronology.INSTANCE}, - {JapaneseChronology.INSTANCE}, - {MinguoChronology.INSTANCE}, - {ThaiBuddhistChronology.INSTANCE}}; - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badWithAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalAdjuster adjuster = new FixedAdjuster(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.with(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + cdt + ", supplied: " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.with(adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalAmount adjuster = new FixedAdjuster(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.plus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + cdt + ", supplied: " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.plus(adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date time"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalAmount adjuster = new FixedAdjuster(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.minus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException, " - + "required: " + cdt + ", supplied: " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.minus(adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalUnit adjuster = new FixedTemporalUnit(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.plus(1, adjuster); - Assert.fail("TemporalUnit.doAdd plus should have thrown a ClassCastException" + cdt - + ", can not be cast to " + cdt2); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.plus(1, adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalUnit adjuster = new FixedTemporalUnit(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.minus(1, adjuster); - Assert.fail("TemporalUnit.doAdd minus should have thrown a ClassCastException" + cdt.getClass() - + ", can not be cast to " + cdt2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.minus(1, adjuster); - assertEquals(result, cdt2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badTemporalFieldChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDateTime cdt = chrono.date(refDate).atTime(LocalTime.NOON); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDateTime cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); - TemporalField adjuster = new FixedTemporalField(cdt2); - if (chrono != chrono2) { - try { - ChronoLocalDateTime notreached = cdt.with(adjuster, 1); - Assert.fail("TemporalField doSet should have thrown a ClassCastException" + cdt.getClass() - + ", can not be cast to " + cdt2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDateTime result = cdt.with(adjuster, 1); - assertEquals(result, cdt2, "TemporalField doSet failed to replace date"); - } - } - } - - //----------------------------------------------------------------------- - // isBefore, isAfter, isEqual - //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="calendars") - public void test_datetime_comparisons(Chronology chrono) { - List> dates = new ArrayList<>(); - - ChronoLocalDateTime date = chrono.date(LocalDate.of(1900, 1, 1)).atTime(LocalTime.MIN); - - // Insert dates in order, no duplicates - dates.add(date.minus(100, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.MONTHS)); - dates.add(date.minus(1, ChronoUnit.WEEKS)); - dates.add(date.minus(1, ChronoUnit.DAYS)); - dates.add(date.minus(1, ChronoUnit.HOURS)); - dates.add(date.minus(1, ChronoUnit.MINUTES)); - dates.add(date.minus(1, ChronoUnit.SECONDS)); - dates.add(date.minus(1, ChronoUnit.NANOS)); - dates.add(date); - dates.add(date.plus(1, ChronoUnit.NANOS)); - dates.add(date.plus(1, ChronoUnit.SECONDS)); - dates.add(date.plus(1, ChronoUnit.MINUTES)); - dates.add(date.plus(1, ChronoUnit.HOURS)); - dates.add(date.plus(1, ChronoUnit.DAYS)); - dates.add(date.plus(1, ChronoUnit.WEEKS)); - dates.add(date.plus(1, ChronoUnit.MONTHS)); - dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(100, ChronoUnit.YEARS)); - - // Check these dates against the corresponding dates for every calendar - for (Chronology[] clist : data_of_calendars()) { - List> otherDates = new ArrayList<>(); - Chronology chrono2 = clist[0]; - for (ChronoLocalDateTime d : dates) { - otherDates.add(chrono2.date(d).atTime(d.toLocalTime())); - } - - // Now compare the sequence of original dates with the sequence of converted dates - for (int i = 0; i < dates.size(); i++) { - ChronoLocalDateTime a = dates.get(i); - for (int j = 0; j < otherDates.size(); j++) { - ChronoLocalDateTime b = otherDates.get(j); - int cmp = ChronoLocalDateTime.DATE_TIME_COMPARATOR.compare(a, b); - if (i < j) { - assertTrue(cmp < 0, a + " compare " + b); - assertEquals(a.isBefore(b), true, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else if (i > j) { - assertTrue(cmp > 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), true, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else { - assertTrue(cmp == 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), true, a + " isEqual " + b); - } - } - } - } - } - - //----------------------------------------------------------------------- - // Test Serialization of ISO via chrono API - //----------------------------------------------------------------------- - @Test( groups={"tck"}, dataProvider="calendars") - public void test_ChronoLocalDateTimeSerialization(Chronology chrono) throws Exception { - LocalDateTime ref = LocalDate.of(2000, 1, 5).atTime(12, 1, 2, 3); - ChronoLocalDateTime orginal = chrono.date(ref).atTime(ref.toLocalTime()); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); - out.writeObject(orginal); - out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream in = new ObjectInputStream(bais); - ChronoLocalDateTime ser = (ChronoLocalDateTime) in.readObject(); - assertEquals(ser, orginal, "deserialized date is wrong"); - } - - - /** - * FixedAdjusted returns a fixed Temporal in all adjustments. - * Construct an adjuster with the Temporal that should be returned from adjust. - */ - static class FixedAdjuster implements TemporalAdjuster, TemporalAmount { - private Temporal datetime; - - FixedAdjuster(Temporal datetime) { - this.datetime = datetime; - } - - @Override - public Temporal adjustInto(Temporal ignore) { - return datetime; - } - - @Override - public Temporal addTo(Temporal ignore) { - return datetime; - } - - @Override - public Temporal subtractFrom(Temporal ignore) { - return datetime; - } - - @Override - public long get(TemporalUnit unit) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public List getUnits() { - throw new UnsupportedOperationException("Not supported yet."); - } - - } - - /** - * FixedTemporalUnit returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalUnit with the Temporal that should be returned from doAdd. - */ - static class FixedTemporalUnit implements TemporalUnit { - private Temporal temporal; - - FixedTemporalUnit(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalUnit"; - } - - @Override - public Duration getDuration() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isDurationEstimated() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(Temporal temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R addTo(R temporal, long amount) { - return (R) this.temporal; - } - - @Override - public long between(Temporal temporal1, Temporal temporal2) { - throw new UnsupportedOperationException("Not supported yet."); - } - } - - /** - * FixedTemporalField returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalField with the Temporal that should be returned from doSet. - */ - static class FixedTemporalField implements TemporalField { - private Temporal temporal; - FixedTemporalField(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalField"; - } - - @Override - public TemporalUnit getBaseUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public TemporalUnit getRangeUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange range() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange rangeRefinedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getFrom(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R adjustInto(R temporal, long newValue) { - return (R) this.temporal; - } - } -} diff --git a/jdk/test/java/time/tck/java/time/chrono/TestMinguoChronology.java b/jdk/test/java/time/tck/java/time/chrono/TestMinguoChronology.java deleted file mode 100644 index 5ea1979bcdf..00000000000 --- a/jdk/test/java/time/tck/java/time/chrono/TestMinguoChronology.java +++ /dev/null @@ -1,325 +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. 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.chrono; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.time.DateTimeException; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.Month; -import java.time.ZoneOffset; -import java.time.chrono.MinguoChronology; -import java.time.chrono.MinguoDate; -import java.time.temporal.Adjusters; -import java.time.temporal.ChronoUnit; -import java.time.chrono.ChronoZonedDateTime; -import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ChronoLocalDateTime; -import java.time.chrono.IsoChronology; -import java.time.chrono.Era; -import java.time.Year; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test. - */ -@Test -public class TestMinguoChronology { - - private static final int YDIFF = 1911; - //----------------------------------------------------------------------- - // Chronology.ofName("Minguo") Lookup by name - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_chrono_byName() { - Chronology c = MinguoChronology.INSTANCE; - Chronology test = Chronology.of("Minguo"); - Assert.assertNotNull(test, "The Minguo calendar could not be found byName"); - Assert.assertEquals(test.getId(), "Minguo", "ID mismatch"); - Assert.assertEquals(test.getCalendarType(), "roc", "Type mismatch"); - Assert.assertEquals(test, c); - } - - //----------------------------------------------------------------------- - // creation, toLocalDate() - //----------------------------------------------------------------------- - @DataProvider(name="samples") - Object[][] data_samples() { - return new Object[][] { - {MinguoChronology.INSTANCE.date(1, 1, 1), LocalDate.of(1 + YDIFF, 1, 1)}, - {MinguoChronology.INSTANCE.date(1, 1, 2), LocalDate.of(1 + YDIFF, 1, 2)}, - {MinguoChronology.INSTANCE.date(1, 1, 3), LocalDate.of(1 + YDIFF, 1, 3)}, - - {MinguoChronology.INSTANCE.date(2, 1, 1), LocalDate.of(2 + YDIFF, 1, 1)}, - {MinguoChronology.INSTANCE.date(3, 1, 1), LocalDate.of(3 + YDIFF, 1, 1)}, - {MinguoChronology.INSTANCE.date(3, 12, 6), LocalDate.of(3 + YDIFF, 12, 6)}, - {MinguoChronology.INSTANCE.date(4, 1, 1), LocalDate.of(4 + YDIFF, 1, 1)}, - {MinguoChronology.INSTANCE.date(4, 7, 3), LocalDate.of(4 + YDIFF, 7, 3)}, - {MinguoChronology.INSTANCE.date(4, 7, 4), LocalDate.of(4 + YDIFF, 7, 4)}, - {MinguoChronology.INSTANCE.date(5, 1, 1), LocalDate.of(5 + YDIFF, 1, 1)}, - {MinguoChronology.INSTANCE.date(100, 3, 3), LocalDate.of(100 + YDIFF, 3, 3)}, - {MinguoChronology.INSTANCE.date(101, 10, 28), LocalDate.of(101 + YDIFF, 10, 28)}, - {MinguoChronology.INSTANCE.date(101, 10, 29), LocalDate.of(101 + YDIFF, 10, 29)}, - - {MinguoChronology.INSTANCE.dateYearDay(1916 - YDIFF, 60), LocalDate.of(1916, 2, 29)}, - {MinguoChronology.INSTANCE.dateYearDay(1908 - YDIFF, 60), LocalDate.of(1908, 2, 29)}, - {MinguoChronology.INSTANCE.dateYearDay(2000 - YDIFF, 60), LocalDate.of(2000, 2, 29)}, - {MinguoChronology.INSTANCE.dateYearDay(2400 - YDIFF, 60), LocalDate.of(2400, 2, 29)}, - }; - } - - @Test(dataProvider="samples", groups={"tck"}) - public void test_toLocalDate(MinguoDate minguo, LocalDate iso) { - assertEquals(LocalDate.from(minguo), iso); - } - - @Test(dataProvider="samples", groups={"tck"}) - public void test_fromCalendrical(MinguoDate minguo, LocalDate iso) { - assertEquals(MinguoChronology.INSTANCE.date(iso), minguo); - } - - @SuppressWarnings("unused") - @Test(dataProvider="samples", groups={"implementation"}) - public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) { - MinguoDate hd = minguoDate; - ChronoLocalDateTime hdt = hd.atTime(LocalTime.NOON); - ZoneOffset zo = ZoneOffset.ofHours(1); - ChronoZonedDateTime hzdt = hdt.atZone(zo); - hdt = hdt.plus(1, ChronoUnit.YEARS); - hdt = hdt.plus(1, ChronoUnit.MONTHS); - hdt = hdt.plus(1, ChronoUnit.DAYS); - hdt = hdt.plus(1, ChronoUnit.HOURS); - hdt = hdt.plus(1, ChronoUnit.MINUTES); - hdt = hdt.plus(1, ChronoUnit.SECONDS); - hdt = hdt.plus(1, ChronoUnit.NANOS); - ChronoLocalDateTime a2 = hzdt.toLocalDateTime(); - MinguoDate a3 = a2.toLocalDate(); - MinguoDate a5 = hzdt.toLocalDate(); - //System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5); - } - - @Test() - public void test_MinguoChrono() { - MinguoDate h1 = (MinguoDate)MinguoChronology.ERA_ROC.date(1, 2, 3); - MinguoDate h2 = h1; - ChronoLocalDateTime h3 = h2.atTime(LocalTime.NOON); - @SuppressWarnings("unused") - ChronoZonedDateTime h4 = h3.atZone(ZoneOffset.UTC); - } - - @DataProvider(name="badDates") - Object[][] data_badDates() { - return new Object[][] { - {1912, 0, 0}, - - {1912, -1, 1}, - {1912, 0, 1}, - {1912, 14, 1}, - {1912, 15, 1}, - - {1912, 1, -1}, - {1912, 1, 0}, - {1912, 1, 32}, - {1912, 2, 29}, - {1912, 2, 30}, - - {1912, 12, -1}, - {1912, 12, 0}, - {1912, 12, 32}, - - {1907 - YDIFF, 2, 29}, - {100 - YDIFF, 2, 29}, - {2100 - YDIFF, 2, 29}, - {2101 - YDIFF, 2, 29}, - }; - } - - @Test(dataProvider="badDates", groups={"tck"}, expectedExceptions=DateTimeException.class) - public void test_badDates(int year, int month, int dom) { - MinguoChronology.INSTANCE.date(year, month, dom); - } - - //----------------------------------------------------------------------- - // prolepticYear() and is LeapYear() - //----------------------------------------------------------------------- - @DataProvider(name="prolepticYear") - Object[][] data_prolepticYear() { - return new Object[][] { - {1, MinguoChronology.ERA_ROC, 1912 - YDIFF, 1912 - YDIFF, true}, - {1, MinguoChronology.ERA_ROC, 1916 - YDIFF, 1916 - YDIFF, true}, - {1, MinguoChronology.ERA_ROC, 1914 - YDIFF, 1914 - YDIFF, false}, - {1, MinguoChronology.ERA_ROC, 2000 - YDIFF, 2000 - YDIFF, true}, - {1, MinguoChronology.ERA_ROC, 2100 - YDIFF, 2100 - YDIFF, false}, - {1, MinguoChronology.ERA_ROC, 0, 0, false}, - {1, MinguoChronology.ERA_ROC, 1908 - YDIFF, 1908 - YDIFF, true}, - {1, MinguoChronology.ERA_ROC, 1900 - YDIFF, 1900 - YDIFF, false}, - {1, MinguoChronology.ERA_ROC, 1600 - YDIFF, 1600 - YDIFF, true}, - - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1911, 1912 - YDIFF, true}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1915, 1916 - YDIFF, true}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1913, 1914 - YDIFF, false}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1999, 2000 - YDIFF, true}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 2099, 2100 - YDIFF, false}, - {0, MinguoChronology.ERA_BEFORE_ROC, 1, 0, false}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1907, 1908 - YDIFF, true}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1899, 1900 - YDIFF, false}, - {0, MinguoChronology.ERA_BEFORE_ROC, YDIFF - 1599, 1600 - YDIFF, true}, - - }; - } - - @Test(dataProvider="prolepticYear", groups={"tck"}) - public void test_prolepticYear(int eraValue, Era era, int yearOfEra, int expectedProlepticYear, boolean isLeapYear) { - Era eraObj = MinguoChronology.INSTANCE.eraOf(eraValue) ; - assertTrue(MinguoChronology.INSTANCE.eras().contains(eraObj)); - assertEquals(eraObj, era); - assertEquals(MinguoChronology.INSTANCE.prolepticYear(era, yearOfEra), expectedProlepticYear); - assertEquals(MinguoChronology.INSTANCE.isLeapYear(expectedProlepticYear), isLeapYear) ; - assertEquals(MinguoChronology.INSTANCE.isLeapYear(expectedProlepticYear), Year.of(expectedProlepticYear + YDIFF).isLeap()) ; - } - - //----------------------------------------------------------------------- - // with(DateTimeAdjuster) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_adjust1() { - MinguoDate base = MinguoChronology.INSTANCE.date(2012, 10, 29); - MinguoDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, MinguoChronology.INSTANCE.date(2012, 10, 31)); - } - - @Test(groups={"tck"}) - public void test_adjust2() { - MinguoDate base = MinguoChronology.INSTANCE.date(1728, 12, 2); - MinguoDate test = base.with(Adjusters.lastDayOfMonth()); - assertEquals(test, MinguoChronology.INSTANCE.date(1728, 12, 31)); - } - - //----------------------------------------------------------------------- - // MinguoDate.with(Local*) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_adjust_toLocalDate() { - MinguoDate minguo = MinguoChronology.INSTANCE.date(99, 1, 4); - MinguoDate test = minguo.with(LocalDate.of(2012, 7, 6)); - assertEquals(test, MinguoChronology.INSTANCE.date(101, 7, 6)); - } - - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) - public void test_adjust_toMonth() { - MinguoDate minguo = MinguoChronology.INSTANCE.date(1726, 1, 4); - minguo.with(Month.APRIL); - } - - //----------------------------------------------------------------------- - // LocalDate.with(MinguoDate) - //----------------------------------------------------------------------- - @Test(groups={"tck"}) - public void test_LocalDate_adjustToMinguoDate() { - MinguoDate minguo = MinguoChronology.INSTANCE.date(101, 10, 29); - LocalDate test = LocalDate.MIN.with(minguo); - assertEquals(test, LocalDate.of(2012, 10, 29)); - } - - @Test(groups={"tck"}) - public void test_LocalDateTime_adjustToMinguoDate() { - MinguoDate minguo = MinguoChronology.INSTANCE.date(101, 10, 29); - LocalDateTime test = LocalDateTime.MIN.with(minguo); - assertEquals(test, LocalDateTime.of(2012, 10, 29, 0, 0)); - } - - //----------------------------------------------------------------------- - // toString() - //----------------------------------------------------------------------- - @DataProvider(name="toString") - Object[][] data_toString() { - return new Object[][] { - {MinguoChronology.INSTANCE.date(1, 1, 1), "Minguo ROC 1-01-01"}, - {MinguoChronology.INSTANCE.date(1728, 10, 28), "Minguo ROC 1728-10-28"}, - {MinguoChronology.INSTANCE.date(1728, 10, 29), "Minguo ROC 1728-10-29"}, - {MinguoChronology.INSTANCE.date(1727, 12, 5), "Minguo ROC 1727-12-05"}, - {MinguoChronology.INSTANCE.date(1727, 12, 6), "Minguo ROC 1727-12-06"}, - }; - } - - @Test(dataProvider="toString", groups={"tck"}) - public void test_toString(MinguoDate minguo, String expected) { - assertEquals(minguo.toString(), expected); - } - - //----------------------------------------------------------------------- - // equals() - //----------------------------------------------------------------------- - @Test(groups="tck") - public void test_equals_true() { - assertTrue(MinguoChronology.INSTANCE.equals(MinguoChronology.INSTANCE)); - } - - @Test(groups="tck") - public void test_equals_false() { - assertFalse(MinguoChronology.INSTANCE.equals(IsoChronology.INSTANCE)); - } - -} diff --git a/jdk/test/java/time/tck/java/time/format/TCKChronoPrinterParser.java b/jdk/test/java/time/tck/java/time/format/TCKChronoPrinterParser.java index e4e74f6f351..de3b91c7f75 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKChronoPrinterParser.java +++ b/jdk/test/java/time/tck/java/time/format/TCKChronoPrinterParser.java @@ -67,8 +67,8 @@ import java.time.chrono.IsoChronology; import java.time.chrono.JapaneseChronology; import java.time.chrono.ThaiBuddhistChronology; import java.time.format.DateTimeFormatterBuilder; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQuery; import java.util.Locale; import org.testng.annotations.BeforeMethod; @@ -122,7 +122,7 @@ public class TCKChronoPrinterParser { TemporalAccessor parsed = builder.toFormatter().parseUnresolved(text, pos); assertEquals(pos.getIndex(), expected.getId().length()); assertEquals(pos.getErrorIndex(), -1); - assertEquals(parsed.query(Queries.chronology()), expected); + assertEquals(parsed.query(TemporalQuery.chronology()), expected); } @Test(dataProvider="parseValid") @@ -140,7 +140,7 @@ public class TCKChronoPrinterParser { TemporalAccessor parsed = builder.toFormatter().parseUnresolved(text.toLowerCase(Locale.ENGLISH), pos); assertEquals(pos.getIndex(), expected.getId().length()); assertEquals(pos.getErrorIndex(), -1); - assertEquals(parsed.query(Queries.chronology()), expected); + assertEquals(parsed.query(TemporalQuery.chronology()), expected); } //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatSymbols.java b/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatSymbols.java index f2be900c908..9deec99814e 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatSymbols.java +++ b/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatSymbols.java @@ -59,11 +59,9 @@ */ package tck.java.time.format; -import java.time.format.*; -import test.java.time.format.*; - import static org.testng.Assert.assertEquals; +import java.time.format.DateTimeFormatSymbols; import java.util.Arrays; import java.util.Locale; @@ -75,7 +73,7 @@ import org.testng.annotations.Test; @Test public class TCKDateTimeFormatSymbols { - @Test(groups={"tck"}) + @Test public void test_getAvailableLocales() { Locale[] locales = DateTimeFormatSymbols.getAvailableLocales(); assertEquals(locales.length > 0, true); @@ -83,7 +81,7 @@ public class TCKDateTimeFormatSymbols { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_of_Locale() { DateTimeFormatSymbols loc1 = DateTimeFormatSymbols.of(Locale.CANADA); assertEquals(loc1.getZeroDigit(), '0'); @@ -93,7 +91,7 @@ public class TCKDateTimeFormatSymbols { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_STANDARD() { DateTimeFormatSymbols loc1 = DateTimeFormatSymbols.STANDARD; assertEquals(loc1.getZeroDigit(), '0'); @@ -103,25 +101,25 @@ public class TCKDateTimeFormatSymbols { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_zeroDigit() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.withZeroDigit('A').getZeroDigit(), 'A'); } - @Test(groups={"tck"}) + @Test public void test_positiveSign() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.withPositiveSign('A').getPositiveSign(), 'A'); } - @Test(groups={"tck"}) + @Test public void test_negativeSign() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.withNegativeSign('A').getNegativeSign(), 'A'); } - @Test(groups={"tck"}) + @Test public void test_decimalSeparator() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.withDecimalSeparator('A').getDecimalSeparator(), 'A'); @@ -129,7 +127,7 @@ public class TCKDateTimeFormatSymbols { //----------------------------------------------------------------------- /* TBD: convertToDigit and convertNumberToI18N are package-private methods - @Test(groups={"tck"}) + @Test public void test_convertToDigit_base() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.convertToDigit('0'), 0); @@ -139,7 +137,7 @@ public class TCKDateTimeFormatSymbols { assertEquals(base.convertToDigit('A'), -1); } - @Test(groups={"tck"}) + @Test public void test_convertToDigit_altered() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD.withZeroDigit('A'); assertEquals(base.convertToDigit('A'), 0); @@ -150,20 +148,20 @@ public class TCKDateTimeFormatSymbols { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_convertNumberToI18N_base() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.convertNumberToI18N("134"), "134"); } - @Test(groups={"tck"}) + @Test public void test_convertNumberToI18N_altered() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD.withZeroDigit('A'); assertEquals(base.convertNumberToI18N("134"), "BDE"); } */ //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equalsHashCode1() { DateTimeFormatSymbols a = DateTimeFormatSymbols.STANDARD; DateTimeFormatSymbols b = DateTimeFormatSymbols.STANDARD; @@ -172,7 +170,7 @@ public class TCKDateTimeFormatSymbols { assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_equalsHashCode2() { DateTimeFormatSymbols a = DateTimeFormatSymbols.STANDARD.withZeroDigit('A'); DateTimeFormatSymbols b = DateTimeFormatSymbols.STANDARD.withZeroDigit('A'); @@ -181,7 +179,7 @@ public class TCKDateTimeFormatSymbols { assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_equalsHashCode3() { DateTimeFormatSymbols a = DateTimeFormatSymbols.STANDARD.withZeroDigit('A'); DateTimeFormatSymbols b = DateTimeFormatSymbols.STANDARD.withDecimalSeparator('A'); @@ -189,7 +187,7 @@ public class TCKDateTimeFormatSymbols { assertEquals(b.equals(a), false); } - @Test(groups={"tck"}) + @Test public void test_equalsHashCode_bad() { DateTimeFormatSymbols a = DateTimeFormatSymbols.STANDARD; assertEquals(a.equals(""), false); @@ -197,13 +195,13 @@ public class TCKDateTimeFormatSymbols { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString_base() { DateTimeFormatSymbols base = DateTimeFormatSymbols.STANDARD; assertEquals(base.toString(), "Symbols[0+-.]"); } - @Test(groups={"tck"}) + @Test public void test_toString_altered() { DateTimeFormatSymbols base = DateTimeFormatSymbols.of(Locale.US).withZeroDigit('A').withDecimalSeparator('@'); assertEquals(base.toString(), "Symbols[A+-@]"); diff --git a/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatter.java b/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatter.java index f124d7ef215..e8f137f963d 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatter.java +++ b/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatter.java @@ -60,6 +60,8 @@ package tck.java.time.format; import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.DAY_OF_WEEK; +import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.HOUR_OF_DAY; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; @@ -71,29 +73,37 @@ import static org.testng.Assert.fail; import java.text.Format; import java.text.ParseException; import java.text.ParsePosition; -import java.util.Locale; - import java.time.DateTimeException; +import java.time.DayOfWeek; import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.YearMonth; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.time.chrono.ChronoZonedDateTime; +import java.time.chrono.Chronology; +import java.time.chrono.IsoChronology; import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistDate; import java.time.format.DateTimeFormatSymbols; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeParseException; import java.time.format.SignStyle; -import java.time.chrono.Chronology; -import java.time.chrono.IsoChronology; -import java.time.OffsetDateTime; -import java.time.OffsetTime; -import java.time.temporal.Temporal; +import java.time.temporal.IsoFields; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; @@ -102,7 +112,7 @@ import org.testng.annotations.Test; /** * Test DateTimeFormatter. */ -@Test(groups={"tck"}) +@Test public class TCKDateTimeFormatter { private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1); @@ -160,87 +170,241 @@ public class TCKDateTimeFormatter { } //----------------------------------------------------------------------- - // print + @Test + public void test_resolverFields_selectOneDateResolveYMD() throws Exception { + DateTimeFormatter base = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral('-').appendValue(MONTH_OF_YEAR).appendLiteral('-') + .appendValue(DAY_OF_MONTH).appendLiteral('-').appendValue(DAY_OF_YEAR).toFormatter(); + DateTimeFormatter f = base.withResolverFields(YEAR, MONTH_OF_YEAR, DAY_OF_MONTH); + try { + base.parse("2012-6-30-321", LocalDate::from); // wrong day-of-year + fail(); + } catch (DateTimeException ex) { + // expected, fails as it produces two different dates + } + LocalDate parsed = f.parse("2012-6-30-321", LocalDate::from); // ignored day-of-year + assertEquals(parsed, LocalDate.of(2012, 6, 30)); + } + + @Test + public void test_resolverFields_selectOneDateResolveYD() throws Exception { + DateTimeFormatter base = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral('-').appendValue(MONTH_OF_YEAR).appendLiteral('-') + .appendValue(DAY_OF_MONTH).appendLiteral('-').appendValue(DAY_OF_YEAR).toFormatter(); + DateTimeFormatter f = base.withResolverFields(YEAR, DAY_OF_YEAR); + assertEquals(f.getResolverFields(), new HashSet<>(Arrays.asList(YEAR, DAY_OF_YEAR))); + try { + base.parse("2012-6-30-321", LocalDate::from); // wrong month/day-of-month + fail(); + } catch (DateTimeException ex) { + // expected, fails as it produces two different dates + } + LocalDate parsed = f.parse("2012-6-30-321", LocalDate::from); // ignored month/day-of-month + assertEquals(parsed, LocalDate.of(2012, 11, 16)); + } + + @Test + public void test_resolverFields_ignoreCrossCheck() throws Exception { + DateTimeFormatter base = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral('-').appendValue(DAY_OF_YEAR).appendLiteral('-') + .appendValue(DAY_OF_WEEK).toFormatter(); + DateTimeFormatter f = base.withResolverFields(YEAR, DAY_OF_YEAR); + try { + base.parse("2012-321-1", LocalDate::from); // wrong day-of-week + fail(); + } catch (DateTimeException ex) { + // expected, should fail in cross-check of day-of-week + } + LocalDate parsed = f.parse("2012-321-1", LocalDate::from); // ignored wrong day-of-week + assertEquals(parsed, LocalDate.of(2012, 11, 16)); + } + + @Test + public void test_resolverFields_emptyList() throws Exception { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).toFormatter().withResolverFields(); + TemporalAccessor parsed = f.parse("2012"); + assertEquals(parsed.isSupported(YEAR), false); // not in the list of resolverFields + } + + @Test + public void test_resolverFields_listOfOneMatching() throws Exception { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).toFormatter().withResolverFields(YEAR); + TemporalAccessor parsed = f.parse("2012"); + assertEquals(parsed.isSupported(YEAR), true); + } + + @Test + public void test_resolverFields_listOfOneNotMatching() throws Exception { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).toFormatter().withResolverFields(MONTH_OF_YEAR); + TemporalAccessor parsed = f.parse("2012"); + assertEquals(parsed.isSupported(YEAR), false); // not in the list of resolverFields + assertEquals(parsed.isSupported(MONTH_OF_YEAR), false); + } + + @Test + public void test_resolverFields_listOfOneNull() throws Exception { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).toFormatter().withResolverFields((TemporalField) null); + TemporalAccessor parsed = f.parse("2012"); + assertEquals(parsed.isSupported(YEAR), false); // not in the list of resolverFields + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_resolverFields_Array_null() throws Exception { + DateTimeFormatter.ISO_DATE.withResolverFields((TemporalField[]) null); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_resolverFields_Set_null() throws Exception { + DateTimeFormatter.ISO_DATE.withResolverFields((Set) null); + } + //----------------------------------------------------------------------- - @DataProvider(name="print") - Object[][] data_format() { + // format + //----------------------------------------------------------------------- + @DataProvider(name="formatWithZoneWithChronology") + Object[][] data_format_withZone_withChronology() { + YearMonth ym = YearMonth.of(2008, 6); LocalDate ld = LocalDate.of(2008, 6, 30); LocalTime lt = LocalTime.of(11, 30); LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 11, 30); OffsetTime ot = OffsetTime.of(LocalTime.of(11, 30), OFFSET_PONE); OffsetDateTime odt = OffsetDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), OFFSET_PONE); ZonedDateTime zdt = ZonedDateTime.of(LocalDateTime.of(2008, 6, 30, 11, 30), ZONE_PARIS); + ChronoZonedDateTime thaiZdt = ThaiBuddhistChronology.INSTANCE.zonedDateTime(zdt); Instant instant = Instant.ofEpochSecond(3600); return new Object[][] { - {null, null, ld, "2008::"}, - {null, null, lt, ":11:"}, - {null, null, ldt, "2008:11:"}, - {null, null, ot, ":11:+01:00"}, - {null, null, odt, "2008:11:+01:00"}, - {null, null, zdt, "2008:11:+02:00Europe/Paris"}, - {null, null, instant, "::"}, + {null, null, DayOfWeek.MONDAY, "::::"}, + {null, null, ym, "2008::::ISO"}, + {null, null, ld, "2008::::ISO"}, + {null, null, lt, ":11:::"}, + {null, null, ldt, "2008:11:::ISO"}, + {null, null, ot, ":11:+01:00::"}, + {null, null, odt, "2008:11:+01:00::ISO"}, + {null, null, zdt, "2008:11:+02:00:Europe/Paris:ISO"}, + {null, null, instant, "::::"}, - {null, ZONE_PARIS, ld, "2008::"}, - {null, ZONE_PARIS, lt, ":11:"}, - {null, ZONE_PARIS, ldt, "2008:11:"}, - {null, ZONE_PARIS, ot, ":11:+01:00"}, - {null, ZONE_PARIS, odt, "2008:12:+02:00Europe/Paris"}, - {null, ZONE_PARIS, zdt, "2008:11:+02:00Europe/Paris"}, - {null, ZONE_PARIS, instant, "1970:02:+01:00Europe/Paris"}, + {IsoChronology.INSTANCE, null, DayOfWeek.MONDAY, "::::ISO"}, + {IsoChronology.INSTANCE, null, ym, "2008::::ISO"}, + {IsoChronology.INSTANCE, null, ld, "2008::::ISO"}, + {IsoChronology.INSTANCE, null, lt, ":11:::ISO"}, + {IsoChronology.INSTANCE, null, ldt, "2008:11:::ISO"}, + {IsoChronology.INSTANCE, null, ot, ":11:+01:00::ISO"}, + {IsoChronology.INSTANCE, null, odt, "2008:11:+01:00::ISO"}, + {IsoChronology.INSTANCE, null, zdt, "2008:11:+02:00:Europe/Paris:ISO"}, + {IsoChronology.INSTANCE, null, instant, "::::ISO"}, - {null, OFFSET_PTHREE, ld, "2008::"}, - {null, OFFSET_PTHREE, lt, ":11:"}, - {null, OFFSET_PTHREE, ldt, "2008:11:"}, - {null, OFFSET_PTHREE, ot, ":11:+01:00"}, - {null, OFFSET_PTHREE, odt, "2008:13:+03:00"}, - {null, OFFSET_PTHREE, zdt, "2008:12:+03:00"}, - {null, OFFSET_PTHREE, instant, "1970:04:+03:00"}, + {null, ZONE_PARIS, DayOfWeek.MONDAY, ":::Europe/Paris:"}, + {null, ZONE_PARIS, ym, "2008:::Europe/Paris:ISO"}, + {null, ZONE_PARIS, ld, "2008:::Europe/Paris:ISO"}, + {null, ZONE_PARIS, lt, ":11::Europe/Paris:"}, + {null, ZONE_PARIS, ldt, "2008:11::Europe/Paris:ISO"}, + {null, ZONE_PARIS, ot, ":11:+01:00:Europe/Paris:"}, + {null, ZONE_PARIS, odt, "2008:12:+02:00:Europe/Paris:ISO"}, + {null, ZONE_PARIS, zdt, "2008:11:+02:00:Europe/Paris:ISO"}, + {null, ZONE_PARIS, instant, "1970:02:+01:00:Europe/Paris:ISO"}, - {ThaiBuddhistChronology.INSTANCE, null, ld, "2551::"}, - {ThaiBuddhistChronology.INSTANCE, null, lt, ":11:"}, - {ThaiBuddhistChronology.INSTANCE, null, ldt, "2551:11:"}, - {ThaiBuddhistChronology.INSTANCE, null, ot, ":11:+01:00"}, - {ThaiBuddhistChronology.INSTANCE, null, odt, "2551:11:+01:00"}, - {ThaiBuddhistChronology.INSTANCE, null, zdt, "2551:11:+02:00Europe/Paris"}, - {ThaiBuddhistChronology.INSTANCE, null, instant, "::"}, + {null, OFFSET_PTHREE, DayOfWeek.MONDAY, ":::+03:00:"}, + {null, OFFSET_PTHREE, ym, "2008:::+03:00:ISO"}, + {null, OFFSET_PTHREE, ld, "2008:::+03:00:ISO"}, + {null, OFFSET_PTHREE, lt, ":11::+03:00:"}, + {null, OFFSET_PTHREE, ldt, "2008:11::+03:00:ISO"}, + {null, OFFSET_PTHREE, ot, null}, // offset and zone clash + {null, OFFSET_PTHREE, odt, "2008:13:+03:00:+03:00:ISO"}, + {null, OFFSET_PTHREE, zdt, "2008:12:+03:00:+03:00:ISO"}, + {null, OFFSET_PTHREE, instant, "1970:04:+03:00:+03:00:ISO"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ld, "2551::"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, lt, ":11:"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ldt, "2551:11:"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ot, ":11:+01:00"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, odt, "2551:12:+02:00Europe/Paris"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, zdt, "2551:11:+02:00Europe/Paris"}, - {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, instant, "1970:02:+01:00Europe/Paris"}, + {ThaiBuddhistChronology.INSTANCE, null, DayOfWeek.MONDAY, null}, // not a complete date + {ThaiBuddhistChronology.INSTANCE, null, ym, null}, // not a complete date + {ThaiBuddhistChronology.INSTANCE, null, ld, "2551::::ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, lt, ":11:::ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, ldt, "2551:11:::ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, ot, ":11:+01:00::ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, odt, "2551:11:+01:00::ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, null, instant, "::::ThaiBuddhist"}, + + {ThaiBuddhistChronology.INSTANCE, null, DayOfWeek.MONDAY, null}, // not a complete date + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ym, null}, // not a complete date + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ld, "2551:::Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, lt, ":11::Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ldt, "2551:11::Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, ot, ":11:+01:00:Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, odt, "2551:12:+02:00:Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, zdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, instant, "2513:02:+01:00:Europe/Paris:ThaiBuddhist"}, + + {null, ZONE_PARIS, thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"}, + {ThaiBuddhistChronology.INSTANCE, ZONE_PARIS, thaiZdt, "2551:11:+02:00:Europe/Paris:ThaiBuddhist"}, + {IsoChronology.INSTANCE, ZONE_PARIS, thaiZdt, "2008:11:+02:00:Europe/Paris:ISO"}, }; } - @Test(dataProvider="print") - public void test_print_Temporal(Chronology overrideChrono, ZoneId overrideZone, Temporal temporal, String expected) { + @Test(dataProvider="formatWithZoneWithChronology") + public void test_format_withZone_withChronology(Chronology overrideChrono, ZoneId overrideZone, TemporalAccessor temporal, String expected) { DateTimeFormatter test = new DateTimeFormatterBuilder() .optionalStart().appendValue(YEAR, 4).optionalEnd() .appendLiteral(':').optionalStart().appendValue(HOUR_OF_DAY, 2).optionalEnd() - .appendLiteral(':').optionalStart().appendOffsetId().optionalStart().appendZoneRegionId().optionalEnd().optionalEnd() + .appendLiteral(':').optionalStart().appendOffsetId().optionalEnd() + .appendLiteral(':').optionalStart().appendZoneId().optionalEnd() + .appendLiteral(':').optionalStart().appendChronologyId().optionalEnd() .toFormatter(Locale.ENGLISH) .withChronology(overrideChrono).withZone(overrideZone); - String result = test.format(temporal); - assertEquals(result, expected); + if (expected != null) { + String result = test.format(temporal); + assertEquals(result, expected); + } else { + try { + test.format(temporal); + fail("Formatting should have failed"); + } catch (DateTimeException ex) { + // expected + } + } } @Test - public void test_print_Temporal_simple() throws Exception { + public void test_format_withChronology_nonChronoFieldMapLink() { + TemporalAccessor temporal = new TemporalAccessor() { + @Override + public boolean isSupported(TemporalField field) { + return field == IsoFields.WEEK_BASED_YEAR; + } + @Override + public long getLong(TemporalField field) { + if (field == IsoFields.WEEK_BASED_YEAR) { + return 2345; + } + throw new UnsupportedTemporalTypeException("Unsupported field: " + field); + } + }; + DateTimeFormatter test = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR, 4) + .toFormatter(Locale.ENGLISH) + .withChronology(IsoChronology.INSTANCE); + String result = test.format(temporal); + assertEquals(result, "2345"); + } + + //----------------------------------------------------------------------- + @Test + public void test_format_TemporalAccessor_simple() { DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withSymbols(DateTimeFormatSymbols.STANDARD); String result = test.format(LocalDate.of(2008, 6, 30)); assertEquals(result, "ONE30"); } - @Test(expectedExceptions=DateTimeException.class) - public void test_print_Temporal_noSuchField() throws Exception { + @Test(expectedExceptions = DateTimeException.class) + public void test_format_TemporalAccessor_noSuchField() { DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withSymbols(DateTimeFormatSymbols.STANDARD); test.format(LocalTime.of(11, 30)); } - @Test(expectedExceptions=NullPointerException.class) - public void test_print_Temporal_null() throws Exception { + @Test(expectedExceptions = NullPointerException.class) + public void test_format_TemporalAccessor_null() { DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withSymbols(DateTimeFormatSymbols.STANDARD); test.format((TemporalAccessor) null); } diff --git a/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java b/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java index 0cb5cb1c7a3..cf2c3a1dad6 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java +++ b/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java @@ -98,7 +98,36 @@ public class TCKDateTimeFormatterBuilder { @Test public void test_toFormatter_empty() throws Exception { DateTimeFormatter f = builder.toFormatter(); - assertEquals(f.toString(), ""); + assertEquals(f.format(LocalDate.of(2012, 6, 30)), ""); + } + + //----------------------------------------------------------------------- + @Test + public void test_parseDefaulting_entireDate() { + DateTimeFormatter f = builder + .parseDefaulting(YEAR, 2012).parseDefaulting(MONTH_OF_YEAR, 6) + .parseDefaulting(DAY_OF_MONTH, 30).toFormatter(); + LocalDate parsed = f.parse("", LocalDate::from); // blank string can be parsed + assertEquals(parsed, LocalDate.of(2012, 6, 30)); + } + + @Test + public void test_parseDefaulting_yearOptionalMonthOptionalDay() { + DateTimeFormatter f = builder + .appendValue(YEAR) + .optionalStart().appendLiteral('-').appendValue(MONTH_OF_YEAR) + .optionalStart().appendLiteral('-').appendValue(DAY_OF_MONTH) + .optionalEnd().optionalEnd() + .parseDefaulting(MONTH_OF_YEAR, 1) + .parseDefaulting(DAY_OF_MONTH, 1).toFormatter(); + assertEquals(f.parse("2012", LocalDate::from), LocalDate.of(2012, 1, 1)); + assertEquals(f.parse("2012-6", LocalDate::from), LocalDate.of(2012, 6, 1)); + assertEquals(f.parse("2012-6-30", LocalDate::from), LocalDate.of(2012, 6, 30)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void test_parseDefaulting_null() { + builder.parseDefaulting(null, 1); } //----------------------------------------------------------------------- @@ -393,6 +422,7 @@ public class TCKDateTimeFormatterBuilder { {"''"}, {"'!'"}, {"!"}, + {"'#'"}, {"'hello_people,][)('"}, {"'hi'"}, @@ -418,17 +448,20 @@ public class TCKDateTimeFormatterBuilder { {"MMMM"}, {"MMMMM"}, + {"L"}, + {"LL"}, + {"LLL"}, + {"LLLL"}, + {"LLLLL"}, + {"D"}, {"DD"}, {"DDD"}, {"d"}, {"dd"}, - {"ddd"}, {"F"}, - {"FF"}, - {"FFF"}, {"Q"}, {"QQ"}, @@ -436,41 +469,48 @@ public class TCKDateTimeFormatterBuilder { {"QQQQ"}, {"QQQQQ"}, + {"q"}, + {"qq"}, + {"qqq"}, + {"qqqq"}, + {"qqqqq"}, + {"E"}, {"EE"}, {"EEE"}, {"EEEE"}, {"EEEEE"}, + {"e"}, + {"ee"}, + {"eee"}, + {"eeee"}, + {"eeeee"}, + + {"c"}, + {"ccc"}, + {"cccc"}, + {"ccccc"}, + {"a"}, - {"aa"}, - {"aaa"}, - {"aaaa"}, - {"aaaaa"}, {"H"}, {"HH"}, - {"HHH"}, {"K"}, {"KK"}, - {"KKK"}, {"k"}, {"kk"}, - {"kkk"}, {"h"}, {"hh"}, - {"hhh"}, {"m"}, {"mm"}, - {"mmm"}, {"s"}, {"ss"}, - {"sss"}, {"S"}, {"SS"}, @@ -523,8 +563,9 @@ public class TCKDateTimeFormatterBuilder { {"e"}, {"w"}, + {"ww"}, + {"W"}, {"W"}, - {"WW"}, }; } @@ -545,18 +586,40 @@ public class TCKDateTimeFormatterBuilder { {"{"}, {"}"}, {"{}"}, + {"#"}, {"]"}, {"yyyy]"}, {"yyyy]MM"}, {"yyyy[MM]]"}, + {"aa"}, + {"aaa"}, + {"aaaa"}, + {"aaaaa"}, + {"aaaaaa"}, {"MMMMMM"}, {"QQQQQQ"}, + {"qqqqqq"}, {"EEEEEE"}, - {"aaaaaa"}, - {"ZZZZ"}, + {"eeeeee"}, + {"cc"}, + {"cccccc"}, + {"ddd"}, + {"DDDD"}, + {"FF"}, + {"FFF"}, + {"hhh"}, + {"HHH"}, + {"kkk"}, + {"KKK"}, + {"mmm"}, + {"sss"}, + {"OO"}, + {"OOO"}, + {"OOOOO"}, {"XXXXXX"}, {"zzzzz"}, + {"ZZZZZZ"}, {"RO"}, @@ -571,9 +634,8 @@ public class TCKDateTimeFormatterBuilder { {"fa"}, {"fM"}, - {"ww"}, - {"ee"}, - {"WWW"}, + {"www"}, + {"WW"}, }; } @@ -588,9 +650,9 @@ public class TCKDateTimeFormatterBuilder { return new Object[][] { {"Q", date(2012, 2, 10), "1"}, {"QQ", date(2012, 2, 10), "01"}, -// {"QQQ", date(2012, 2, 10), "Q1"}, // TODO: data for quarters? -// {"QQQQ", date(2012, 2, 10), "Q1"}, -// {"QQQQQ", date(2012, 2, 10), "Q1"}, + {"QQQ", date(2012, 2, 10), "Q1"}, + {"QQQQ", date(2012, 2, 10), "1st quarter"}, + {"QQQQQ", date(2012, 2, 10), "1"}, }; } diff --git a/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java b/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java index 45548772f50..3ba962ad212 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java +++ b/jdk/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java @@ -77,16 +77,20 @@ import java.text.ParsePosition; import java.time.DateTimeException; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.Month; import java.time.Year; import java.time.YearMonth; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.chrono.Chronology; +import java.time.chrono.IsoChronology; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; +import java.time.format.FormatStyle; +import java.time.format.ResolverStyle; +import java.time.format.TextStyle; import java.time.temporal.IsoFields; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import java.time.temporal.TemporalQuery; @@ -110,27 +114,28 @@ public class TCKDateTimeFormatters { } //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) - public void test_print_nullCalendrical() { + @Test(expectedExceptions=NullPointerException.class) + public void test_format_nullTemporalAccessor() { DateTimeFormatter.ISO_DATE.format((TemporalAccessor) null); } //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_pattern_String() { DateTimeFormatter test = DateTimeFormatter.ofPattern("d MMM yyyy"); - assertEquals(test.toString(), "Value(DayOfMonth)' 'Text(MonthOfYear,SHORT)' 'Value(Year,4,19,EXCEEDS_PAD)"); + assertEquals(test.format(LocalDate.of(2012, 6, 30)), "30 " + + Month.JUNE.getDisplayName(TextStyle.SHORT, Locale.getDefault()) + " 2012"); assertEquals(test.getLocale(), Locale.getDefault()); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_pattern_String_invalid() { DateTimeFormatter.ofPattern("p"); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_pattern_String_null() { DateTimeFormatter.ofPattern(null); } @@ -138,28 +143,59 @@ public class TCKDateTimeFormatters { //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_pattern_StringLocale() { DateTimeFormatter test = DateTimeFormatter.ofPattern("d MMM yyyy", Locale.UK); - assertEquals(test.toString(), "Value(DayOfMonth)' 'Text(MonthOfYear,SHORT)' 'Value(Year,4,19,EXCEEDS_PAD)"); + assertEquals(test.format(LocalDate.of(2012, 6, 30)), "30 Jun 2012"); assertEquals(test.getLocale(), Locale.UK); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_pattern_StringLocale_invalid() { DateTimeFormatter.ofPattern("p", Locale.UK); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_pattern_StringLocale_nullPattern() { DateTimeFormatter.ofPattern(null, Locale.UK); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_pattern_StringLocale_nullLocale() { DateTimeFormatter.ofPattern("yyyy", null); } + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @Test + public void test_ofLocalizedDate_basics() { + assertEquals(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).getZone(), null); + assertEquals(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).getResolverStyle(), ResolverStyle.SMART); + } + + @Test + public void test_ofLocalizedTime_basics() { + assertEquals(DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL).getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL).getZone(), null); + assertEquals(DateTimeFormatter.ofLocalizedTime(FormatStyle.FULL).getResolverStyle(), ResolverStyle.SMART); + } + + @Test + public void test_ofLocalizedDateTime1_basics() { + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).getZone(), null); + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).getResolverStyle(), ResolverStyle.SMART); + } + + @Test + public void test_ofLocalizedDateTime2_basics() { + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.MEDIUM).getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.MEDIUM).getZone(), null); + assertEquals(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.MEDIUM).getResolverStyle(), ResolverStyle.SMART); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -183,7 +219,7 @@ public class TCKDateTimeFormatters { }; } - @Test(dataProvider="sample_isoLocalDate", groups={"tck"}) + @Test(dataProvider="sample_isoLocalDate") public void test_print_isoLocalDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -200,7 +236,7 @@ public class TCKDateTimeFormatters { } } - @Test(dataProvider="sample_isoLocalDate", groups={"tck"}) + @Test(dataProvider="sample_isoLocalDate") public void test_parse_isoLocalDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String input, Class invalid) { @@ -211,42 +247,49 @@ public class TCKDateTimeFormatters { } } - @Test(groups={"tck"}) + @Test public void test_parse_isoLocalDate_999999999() { Expected expected = createDate(999999999, 8, 6); assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("+999999999-08-06", new ParsePosition(0)), expected); assertEquals(LocalDate.parse("+999999999-08-06"), LocalDate.of(999999999, 8, 6)); } - @Test(groups={"tck"}) + @Test public void test_parse_isoLocalDate_1000000000() { Expected expected = createDate(1000000000, 8, 6); assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("+1000000000-08-06", new ParsePosition(0)), expected); } - @Test(expectedExceptions = DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions = DateTimeException.class) public void test_parse_isoLocalDate_1000000000_failedCreate() { LocalDate.parse("+1000000000-08-06"); } - @Test(groups={"tck"}) + @Test public void test_parse_isoLocalDate_M999999999() { Expected expected = createDate(-999999999, 8, 6); assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("-999999999-08-06", new ParsePosition(0)), expected); assertEquals(LocalDate.parse("-999999999-08-06"), LocalDate.of(-999999999, 8, 6)); } - @Test(groups={"tck"}) + @Test public void test_parse_isoLocalDate_M1000000000() { Expected expected = createDate(-1000000000, 8, 6); assertParseMatch(DateTimeFormatter.ISO_LOCAL_DATE.parseUnresolved("-1000000000-08-06", new ParsePosition(0)), expected); } - @Test(expectedExceptions = DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions = DateTimeException.class) public void test_parse_isoLocalDate_M1000000000_failedCreate() { LocalDate.parse("-1000000000-08-06"); } + @Test + public void test_isoLocalDate_basics() { + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE.getZone(), null); + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -270,7 +313,7 @@ public class TCKDateTimeFormatters { }; } - @Test(dataProvider="sample_isoOffsetDate", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetDate") public void test_print_isoOffsetDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -287,7 +330,7 @@ public class TCKDateTimeFormatters { } } - @Test(dataProvider="sample_isoOffsetDate", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetDate") public void test_parse_isoOffsetDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String input, Class invalid) { @@ -298,6 +341,13 @@ public class TCKDateTimeFormatters { } } + @Test + public void test_isoOffsetDate_basics() { + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE.getZone(), null); + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -321,7 +371,7 @@ public class TCKDateTimeFormatters { }; } - @Test(dataProvider="sample_isoDate", groups={"tck"}) + @Test(dataProvider="sample_isoDate") public void test_print_isoDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -338,7 +388,7 @@ public class TCKDateTimeFormatters { } } - @Test(dataProvider="sample_isoDate", groups={"tck"}) + @Test(dataProvider="sample_isoDate") public void test_parse_isoDate( Integer year, Integer month, Integer day, String offsetId, String zoneId, String input, Class invalid) { @@ -351,6 +401,13 @@ public class TCKDateTimeFormatters { } } + @Test + public void test_isoDate_basics() { + assertEquals(DateTimeFormatter.ISO_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_DATE.getZone(), null); + assertEquals(DateTimeFormatter.ISO_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -386,7 +443,7 @@ public class TCKDateTimeFormatters { }; } - @Test(dataProvider="sample_isoLocalTime", groups={"tck"}) + @Test(dataProvider="sample_isoLocalTime") public void test_print_isoLocalTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -403,7 +460,7 @@ public class TCKDateTimeFormatters { } } - @Test(dataProvider="sample_isoLocalTime", groups={"tck"}) + @Test(dataProvider="sample_isoLocalTime") public void test_parse_isoLocalTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String input, Class invalid) { @@ -414,6 +471,13 @@ public class TCKDateTimeFormatters { } } + @Test + public void test_isoLocalTime_basics() { + assertEquals(DateTimeFormatter.ISO_LOCAL_TIME.getChronology(), null); + assertEquals(DateTimeFormatter.ISO_LOCAL_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_LOCAL_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -449,7 +513,7 @@ public class TCKDateTimeFormatters { }; } - @Test(dataProvider="sample_isoOffsetTime", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetTime") public void test_print_isoOffsetTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -466,7 +530,7 @@ public class TCKDateTimeFormatters { } } - @Test(dataProvider="sample_isoOffsetTime", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetTime") public void test_parse_isoOffsetTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String input, Class invalid) { @@ -477,6 +541,13 @@ public class TCKDateTimeFormatters { } } + @Test + public void test_isoOffsetTime_basics() { + assertEquals(DateTimeFormatter.ISO_OFFSET_TIME.getChronology(), null); + assertEquals(DateTimeFormatter.ISO_OFFSET_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_OFFSET_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -512,7 +583,7 @@ public class TCKDateTimeFormatters { }; } - @Test(dataProvider="sample_isoTime", groups={"tck"}) + @Test(dataProvider="sample_isoTime") public void test_print_isoTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String expected, Class expectedEx) { @@ -529,7 +600,7 @@ public class TCKDateTimeFormatters { } } - @Test(dataProvider="sample_isoTime", groups={"tck"}) + @Test(dataProvider="sample_isoTime") public void test_parse_isoTime( Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, String input, Class invalid) { @@ -542,6 +613,13 @@ public class TCKDateTimeFormatters { } } + @Test + public void test_isoTime_basics() { + assertEquals(DateTimeFormatter.ISO_TIME.getChronology(), null); + assertEquals(DateTimeFormatter.ISO_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -585,7 +663,7 @@ public class TCKDateTimeFormatters { }; } - @Test(dataProvider="sample_isoLocalDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoLocalDateTime") public void test_print_isoLocalDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -603,7 +681,7 @@ public class TCKDateTimeFormatters { } } - @Test(dataProvider="sample_isoLocalDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoLocalDateTime") public void test_parse_isoLocalDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -614,6 +692,13 @@ public class TCKDateTimeFormatters { } } + @Test + public void test_isoLocalDateTime_basics() { + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE_TIME.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_LOCAL_DATE_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -657,7 +742,7 @@ public class TCKDateTimeFormatters { }; } - @Test(dataProvider="sample_isoOffsetDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetDateTime") public void test_print_isoOffsetDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -675,7 +760,7 @@ public class TCKDateTimeFormatters { } } - @Test(dataProvider="sample_isoOffsetDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoOffsetDateTime") public void test_parse_isoOffsetDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -687,6 +772,13 @@ public class TCKDateTimeFormatters { } } + @Test + public void test_isoOffsetDateTime_basics() { + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE_TIME.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_OFFSET_DATE_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -739,7 +831,7 @@ public class TCKDateTimeFormatters { }; } - @Test(dataProvider="sample_isoZonedDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoZonedDateTime") public void test_print_isoZonedDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -757,7 +849,7 @@ public class TCKDateTimeFormatters { } } - @Test(dataProvider="sample_isoZonedDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoZonedDateTime") public void test_parse_isoZonedDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -773,6 +865,13 @@ public class TCKDateTimeFormatters { } } + @Test + public void test_isoZonedDateTime_basics() { + assertEquals(DateTimeFormatter.ISO_ZONED_DATE_TIME.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_ZONED_DATE_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_ZONED_DATE_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -816,7 +915,7 @@ public class TCKDateTimeFormatters { }; } - @Test(dataProvider="sample_isoDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoDateTime") public void test_print_isoDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -834,7 +933,7 @@ public class TCKDateTimeFormatters { } } - @Test(dataProvider="sample_isoDateTime", groups={"tck"}) + @Test(dataProvider="sample_isoDateTime") public void test_parse_isoDateTime( Integer year, Integer month, Integer day, Integer hour, Integer min, Integer sec, Integer nano, String offsetId, String zoneId, @@ -851,28 +950,35 @@ public class TCKDateTimeFormatters { } } + @Test + public void test_isoDateTime_basics() { + assertEquals(DateTimeFormatter.ISO_DATE_TIME.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_DATE_TIME.getZone(), null); + assertEquals(DateTimeFormatter.ISO_DATE_TIME.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_print_isoOrdinalDate() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), null, null); assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "2008-155"); } - @Test(groups={"tck"}) + @Test public void test_print_isoOrdinalDate_offset() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "Z", null); assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "2008-155Z"); } - @Test(groups={"tck"}) + @Test public void test_print_isoOrdinalDate_zoned() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "+02:00", "Europe/Paris"); assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "2008-155+02:00"); } - @Test(groups={"tck"}) + @Test public void test_print_isoOrdinalDate_zoned_largeYear() { TemporalAccessor test = buildAccessor(LocalDateTime.of(123456, 6, 3, 11, 5, 30), "Z", null); assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.format(test), "+123456-155Z"); @@ -907,65 +1013,72 @@ public class TCKDateTimeFormatters { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_parse_isoOrdinalDate() { Expected expected = new Expected(YEAR, 2008, DAY_OF_YEAR, 123); assertParseMatch(DateTimeFormatter.ISO_ORDINAL_DATE.parseUnresolved("2008-123", new ParsePosition(0)), expected); } - @Test(groups={"tck"}) + @Test public void test_parse_isoOrdinalDate_largeYear() { Expected expected = new Expected(YEAR, 123456, DAY_OF_YEAR, 123); assertParseMatch(DateTimeFormatter.ISO_ORDINAL_DATE.parseUnresolved("+123456-123", new ParsePosition(0)), expected); } + @Test + public void test_isoOrdinalDate_basics() { + assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.getZone(), null); + assertEquals(DateTimeFormatter.ISO_ORDINAL_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_print_basicIsoDate() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), null, null); assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603"); } - @Test(groups={"tck"}) + @Test public void test_print_basicIsoDate_offset() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "Z", null); assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603Z"); } - @Test(groups={"tck"}) + @Test public void test_print_basicIsoDate_zoned() { TemporalAccessor test = buildAccessor(LocalDateTime.of(2008, 6, 3, 11, 5, 30), "+02:00", "Europe/Paris"); assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603+0200"); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_print_basicIsoDate_largeYear() { TemporalAccessor test = buildAccessor(LocalDateTime.of(123456, 6, 3, 11, 5, 30), "Z", null); DateTimeFormatter.BASIC_ISO_DATE.format(test); } - @Test(groups={"tck"}) + @Test public void test_print_basicIsoDate_fields() { TemporalAccessor test = buildAccessor(LocalDate.of(2008, 6, 3), null, null); assertEquals(DateTimeFormatter.BASIC_ISO_DATE.format(test), "20080603"); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_print_basicIsoDate_missingField() { TemporalAccessor test = YearMonth.of(2008, 6); DateTimeFormatter.BASIC_ISO_DATE.format(test); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_parse_basicIsoDate() { LocalDate expected = LocalDate.of(2008, 6, 3); assertEquals(DateTimeFormatter.BASIC_ISO_DATE.parse("20080603", LocalDate::from), expected); } - @Test(expectedExceptions=DateTimeParseException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeParseException.class) public void test_parse_basicIsoDate_largeYear() { try { LocalDate expected = LocalDate.of(123456, 6, 3); @@ -977,6 +1090,13 @@ public class TCKDateTimeFormatters { } } + @Test + public void test_basicIsoDate_basics() { + assertEquals(DateTimeFormatter.BASIC_ISO_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.BASIC_ISO_DATE.getZone(), null); + assertEquals(DateTimeFormatter.BASIC_ISO_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -1012,37 +1132,37 @@ public class TCKDateTimeFormatters { }; } - @Test(dataProvider="weekDate", groups={"tck"}) + @Test(dataProvider="weekDate") public void test_print_isoWeekDate(TemporalAccessor test, String expected) { assertEquals(DateTimeFormatter.ISO_WEEK_DATE.format(test), expected); } - @Test(groups={"tck"}) + @Test public void test_print_isoWeekDate_zoned_largeYear() { TemporalAccessor test = buildAccessor(LocalDateTime.of(123456, 6, 3, 11, 5, 30), "Z", null); assertEquals(DateTimeFormatter.ISO_WEEK_DATE.format(test), "+123456-W23-2Z"); } - @Test(groups={"tck"}) + @Test public void test_print_isoWeekDate_fields() { TemporalAccessor test = buildAccessor(LocalDate.of(2004, 1, 27), null, null); assertEquals(DateTimeFormatter.ISO_WEEK_DATE.format(test), "2004-W05-2"); } - @Test(expectedExceptions=DateTimeException.class, groups={"tck"}) + @Test(expectedExceptions=DateTimeException.class) public void test_print_isoWeekDate_missingField() { TemporalAccessor test = YearMonth.of(2008, 6); DateTimeFormatter.ISO_WEEK_DATE.format(test); } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_parse_weekDate() { LocalDate expected = LocalDate.of(2004, 1, 28); assertEquals(DateTimeFormatter.ISO_WEEK_DATE.parse("2004-W05-3", LocalDate::from), expected); } - @Test(groups={"tck"}) + @Test public void test_parse_weekDate_largeYear() { TemporalAccessor parsed = DateTimeFormatter.ISO_WEEK_DATE.parseUnresolved("+123456-W04-5", new ParsePosition(0)); assertEquals(parsed.getLong(IsoFields.WEEK_BASED_YEAR), 123456L); @@ -1050,6 +1170,23 @@ public class TCKDateTimeFormatters { assertEquals(parsed.getLong(DAY_OF_WEEK), 5L); } + @Test + public void test_isoWeekDate_basics() { + assertEquals(DateTimeFormatter.ISO_WEEK_DATE.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.ISO_WEEK_DATE.getZone(), null); + assertEquals(DateTimeFormatter.ISO_WEEK_DATE.getResolverStyle(), ResolverStyle.STRICT); + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @Test + public void test_isoInstant_basics() { + assertEquals(DateTimeFormatter.ISO_INSTANT.getChronology(), null); + assertEquals(DateTimeFormatter.ISO_INSTANT.getZone(), null); + assertEquals(DateTimeFormatter.ISO_INSTANT.getResolverStyle(), ResolverStyle.STRICT); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -1063,24 +1200,31 @@ public class TCKDateTimeFormatters { }; } - @Test(groups={"tck"}, dataProvider="rfc") + @Test(dataProvider="rfc") public void test_print_rfc1123(LocalDateTime base, String offsetId, String expected) { TemporalAccessor test = buildAccessor(base, offsetId, null); assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.format(test), expected); } - @Test(groups={"tck"}, dataProvider="rfc") + @Test(dataProvider="rfc") public void test_print_rfc1123_french(LocalDateTime base, String offsetId, String expected) { TemporalAccessor test = buildAccessor(base, offsetId, null); assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.withLocale(Locale.FRENCH).format(test), expected); } - @Test(groups={"tck"}, expectedExceptions=DateTimeException.class) + @Test(expectedExceptions=DateTimeException.class) public void test_print_rfc1123_missingField() { TemporalAccessor test = YearMonth.of(2008, 6); DateTimeFormatter.RFC_1123_DATE_TIME.format(test); } + @Test + public void test_rfc1123_basics() { + assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.getChronology(), IsoChronology.INSTANCE); + assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.getZone(), null); + assertEquals(DateTimeFormatter.RFC_1123_DATE_TIME.getResolverStyle(), ResolverStyle.SMART); + } + //----------------------------------------------------------------------- //----------------------------------------------------------------------- //----------------------------------------------------------------------- @@ -1204,13 +1348,11 @@ public class TCKDateTimeFormatters { assertEquals(parsed.isSupported(field), true); parsed.getLong(field); } - assertEquals(parsed.query(Queries.chronology()), expected.chrono); - assertEquals(parsed.query(Queries.zoneId()), expected.zone); + assertEquals(parsed.query(TemporalQuery.chronology()), expected.chrono); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected.zone); } //------------------------------------------------------------------------- - Map fields = new HashMap<>(); - ZoneId zoneId; static class MockAccessor implements TemporalAccessor { Map fields = new HashMap<>(); ZoneId zoneId; @@ -1272,7 +1414,7 @@ public class TCKDateTimeFormatters { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == Queries.zoneId()) { + if (query == TemporalQuery.zoneId()) { return (R) zoneId; } return TemporalAccessor.super.query(query); diff --git a/jdk/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java b/jdk/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java new file mode 100644 index 00000000000..8b6c1340688 --- /dev/null +++ b/jdk/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java @@ -0,0 +1,522 @@ +/* + * 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. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file: + * + * Copyright (c) 2008-2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package tck.java.time.format; + +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH; +import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR; +import static java.time.temporal.ChronoField.AMPM_OF_DAY; +import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_AMPM; +import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_DAY; +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.DAY_OF_WEEK; +import static java.time.temporal.ChronoField.DAY_OF_YEAR; +import static java.time.temporal.ChronoField.EPOCH_DAY; +import static java.time.temporal.ChronoField.ERA; +import static java.time.temporal.ChronoField.HOUR_OF_AMPM; +import static java.time.temporal.ChronoField.HOUR_OF_DAY; +import static java.time.temporal.ChronoField.MICRO_OF_DAY; +import static java.time.temporal.ChronoField.MICRO_OF_SECOND; +import static java.time.temporal.ChronoField.MILLI_OF_DAY; +import static java.time.temporal.ChronoField.MILLI_OF_SECOND; +import static java.time.temporal.ChronoField.MINUTE_OF_DAY; +import static java.time.temporal.ChronoField.MINUTE_OF_HOUR; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.NANO_OF_DAY; +import static java.time.temporal.ChronoField.NANO_OF_SECOND; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; +import static java.time.temporal.ChronoField.SECOND_OF_DAY; +import static java.time.temporal.ChronoField.SECOND_OF_MINUTE; +import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static org.testng.Assert.assertEquals; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.temporal.IsoFields; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test parse resolving. + */ +@Test +public class TCKDateTimeParseResolver { + // TODO: tests with weird TenporalField implementations + // TODO: tests with non-ISO chronologies + + //----------------------------------------------------------------------- + @DataProvider(name="resolveOneNoChange") + Object[][] data_resolveOneNoChange() { + return new Object[][]{ + {YEAR, 2012}, + {MONTH_OF_YEAR, 8}, + {DAY_OF_MONTH, 7}, + {DAY_OF_YEAR, 6}, + {DAY_OF_WEEK, 5}, + }; + } + + @Test(dataProvider="resolveOneNoChange") + public void test_resolveOneNoChange(TemporalField field1, long value1) { + String str = Long.toString(value1); + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.isSupported(field1), true); + assertEquals(accessor.getLong(field1), value1); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveTwoNoChange") + Object[][] data_resolveTwoNoChange() { + return new Object[][]{ + {YEAR, 2012, MONTH_OF_YEAR, 5}, + {YEAR, 2012, DAY_OF_MONTH, 5}, + {YEAR, 2012, DAY_OF_WEEK, 5}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5}, + {YEAR, 2012, ALIGNED_WEEK_OF_MONTH, 5}, + {YEAR, 2012, IsoFields.QUARTER_OF_YEAR, 3}, + {YEAR, 2012, MINUTE_OF_HOUR, 5}, + {YEAR, 2012, SECOND_OF_MINUTE, 5}, + {YEAR, 2012, NANO_OF_SECOND, 5}, + + {MONTH_OF_YEAR, 5, DAY_OF_MONTH, 5}, + {MONTH_OF_YEAR, 5, DAY_OF_WEEK, 5}, + {MONTH_OF_YEAR, 5, ALIGNED_WEEK_OF_YEAR, 5}, + {MONTH_OF_YEAR, 5, ALIGNED_WEEK_OF_MONTH, 5}, + {MONTH_OF_YEAR, 3, IsoFields.QUARTER_OF_YEAR, 5}, + {MONTH_OF_YEAR, 5, MINUTE_OF_HOUR, 5}, + {MONTH_OF_YEAR, 5, SECOND_OF_MINUTE, 5}, + {MONTH_OF_YEAR, 5, NANO_OF_SECOND, 5}, + }; + } + + @Test(dataProvider="resolveTwoNoChange") + public void test_resolveTwoNoChange(TemporalField field1, long value1, TemporalField field2, long value2) { + String str = value1 + " " + value2; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).toFormatter(); + TemporalAccessor accessor = f.parse(str); + + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.isSupported(field1), true); + assertEquals(accessor.isSupported(field2), true); + assertEquals(accessor.getLong(field1), value1); + assertEquals(accessor.getLong(field2), value2); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveThreeNoChange") + Object[][] data_resolveThreeNoChange() { + return new Object[][]{ + {YEAR, 2012, MONTH_OF_YEAR, 5, DAY_OF_WEEK, 5}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5, DAY_OF_MONTH, 5}, + {YEAR, 2012, ALIGNED_WEEK_OF_MONTH, 5, DAY_OF_MONTH, 5}, + {YEAR, 2012, MONTH_OF_YEAR, 5, DAY_OF_WEEK, 5}, + {ERA, 1, MONTH_OF_YEAR, 5, DAY_OF_MONTH, 5}, + {MONTH_OF_YEAR, 1, DAY_OF_MONTH, 5, IsoFields.QUARTER_OF_YEAR, 3}, + {HOUR_OF_DAY, 1, SECOND_OF_MINUTE, 5, NANO_OF_SECOND, 5}, + {MINUTE_OF_HOUR, 1, SECOND_OF_MINUTE, 5, NANO_OF_SECOND, 5}, + }; + } + + @Test(dataProvider="resolveThreeNoChange") + public void test_resolveThreeNoChange(TemporalField field1, long value1, TemporalField field2, long value2, TemporalField field3, long value3) { + String str = value1 + " " + value2 + " " + value3; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).appendLiteral(' ') + .appendValue(field3).toFormatter(); + TemporalAccessor accessor = f.parse(str); + + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.isSupported(field1), true); + assertEquals(accessor.isSupported(field2), true); + assertEquals(accessor.isSupported(field3), true); + assertEquals(accessor.getLong(field1), value1); + assertEquals(accessor.getLong(field2), value2); + assertEquals(accessor.getLong(field3), value3); + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name="resolveOneToField") + Object[][] data_resolveOneToField() { + return new Object[][]{ + {YEAR_OF_ERA, 2012, YEAR, 2012L, null, null}, + {PROLEPTIC_MONTH, 2012 * 12L + (3 - 1), YEAR, 2012L, MONTH_OF_YEAR, 3L}, + + {CLOCK_HOUR_OF_AMPM, 8, HOUR_OF_AMPM, 8L, null, null}, + {CLOCK_HOUR_OF_AMPM, 12, HOUR_OF_AMPM, 0L, null, null}, + {MICRO_OF_SECOND, 12, NANO_OF_SECOND, 12_000L, null, null}, + {MILLI_OF_SECOND, 12, NANO_OF_SECOND, 12_000_000L, null, null}, + }; + } + + @Test(dataProvider="resolveOneToField") + public void test_resolveOneToField(TemporalField field1, long value1, + TemporalField expectedField1, Long expectedValue1, + TemporalField expectedField2, Long expectedValue2) { + String str = Long.toString(value1); + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + if (expectedField1 != null) { + assertEquals(accessor.isSupported(expectedField1), true); + assertEquals(accessor.getLong(expectedField1), expectedValue1.longValue()); + } + if (expectedField2 != null) { + assertEquals(accessor.isSupported(expectedField2), true); + assertEquals(accessor.getLong(expectedField2), expectedValue2.longValue()); + } + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveOneToDate") + Object[][] data_resolveOneToDate() { + return new Object[][]{ + {EPOCH_DAY, 32, LocalDate.of(1970, 2, 2)}, + }; + } + + @Test(dataProvider="resolveOneToDate") + public void test_resolveOneToDate(TemporalField field1, long value1, LocalDate expectedDate) { + String str = Long.toString(value1); + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveOneToTime") + Object[][] data_resolveOneToTime() { + return new Object[][]{ + {HOUR_OF_DAY, 8, LocalTime.of(8, 0)}, + {CLOCK_HOUR_OF_DAY, 8, LocalTime.of(8, 0)}, + {CLOCK_HOUR_OF_DAY, 24, LocalTime.of(0, 0)}, + {MINUTE_OF_DAY, 650, LocalTime.of(10, 50)}, + {SECOND_OF_DAY, 3600 + 650, LocalTime.of(1, 10, 50)}, + {MILLI_OF_DAY, (3600 + 650) * 1_000L + 2, LocalTime.of(1, 10, 50, 2_000_000)}, + {MICRO_OF_DAY, (3600 + 650) * 1_000_000L + 2, LocalTime.of(1, 10, 50, 2_000)}, + {NANO_OF_DAY, (3600 + 650) * 1_000_000_000L + 2, LocalTime.of(1, 10, 50, 2)}, + }; + } + + @Test(dataProvider="resolveOneToTime") + public void test_resolveOneToTime(TemporalField field1, long value1, LocalTime expectedTime) { + String str = Long.toString(value1); + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), expectedTime); + } + + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + //----------------------------------------------------------------------- + @DataProvider(name="resolveTwoToField") + Object[][] data_resolveTwoToField() { + return new Object[][]{ + // cross-check + {PROLEPTIC_MONTH, 2012 * 12L + (3 - 1), YEAR, 2012, YEAR, 2012L, MONTH_OF_YEAR, 3L}, + {PROLEPTIC_MONTH, 2012 * 12L + (3 - 1), YEAR_OF_ERA, 2012, YEAR, 2012L, MONTH_OF_YEAR, 3L}, + {PROLEPTIC_MONTH, 2012 * 12L + (3 - 1), ERA, 1, YEAR, 2012L, MONTH_OF_YEAR, 3L}, + {PROLEPTIC_MONTH, (3 - 1), YEAR, 0, YEAR, 0L, MONTH_OF_YEAR, 3L}, + {PROLEPTIC_MONTH, (3 - 1), YEAR_OF_ERA, 1, YEAR, 0L, MONTH_OF_YEAR, 3L}, + {PROLEPTIC_MONTH, (3 - 1), ERA, 0, YEAR, 0L, MONTH_OF_YEAR, 3L}, + }; + } + + @Test(dataProvider="resolveTwoToField") + public void test_resolveTwoToField(TemporalField field1, long value1, + TemporalField field2, long value2, + TemporalField expectedField1, Long expectedValue1, + TemporalField expectedField2, Long expectedValue2) { + String str = value1 + " " + value2; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + if (expectedField1 != null) { + assertEquals(accessor.isSupported(expectedField1), true); + assertEquals(accessor.getLong(expectedField1), expectedValue1.longValue()); + } + if (expectedField2 != null) { + assertEquals(accessor.isSupported(expectedField2), true); + assertEquals(accessor.getLong(expectedField2), expectedValue2.longValue()); + } + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveTwoToDate") + Object[][] data_resolveTwoToDate() { + return new Object[][]{ + // merge + {YEAR, 2012, DAY_OF_YEAR, 32, LocalDate.of(2012, 2, 1)}, + {YEAR_OF_ERA, 2012, DAY_OF_YEAR, 32, LocalDate.of(2012, 2, 1)}, + + // merge + {PROLEPTIC_MONTH, 2012 * 12 + (2 - 1), DAY_OF_MONTH, 25, LocalDate.of(2012, 2, 25)}, + {PROLEPTIC_MONTH, 2012 * 12 + (2 - 1), DAY_OF_YEAR, 56, LocalDate.of(2012, 2, 25)}, + + // cross-check + {EPOCH_DAY, 32, ERA, 1, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, -146097 * 5L, ERA, 0, LocalDate.of(1970 - (400 * 5), 1, 1)}, + {EPOCH_DAY, 32, YEAR, 1970, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, -146097 * 5L, YEAR, 1970 - (400 * 5), LocalDate.of(1970 - (400 * 5), 1, 1)}, + {EPOCH_DAY, 32, YEAR_OF_ERA, 1970, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, -146097 * 5L, YEAR_OF_ERA, 1 - (1970 - (400 * 5)), LocalDate.of(1970 - (400 * 5), 1, 1)}, + {EPOCH_DAY, 32, MONTH_OF_YEAR, 2, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, 32, DAY_OF_YEAR, 33, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, 32, DAY_OF_MONTH, 2, LocalDate.of(1970, 2, 2)}, + {EPOCH_DAY, 32, DAY_OF_WEEK, 1, LocalDate.of(1970, 2, 2)}, + }; + } + + @Test(dataProvider="resolveTwoToDate") + public void test_resolveTwoToDate(TemporalField field1, long value1, + TemporalField field2, long value2, + LocalDate expectedDate) { + String str = value1 + " " + value2; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveTwoToTime") + Object[][] data_resolveTwoToTime() { + return new Object[][]{ + // merge + {HOUR_OF_DAY, 8, MINUTE_OF_HOUR, 6, LocalTime.of(8, 6)}, + + // merge + {AMPM_OF_DAY, 0, HOUR_OF_AMPM, 5, LocalTime.of(5, 0)}, + {AMPM_OF_DAY, 1, HOUR_OF_AMPM, 5, LocalTime.of(17, 0)}, + {AMPM_OF_DAY, 0, CLOCK_HOUR_OF_AMPM, 5, LocalTime.of(5, 0)}, + {AMPM_OF_DAY, 1, CLOCK_HOUR_OF_AMPM, 5, LocalTime.of(17, 0)}, + {AMPM_OF_DAY, 0, HOUR_OF_DAY, 5, LocalTime.of(5, 0)}, + {AMPM_OF_DAY, 1, HOUR_OF_DAY, 17, LocalTime.of(17, 0)}, + {AMPM_OF_DAY, 0, CLOCK_HOUR_OF_DAY, 5, LocalTime.of(5, 0)}, + {AMPM_OF_DAY, 1, CLOCK_HOUR_OF_DAY, 17, LocalTime.of(17, 0)}, + + // merge + {CLOCK_HOUR_OF_DAY, 8, MINUTE_OF_HOUR, 6, LocalTime.of(8, 6)}, + {CLOCK_HOUR_OF_DAY, 24, MINUTE_OF_HOUR, 6, LocalTime.of(0, 6)}, + // cross-check + {CLOCK_HOUR_OF_DAY, 8, HOUR_OF_DAY, 8, LocalTime.of(8, 0)}, + {CLOCK_HOUR_OF_DAY, 8, CLOCK_HOUR_OF_AMPM, 8, LocalTime.of(8, 0)}, + {CLOCK_HOUR_OF_DAY, 20, CLOCK_HOUR_OF_AMPM, 8, LocalTime.of(20, 0)}, + {CLOCK_HOUR_OF_DAY, 8, AMPM_OF_DAY, 0, LocalTime.of(8, 0)}, + {CLOCK_HOUR_OF_DAY, 20, AMPM_OF_DAY, 1, LocalTime.of(20, 0)}, + + // merge + {MINUTE_OF_DAY, 650, SECOND_OF_MINUTE, 8, LocalTime.of(10, 50, 8)}, + // cross-check + {MINUTE_OF_DAY, 650, HOUR_OF_DAY, 10, LocalTime.of(10, 50)}, + {MINUTE_OF_DAY, 650, CLOCK_HOUR_OF_DAY, 10, LocalTime.of(10, 50)}, + {MINUTE_OF_DAY, 650, CLOCK_HOUR_OF_AMPM, 10, LocalTime.of(10, 50)}, + {MINUTE_OF_DAY, 650, AMPM_OF_DAY, 0, LocalTime.of(10, 50)}, + {MINUTE_OF_DAY, 650, MINUTE_OF_HOUR, 50, LocalTime.of(10, 50)}, + + // merge + {SECOND_OF_DAY, 3600 + 650, MILLI_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2_000_000)}, + {SECOND_OF_DAY, 3600 + 650, MICRO_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2_000)}, + {SECOND_OF_DAY, 3600 + 650, NANO_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2)}, + // cross-check + {SECOND_OF_DAY, 3600 + 650, HOUR_OF_DAY, 1, LocalTime.of(1, 10, 50)}, + {SECOND_OF_DAY, 3600 + 650, MINUTE_OF_HOUR, 10, LocalTime.of(1, 10, 50)}, + {SECOND_OF_DAY, 3600 + 650, SECOND_OF_MINUTE, 50, LocalTime.of(1, 10, 50)}, + + // merge + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, MICRO_OF_SECOND, 2_004, LocalTime.of(1, 10, 50, 2_004_000)}, + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, NANO_OF_SECOND, 2_000_004, LocalTime.of(1, 10, 50, 2_000_004)}, + // cross-check + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, HOUR_OF_DAY, 1, LocalTime.of(1, 10, 50, 2_000_000)}, + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, MINUTE_OF_HOUR, 10, LocalTime.of(1, 10, 50, 2_000_000)}, + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, SECOND_OF_MINUTE, 50, LocalTime.of(1, 10, 50, 2_000_000)}, + {MILLI_OF_DAY, (3600 + 650) * 1000L + 2, MILLI_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2_000_000)}, + + // merge + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, NANO_OF_SECOND, 2_004, LocalTime.of(1, 10, 50, 2_004)}, + // cross-check + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, HOUR_OF_DAY, 1, LocalTime.of(1, 10, 50, 2_000)}, + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, MINUTE_OF_HOUR, 10, LocalTime.of(1, 10, 50, 2_000)}, + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, SECOND_OF_MINUTE, 50, LocalTime.of(1, 10, 50, 2_000)}, + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, MILLI_OF_SECOND, 0, LocalTime.of(1, 10, 50, 2_000)}, + {MICRO_OF_DAY, (3600 + 650) * 1000_000L + 2, MICRO_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2_000)}, + + // cross-check + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, HOUR_OF_DAY, 1, LocalTime.of(1, 10, 50, 2)}, + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, MINUTE_OF_HOUR, 10, LocalTime.of(1, 10, 50, 2)}, + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, SECOND_OF_MINUTE, 50, LocalTime.of(1, 10, 50, 2)}, + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, MILLI_OF_SECOND, 0, LocalTime.of(1, 10, 50, 2)}, + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, MICRO_OF_SECOND, 0, LocalTime.of(1, 10, 50, 2)}, + {NANO_OF_DAY, (3600 + 650) * 1000_000_000L + 2, NANO_OF_SECOND, 2, LocalTime.of(1, 10, 50, 2)}, + }; + } + + @Test(dataProvider="resolveTwoToTime") + public void test_resolveTwoToTime(TemporalField field1, long value1, + TemporalField field2, long value2, + LocalTime expectedTime) { + String str = value1 + " " + value2; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), null); + assertEquals(accessor.query(TemporalQuery.localTime()), expectedTime); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveThreeToDate") + Object[][] data_resolveThreeToDate() { + return new Object[][]{ + // merge + {YEAR, 2012, MONTH_OF_YEAR, 2, DAY_OF_MONTH, 1, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5, ALIGNED_DAY_OF_WEEK_IN_YEAR, 4, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5, DAY_OF_WEEK, 3, LocalDate.of(2012, 2, 1)}, + + // cross-check + {YEAR, 2012, DAY_OF_YEAR, 32, DAY_OF_MONTH, 1, LocalDate.of(2012, 2, 1)}, + {YEAR_OF_ERA, 2012, DAY_OF_YEAR, 32, DAY_OF_MONTH, 1, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, DAY_OF_YEAR, 32, DAY_OF_WEEK, 3, LocalDate.of(2012, 2, 1)}, + {PROLEPTIC_MONTH, 2012 * 12 + (2 - 1), DAY_OF_MONTH, 25, DAY_OF_WEEK, 6, LocalDate.of(2012, 2, 25)}, + }; + } + + @Test(dataProvider="resolveThreeToDate") + public void test_resolveThreeToDate(TemporalField field1, long value1, + TemporalField field2, long value2, + TemporalField field3, long value3, + LocalDate expectedDate) { + String str = value1 + " " + value2 + " " + value3; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).appendLiteral(' ') + .appendValue(field3).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + } + + //----------------------------------------------------------------------- + @DataProvider(name="resolveFourToDate") + Object[][] data_resolveFourToDate() { + return new Object[][]{ + // merge + {YEAR, 2012, MONTH_OF_YEAR, 2, ALIGNED_WEEK_OF_MONTH, 1, ALIGNED_DAY_OF_WEEK_IN_MONTH, 1, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, MONTH_OF_YEAR, 2, ALIGNED_WEEK_OF_MONTH, 1, DAY_OF_WEEK, 3, LocalDate.of(2012, 2, 1)}, + + // cross-check + {YEAR, 2012, MONTH_OF_YEAR, 2, DAY_OF_MONTH, 1, DAY_OF_WEEK, 3, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5, ALIGNED_DAY_OF_WEEK_IN_YEAR, 4, DAY_OF_WEEK, 3, LocalDate.of(2012, 2, 1)}, + {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5, DAY_OF_WEEK, 3, DAY_OF_MONTH, 1, LocalDate.of(2012, 2, 1)}, + }; + } + + @Test(dataProvider="resolveFourToDate") + public void test_resolveFourToDate(TemporalField field1, long value1, + TemporalField field2, long value2, + TemporalField field3, long value3, + TemporalField field4, long value4, + LocalDate expectedDate) { + String str = value1 + " " + value2 + " " + value3 + " " + value4; + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(field1).appendLiteral(' ') + .appendValue(field2).appendLiteral(' ') + .appendValue(field3).appendLiteral(' ') + .appendValue(field4).toFormatter(); + + TemporalAccessor accessor = f.parse(str); + assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQuery.localTime()), null); + } + +} diff --git a/jdk/test/java/time/tck/java/time/format/TCKDateTimeTextPrinting.java b/jdk/test/java/time/tck/java/time/format/TCKDateTimeTextPrinting.java index d436fb41ad4..52f51369a0c 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKDateTimeTextPrinting.java +++ b/jdk/test/java/time/tck/java/time/format/TCKDateTimeTextPrinting.java @@ -59,21 +59,21 @@ */ package tck.java.time.format; -import java.time.format.*; - import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static org.testng.Assert.assertEquals; +import java.time.LocalDateTime; +import java.time.Month; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.TextStyle; +import java.time.temporal.TemporalField; import java.util.HashMap; import java.util.Locale; import java.util.Map; -import java.time.LocalDateTime; -import java.time.Month; -import java.time.temporal.TemporalField; - import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -86,7 +86,7 @@ public class TCKDateTimeTextPrinting { private DateTimeFormatterBuilder builder; - @BeforeMethod(groups={"tck"}) + @BeforeMethod public void setUp() { builder = new DateTimeFormatterBuilder(); } @@ -135,7 +135,7 @@ public class TCKDateTimeTextPrinting { }; } - @Test(dataProvider="printText", groups={"tck"}) + @Test(dataProvider="printText") public void test_appendText2arg_format(TemporalField field, TextStyle style, int value, String expected) throws Exception { DateTimeFormatter f = builder.appendText(field, style).toFormatter(Locale.ENGLISH); LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0); @@ -144,7 +144,7 @@ public class TCKDateTimeTextPrinting { assertEquals(text, expected); } - @Test(dataProvider="printText", groups={"tck"}) + @Test(dataProvider="printText") public void test_appendText1arg_format(TemporalField field, TextStyle style, int value, String expected) throws Exception { if (style == TextStyle.FULL) { DateTimeFormatter f = builder.appendText(field).toFormatter(Locale.ENGLISH); @@ -156,7 +156,7 @@ public class TCKDateTimeTextPrinting { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_print_appendText2arg_french_long() throws Exception { DateTimeFormatter f = builder.appendText(MONTH_OF_YEAR, TextStyle.FULL).toFormatter(Locale.FRENCH); LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0); @@ -164,7 +164,7 @@ public class TCKDateTimeTextPrinting { assertEquals(text, "janvier"); } - @Test(groups={"tck"}) + @Test public void test_print_appendText2arg_french_short() throws Exception { DateTimeFormatter f = builder.appendText(MONTH_OF_YEAR, TextStyle.SHORT).toFormatter(Locale.FRENCH); LocalDateTime dt = LocalDateTime.of(2010, 1, 1, 0, 0); @@ -173,7 +173,7 @@ public class TCKDateTimeTextPrinting { } //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_appendTextMap() throws Exception { Map map = new HashMap(); map.put(1L, "JNY"); @@ -196,7 +196,7 @@ public class TCKDateTimeTextPrinting { } } - @Test(groups={"tck"}) + @Test public void test_appendTextMap_DOM() throws Exception { Map map = new HashMap(); map.put(1L, "1st"); @@ -210,7 +210,7 @@ public class TCKDateTimeTextPrinting { assertEquals(f.format(dt.withDayOfMonth(3)), "3rd"); } - @Test(groups={"tck"}) + @Test public void test_appendTextMapIncomplete() throws Exception { Map map = new HashMap(); map.put(1L, "JNY"); diff --git a/jdk/test/java/time/tck/java/time/format/TCKLocalizedFieldParser.java b/jdk/test/java/time/tck/java/time/format/TCKLocalizedFieldParser.java index 0d7975a8310..eef99fc7add 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKLocalizedFieldParser.java +++ b/jdk/test/java/time/tck/java/time/format/TCKLocalizedFieldParser.java @@ -59,8 +59,7 @@ */ package tck.java.time.format; -import static java.time.temporal.ChronoField.MONTH_OF_YEAR; -import static java.time.temporal.ChronoField.YEAR; +import static java.time.temporal.ChronoField.YEAR_OF_ERA; import static org.testng.Assert.assertEquals; import java.text.ParsePosition; @@ -78,7 +77,7 @@ import test.java.time.format.AbstractTestPrinterParser; /** * Test TCKLocalizedFieldParser. */ -@Test(groups={"tck"}) +@Test public class TCKLocalizedFieldParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- @@ -86,13 +85,16 @@ public class TCKLocalizedFieldParser extends AbstractTestPrinterParser { Object[][] provider_fieldPatterns() { return new Object[][] { {"e", "6", 0, 1, 6}, - {"w", "3", 0, 1, 3}, - {"W", "29", 0, 2, 29}, - {"WW", "29", 0, 2, 29}, + {"W", "3", 0, 1, 3}, + {"w", "29", 0, 2, 29}, + {"ww", "29", 0, 2, 29}, + {"Y", "2013", 0, 4, 2013}, + {"YY", "13", 0, 2, 2013}, + {"YYYY", "2013", 0, 4, 2013}, }; } - @Test(dataProvider="FieldPatterns",groups={"tck"}) + @Test(dataProvider="FieldPatterns") public void test_parse_textField(String pattern, String text, int pos, int expectedPos, long expectedValue) { WeekFields weekDef = WeekFields.of(locale); TemporalField field = null; @@ -101,10 +103,13 @@ public class TCKLocalizedFieldParser extends AbstractTestPrinterParser { field = weekDef.dayOfWeek(); break; case 'w': - field = weekDef.weekOfMonth(); + field = weekDef.weekOfWeekBasedYear(); break; case 'W': - field = weekDef.weekOfYear(); + field = weekDef.weekOfMonth(); + break; + case 'Y': + field = weekDef.weekBasedYear(); break; default: throw new IllegalStateException("bad format letter from pattern"); @@ -123,27 +128,24 @@ public class TCKLocalizedFieldParser extends AbstractTestPrinterParser { } } - //----------------------------------------------------------------------- - @DataProvider(name="LocalDatePatterns") + //----------------------------------------------------------------------- + @DataProvider(name="LocalWeekMonthYearPatterns") Object[][] provider_patternLocalDate() { return new Object[][] { - {"e w M y", "1 1 1 2012", 0, 10, LocalDate.of(2012, 1, 1)}, - {"e w M y", "1 2 1 2012", 0, 10, LocalDate.of(2012, 1, 8)}, - {"e w M y", "2 2 1 2012", 0, 10, LocalDate.of(2012, 1, 9)}, - {"e w M y", "3 2 1 2012", 0, 10, LocalDate.of(2012, 1, 10)}, - {"e w M y", "1 3 1 2012", 0, 10, LocalDate.of(2012, 1, 15)}, - {"e w M y", "2 3 1 2012", 0, 10, LocalDate.of(2012, 1, 16)}, - {"e w M y", "6 2 1 2012", 0, 10, LocalDate.of(2012, 1, 13)}, - {"e w M y", "6 2 7 2012", 0, 10, LocalDate.of(2012, 7, 13)}, - {"e W y", "6 29 2012", 0, 9, LocalDate.of(2012, 7, 20)}, - {"'Date: 'y-MM', day-of-week: 'e', week-of-month: 'w", + {"e W M y", "1 1 1 2012", 0, 10, LocalDate.of(2012, 1, 1)}, + {"e W M y", "1 2 1 2012", 0, 10, LocalDate.of(2012, 1, 8)}, + {"e W M y", "2 2 1 2012", 0, 10, LocalDate.of(2012, 1, 9)}, + {"e W M y", "3 2 1 2012", 0, 10, LocalDate.of(2012, 1, 10)}, + {"e W M y", "1 3 1 2012", 0, 10, LocalDate.of(2012, 1, 15)}, + {"e W M y", "2 3 1 2012", 0, 10, LocalDate.of(2012, 1, 16)}, + {"e W M y", "6 2 1 2012", 0, 10, LocalDate.of(2012, 1, 13)}, + {"e W M y", "6 2 7 2012", 0, 10, LocalDate.of(2012, 7, 13)}, + {"'Date: 'y-MM', day-of-week: 'e', week-of-month: 'W", "Date: 2012-07, day-of-week: 6, week-of-month: 3", 0, 47, LocalDate.of(2012, 7, 20)}, - {"'Date: 'y', day-of-week: 'e', week-of-year: 'W", - "Date: 2012, day-of-week: 6, week-of-year: 29", 0, 44, LocalDate.of(2012, 7, 20)}, }; } - @Test(dataProvider="LocalDatePatterns",groups={"tck"}) + @Test(dataProvider="LocalWeekMonthYearPatterns") public void test_parse_textLocalDate(String pattern, String text, int pos, int expectedPos, LocalDate expectedValue) { ParsePosition ppos = new ParsePosition(pos); DateTimeFormatterBuilder b = new DateTimeFormatterBuilder().appendPattern(pattern); @@ -153,7 +155,7 @@ public class TCKLocalizedFieldParser extends AbstractTestPrinterParser { assertEquals(ppos.getErrorIndex(), expectedPos); } else { assertEquals(ppos.getIndex(), expectedPos, "Incorrect ending parse position"); - assertEquals(parsed.isSupported(YEAR), true); + assertEquals(parsed.isSupported(YEAR_OF_ERA), true); assertEquals(parsed.isSupported(WeekFields.of(locale).dayOfWeek()), true); assertEquals(parsed.isSupported(WeekFields.of(locale).weekOfMonth()) || parsed.isSupported(WeekFields.of(locale).weekOfYear()), true); @@ -163,4 +165,41 @@ public class TCKLocalizedFieldParser extends AbstractTestPrinterParser { } } + //----------------------------------------------------------------------- + @DataProvider(name="LocalWeekBasedYearPatterns") + Object[][] provider_patternLocalWeekBasedYearDate() { + return new Object[][] { + //{"w Y", "29 2012", 0, 7, LocalDate.of(2012, 7, 20)}, // Default lenient dayOfWeek not supported + {"e w Y", "6 29 2012", 0, 9, LocalDate.of(2012, 7, 20)}, + {"'Date: 'Y', day-of-week: 'e', week-of-year: 'w", + "Date: 2012, day-of-week: 6, week-of-year: 29", 0, 44, LocalDate.of(2012, 7, 20)}, + {"Y-w-e", "2008-01-1", 0, 9, LocalDate.of(2007, 12, 30)}, + {"Y-w-e", "2008-52-1", 0, 9, LocalDate.of(2008, 12, 21)}, + {"Y-w-e", "2008-52-7", 0, 9, LocalDate.of(2008, 12, 27)}, + {"Y-w-e", "2009-01-01", 0, 10, LocalDate.of(2008, 12, 28)}, + {"Y-w-e", "2009-01-04", 0, 10, LocalDate.of(2008, 12, 31)}, + {"Y-w-e", "2009-01-05", 0, 10, LocalDate.of(2009, 1, 1)}, + }; + } + + @Test(dataProvider="LocalWeekBasedYearPatterns") + public void test_parse_WeekBasedYear(String pattern, String text, int pos, int expectedPos, LocalDate expectedValue) { + ParsePosition ppos = new ParsePosition(pos); + DateTimeFormatterBuilder b = new DateTimeFormatterBuilder().appendPattern(pattern); + DateTimeFormatter dtf = b.toFormatter(locale); + TemporalAccessor parsed = dtf.parseUnresolved(text, ppos); + if (ppos.getErrorIndex() != -1) { + assertEquals(ppos.getErrorIndex(), expectedPos); + } else { + WeekFields weekDef = WeekFields.of(locale); + assertEquals(ppos.getIndex(), expectedPos, "Incorrect ending parse position"); + assertEquals(parsed.isSupported(weekDef.dayOfWeek()), pattern.indexOf('e') >= 0); + assertEquals(parsed.isSupported(weekDef.weekOfWeekBasedYear()), pattern.indexOf('w') >= 0); + assertEquals(parsed.isSupported(weekDef.weekBasedYear()), pattern.indexOf('Y') >= 0); + // ensure combination resolves into a date + LocalDate result = LocalDate.parse(text, dtf); + assertEquals(result, expectedValue, "LocalDate incorrect for " + pattern + ", weekDef: " + weekDef); + } + } + } diff --git a/jdk/test/java/time/tck/java/time/format/TCKLocalizedFieldPrinter.java b/jdk/test/java/time/tck/java/time/format/TCKLocalizedFieldPrinter.java index 3be85a9a03c..2b7d0f82ce4 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKLocalizedFieldPrinter.java +++ b/jdk/test/java/time/tck/java/time/format/TCKLocalizedFieldPrinter.java @@ -59,22 +59,22 @@ */ package tck.java.time.format; -import java.time.format.*; - import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; import java.time.LocalDate; - -import test.java.time.format.AbstractTestPrinterParser; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.temporal.WeekFields; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import test.java.time.format.AbstractTestPrinterParser; + /** * Test LocalizedFieldPrinterParser. */ -@Test(groups={"tck"}) +@Test public class TCKLocalizedFieldPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- @@ -82,17 +82,17 @@ public class TCKLocalizedFieldPrinter extends AbstractTestPrinterParser { Object[][] provider_pad() { return new Object[][] { {"e", "6"}, - {"w", "3"}, - {"W", "29"}, - {"WW", "29"}, - {"'Date: 'y-MM-d', week-of-month: 'w', week-of-year: 'W", + {"W", "3"}, + {"w", "29"}, + {"ww", "29"}, + {"'Date: 'y-MM-d', week-of-month: 'W', week-of-year: 'w", "Date: 2012-07-20, week-of-month: 3, week-of-year: 29"}, }; } //----------------------------------------------------------------------- - @Test(dataProvider="Patterns",groups={"tck"}) + @Test(dataProvider="Patterns") public void test_localizedDayOfWeek(String pattern, String expected) { DateTimeFormatterBuilder b = new DateTimeFormatterBuilder().appendPattern(pattern); @@ -102,4 +102,28 @@ public class TCKLocalizedFieldPrinter extends AbstractTestPrinterParser { assertEquals(result, expected, "Wrong output for pattern '" + pattern + "'."); } + //----------------------------------------------------------------------- + @DataProvider(name="LocalWeekBasedYearPatterns") + Object[][] provider_patternLocalWeekBasedYearDate() { + return new Object[][] { + {"e w Y", "6 29 2012", LocalDate.of(2012, 7, 20)}, + {"'Date: 'Y', day-of-week: 'e', week-of-year: 'w", + "Date: 2012, day-of-week: 6, week-of-year: 29", LocalDate.of(2012, 7, 20)}, + {"Y-ww-ee", "2008-01-01", LocalDate.of(2007, 12, 30)}, + {"Y-w-e", "2008-52-1", LocalDate.of(2008, 12, 21)}, + {"Y-w-e", "2008-52-7", LocalDate.of(2008, 12, 27)}, + {"Y-ww-e", "2009-01-1", LocalDate.of(2008, 12, 28)}, + {"Y-w-e", "2009-1-4", LocalDate.of(2008, 12, 31)}, + {"Y-w-e", "2009-1-5", LocalDate.of(2009, 1, 1)}, + {"YYYYYYYYY-w-e", "000002009-1-5", LocalDate.of(2009, 1, 1)}, + }; + } + + @Test(dataProvider = "LocalWeekBasedYearPatterns") + public void test_print_WeekBasedYear(String pattern, String expectedText, LocalDate date) { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern, locale); + String result = dtf.format(date); + WeekFields weekDef = WeekFields.of(locale); + assertEquals(result, expectedText, "Incorrect formatting for " + pattern + ", weekDef: " + weekDef); + } } diff --git a/jdk/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java b/jdk/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java index cb348b264c3..075d862e72c 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java +++ b/jdk/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java @@ -63,7 +63,6 @@ import static org.testng.Assert.assertEquals; import java.text.DateFormat; import java.text.ParsePosition; -import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalTime; import java.time.format.DateTimeFormatter; diff --git a/jdk/test/java/time/tck/java/time/format/TCKOffsetPrinterParser.java b/jdk/test/java/time/tck/java/time/format/TCKOffsetPrinterParser.java index 0ebc718c1e3..76cfa56f88d 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKOffsetPrinterParser.java +++ b/jdk/test/java/time/tck/java/time/format/TCKOffsetPrinterParser.java @@ -62,11 +62,13 @@ package tck.java.time.format; import static org.testng.Assert.assertEquals; import java.time.LocalDateTime; +import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; +import java.time.format.TextStyle; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; @@ -200,6 +202,34 @@ public class TCKOffsetPrinterParser { }; } + @DataProvider(name="print_localized") + Object[][] data_print_localized() { + return new Object[][] { + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_UTC, "GMT"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0100, "GMT+01:00"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0123, "GMT+01:23"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P0023, "GMT+00:23"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_P012345, "GMT+01:23:45"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-00:00:45"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0100, "GMT-01:00"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0123, "GMT-01:23"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M0023, "GMT-00:23"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M012345, "GMT-01:23:45"}, + {TextStyle.FULL, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-00:00:45"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_UTC, "GMT"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0100, "GMT+1"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0123, "GMT+1:23"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P0023, "GMT+0:23"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_P012345, "GMT+1:23:45"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-0:00:45"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0100, "GMT-1"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0123, "GMT-1:23"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M0023, "GMT-0:23"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M012345, "GMT-1:23:45"}, + {TextStyle.SHORT, DT_2012_06_30_12_30_40, OFFSET_M000045, "GMT-0:00:45"}, + }; + } + @Test(dataProvider="print") public void test_print(String offsetPattern, String noOffset, LocalDateTime ldt, ZoneId zone, String expected) { ZonedDateTime zdt = ldt.atZone(zone); @@ -275,6 +305,45 @@ public class TCKOffsetPrinterParser { DateTimeFormatter f3 = new DateTimeFormatterBuilder().appendPattern("ZZZ").toFormatter(); String output3 = f3.format(zdt); assertEquals(output3, (expected.equals("Z") ? "+0000" : expected)); + } else if (offsetPattern.equals("+HH:MM:ss") && noOffset.equals("Z")) { + ZonedDateTime zdt = ldt.atZone(zone); + DateTimeFormatter f = new DateTimeFormatterBuilder().appendPattern("ZZZZZ").toFormatter(); + String output = f.format(zdt); + assertEquals(output, expected); + } + } + + @Test(dataProvider="print_localized") + public void test_print_localized(TextStyle style, LocalDateTime ldt, ZoneOffset offset, String expected) { + OffsetDateTime odt = OffsetDateTime.of(ldt, offset); + ZonedDateTime zdt = ldt.atZone(offset); + + DateTimeFormatter f = new DateTimeFormatterBuilder().appendLocalizedOffset(style) + .toFormatter(); + assertEquals(f.format(odt), expected); + assertEquals(f.format(zdt), expected); + assertEquals(f.parse(expected, ZoneOffset::from), offset); + + if (style == TextStyle.FULL) { + f = new DateTimeFormatterBuilder().appendPattern("ZZZZ") + .toFormatter(); + assertEquals(f.format(odt), expected); + assertEquals(f.format(zdt), expected); + assertEquals(f.parse(expected, ZoneOffset::from), offset); + + f = new DateTimeFormatterBuilder().appendPattern("OOOO") + .toFormatter(); + assertEquals(f.format(odt), expected); + assertEquals(f.format(zdt), expected); + assertEquals(f.parse(expected, ZoneOffset::from), offset); + } + + if (style == TextStyle.SHORT) { + f = new DateTimeFormatterBuilder().appendPattern("O") + .toFormatter(); + assertEquals(f.format(odt), expected); + assertEquals(f.format(zdt), expected); + assertEquals(f.parse(expected, ZoneOffset::from), offset); } } @@ -290,8 +359,43 @@ public class TCKOffsetPrinterParser { } @Test(expectedExceptions=IllegalArgumentException.class) - public void test_print_pattern_Z4rejected() { - builder.appendPattern("ZZZZ"); + public void test_print_pattern_Z6rejected() { + builder.appendPattern("ZZZZZZ"); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_O2rejected() { + builder.appendPattern("OO"); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_O3rejected() { + builder.appendPattern("OOO"); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_O5rejected() { + builder.appendPattern("OOOOO"); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_localzed_full_standline() { + builder.appendLocalizedOffset(TextStyle.FULL_STANDALONE); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_localzed_short_standalone() { + builder.appendLocalizedOffset(TextStyle.SHORT_STANDALONE); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_localzed_narrow() { + builder.appendLocalizedOffset(TextStyle.NARROW); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_print_pattern_localzed_narrow_standalone() { + builder.appendLocalizedOffset(TextStyle.NARROW_STANDALONE); } } diff --git a/jdk/test/java/time/test/java/time/temporal/TestDateTimeAdjusters.java b/jdk/test/java/time/tck/java/time/format/TCKTextStyle.java similarity index 63% rename from jdk/test/java/time/test/java/time/temporal/TestDateTimeAdjusters.java rename to jdk/test/java/time/tck/java/time/format/TCKTextStyle.java index bdade55f572..4e80960fc2f 100644 --- a/jdk/test/java/time/test/java/time/temporal/TestDateTimeAdjusters.java +++ b/jdk/test/java/time/tck/java/time/format/TCKTextStyle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,7 @@ * However, the following notice accompanied the original version of this * file: * - * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos + * Copyright (c) 2013, Stephen Colebourne & Michael Nascimento Santos * * All rights reserved. * @@ -57,56 +57,38 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package test.java.time.temporal; +package tck.java.time.format; -import java.time.temporal.*; - -import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; -import java.util.Collections; +import java.time.format.TextStyle; import org.testng.annotations.Test; /** - * Test Adjusters. + * Test DateTimeFormatSymbols. */ -@Test(groups={"implementation"}) -public class TestDateTimeAdjusters { +@Test +public class TCKTextStyle { - @SuppressWarnings("rawtypes") - public void test_constructor() throws Exception { - for (Constructor constructor : Adjusters.class.getDeclaredConstructors()) { - assertTrue(Modifier.isPrivate(constructor.getModifiers())); - constructor.setAccessible(true); - constructor.newInstance(Collections.nCopies(constructor.getParameterTypes().length, null).toArray()); - } - } + @Test + public void test_standaloneNormal() { + assertEquals(TextStyle.FULL, TextStyle.FULL_STANDALONE.asNormal()); + assertEquals(TextStyle.SHORT, TextStyle.SHORT.asNormal()); + assertEquals(TextStyle.NARROW, TextStyle.NARROW.asNormal()); - public void factory_firstDayOfMonthSame() { - assertSame(Adjusters.firstDayOfMonth(), Adjusters.firstDayOfMonth()); - } + assertEquals(TextStyle.FULL_STANDALONE, TextStyle.FULL_STANDALONE.asStandalone()); + assertEquals(TextStyle.SHORT_STANDALONE, TextStyle.SHORT.asStandalone()); + assertEquals(TextStyle.NARROW_STANDALONE, TextStyle.NARROW.asStandalone()); - public void factory_lastDayOfMonthSame() { - assertSame(Adjusters.lastDayOfMonth(), Adjusters.lastDayOfMonth()); - } + assertTrue(TextStyle.FULL_STANDALONE.isStandalone()); + assertTrue(TextStyle.SHORT_STANDALONE.isStandalone()); + assertTrue(TextStyle.NARROW_STANDALONE.isStandalone()); - public void factory_firstDayOfNextMonthSame() { - assertSame(Adjusters.firstDayOfNextMonth(), Adjusters.firstDayOfNextMonth()); - } - - public void factory_firstDayOfYearSame() { - assertSame(Adjusters.firstDayOfYear(), Adjusters.firstDayOfYear()); - } - - public void factory_lastDayOfYearSame() { - assertSame(Adjusters.lastDayOfYear(), Adjusters.lastDayOfYear()); - } - - public void factory_firstDayOfNextYearSame() { - assertSame(Adjusters.firstDayOfNextYear(), Adjusters.firstDayOfNextYear()); + assertTrue(!TextStyle.FULL.isStandalone()); + assertTrue(!TextStyle.SHORT.isStandalone()); + assertTrue(!TextStyle.NARROW.isStandalone()); } } diff --git a/jdk/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java b/jdk/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java index e346742dea3..f6c4c46f2a1 100644 --- a/jdk/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java +++ b/jdk/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java @@ -67,8 +67,8 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatterBuilder; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQuery; import java.util.Locale; import org.testng.annotations.BeforeMethod; @@ -209,9 +209,9 @@ public class TCKZoneIdPrinterParser { assertEquals(pos.getErrorIndex(), expectedErrorIndex); assertEquals(pos.getIndex(), expectedIndex); if (expected != null) { - assertEquals(parsed.query(Queries.zoneId()), expected); - assertEquals(parsed.query(Queries.offset()), null); - assertEquals(parsed.query(Queries.zone()), expected); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected); + assertEquals(parsed.query(TemporalQuery.offset()), null); + assertEquals(parsed.query(TemporalQuery.zone()), expected); } else { assertEquals(parsed, null); } @@ -225,9 +225,9 @@ public class TCKZoneIdPrinterParser { assertEquals(pos.getErrorIndex(), expectedErrorIndex >= 0 ? expectedErrorIndex + 3 : expectedErrorIndex); assertEquals(pos.getIndex(), expectedIndex + 3); if (expected != null) { - assertEquals(parsed.query(Queries.zoneId()), expected); - assertEquals(parsed.query(Queries.offset()), null); - assertEquals(parsed.query(Queries.zone()), expected); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected); + assertEquals(parsed.query(TemporalQuery.offset()), null); + assertEquals(parsed.query(TemporalQuery.zone()), expected); } else { assertEquals(parsed, null); } @@ -240,9 +240,9 @@ public class TCKZoneIdPrinterParser { assertEquals(pos.getErrorIndex(), expectedErrorIndex); assertEquals(pos.getIndex(), expectedIndex); if (expected != null) { - assertEquals(parsed.query(Queries.zoneId()), expected); - assertEquals(parsed.query(Queries.offset()), null); - assertEquals(parsed.query(Queries.zone()), expected); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected); + assertEquals(parsed.query(TemporalQuery.offset()), null); + assertEquals(parsed.query(TemporalQuery.zone()), expected); } else { assertEquals(parsed, null); } @@ -261,9 +261,9 @@ public class TCKZoneIdPrinterParser { assertEquals(pos.getIndex(), expectedIndex); assertEquals(pos.getErrorIndex(), expectedErrorIndex); if (expected != null) { - assertEquals(parsed.query(Queries.zoneId()), expected); - assertEquals(parsed.query(Queries.offset()), null); - assertEquals(parsed.query(Queries.zone()), expected); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected); + assertEquals(parsed.query(TemporalQuery.offset()), null); + assertEquals(parsed.query(TemporalQuery.zone()), expected); } else { assertEquals(parsed, null); } @@ -277,9 +277,9 @@ public class TCKZoneIdPrinterParser { assertEquals(pos.getErrorIndex(), expectedErrorIndex); assertEquals(pos.getIndex(), expectedIndex); if (expected != null) { - assertEquals(parsed.query(Queries.zoneId()), expected); - assertEquals(parsed.query(Queries.offset()), null); - assertEquals(parsed.query(Queries.zone()), expected); + assertEquals(parsed.query(TemporalQuery.zoneId()), expected); + assertEquals(parsed.query(TemporalQuery.offset()), null); + assertEquals(parsed.query(TemporalQuery.zone()), expected); } else { assertEquals(parsed, null); } diff --git a/jdk/test/java/time/tck/java/time/temporal/TCKIsoFields.java b/jdk/test/java/time/tck/java/time/temporal/TCKIsoFields.java index 359aac1b0e6..7159b312866 100644 --- a/jdk/test/java/time/tck/java/time/temporal/TCKIsoFields.java +++ b/jdk/test/java/time/tck/java/time/temporal/TCKIsoFields.java @@ -66,11 +66,14 @@ import static java.time.DayOfWeek.WEDNESDAY; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.YEAR; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; +import java.time.format.DateTimeParseException; +import java.time.format.ResolverStyle; import java.time.temporal.IsoFields; import java.time.temporal.ValueRange; @@ -80,7 +83,7 @@ import org.testng.annotations.Test; /** * Test. */ -@Test(groups={"tck"}) +@Test public class TCKIsoFields { @DataProvider(name="quarter") @@ -115,34 +118,132 @@ public class TCKIsoFields { //----------------------------------------------------------------------- // DAY_OF_QUARTER //----------------------------------------------------------------------- - @Test(dataProvider="quarter") + @Test(dataProvider = "quarter") public void test_DOQ(LocalDate date, int doq, int qoy) { assertEquals(IsoFields.DAY_OF_QUARTER.getFrom(date), doq); assertEquals(date.get(IsoFields.DAY_OF_QUARTER), doq); } + public void test_DOQ_basics() { + assertEquals(IsoFields.DAY_OF_QUARTER.isDateBased(), true); + assertEquals(IsoFields.DAY_OF_QUARTER.isTimeBased(), false); + } + //----------------------------------------------------------------------- // QUARTER_OF_YEAR //----------------------------------------------------------------------- - @Test(dataProvider="quarter") + @Test(dataProvider = "quarter") public void test_QOY(LocalDate date, int doq, int qoy) { assertEquals(IsoFields.QUARTER_OF_YEAR.getFrom(date), qoy); assertEquals(date.get(IsoFields.QUARTER_OF_YEAR), qoy); } + public void test_QOY_basics() { + assertEquals(IsoFields.QUARTER_OF_YEAR.isDateBased(), true); + assertEquals(IsoFields.QUARTER_OF_YEAR.isTimeBased(), false); + } + //----------------------------------------------------------------------- // parse quarters //----------------------------------------------------------------------- - @Test(dataProvider="quarter") + @Test(dataProvider = "quarter") public void test_parse_quarters(LocalDate date, int doq, int qoy) { DateTimeFormatter f = new DateTimeFormatterBuilder() .appendValue(YEAR).appendLiteral('-') .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral('-') - .appendValue(IsoFields.DAY_OF_QUARTER).toFormatter(); + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.STRICT); LocalDate parsed = LocalDate.parse(date.getYear() + "-" + qoy + "-" + doq, f); assertEquals(parsed, date); } + @Test(dataProvider = "quarter") + public void test_parse_quarters_SMART(LocalDate date, int doq, int qoy) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral('-') + .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral('-') + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.SMART); + LocalDate parsed = LocalDate.parse(date.getYear() + "-" + qoy + "-" + doq, f); + assertEquals(parsed, date); + } + + @Test(dataProvider = "quarter") + public void test_parse_quarters_LENIENT(LocalDate date, int doq, int qoy) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral('-') + .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral('-') + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.LENIENT); + LocalDate parsed = LocalDate.parse(date.getYear() + "-" + qoy + "-" + doq, f); + assertEquals(parsed, date); + } + + //----------------------------------------------------------------------- + @DataProvider(name="parseLenientQuarter") + Object[][] data_parseLenientQuarter() { + return new Object[][] { + {"2012:0:1", LocalDate.of(2011, 10, 1), false}, + {"2012:5:1", LocalDate.of(2013, 1, 1), false}, + + {"2012:1:-1", LocalDate.of(2011, 12, 30), false}, + {"2012:1:0", LocalDate.of(2011, 12, 31), false}, + {"2012:0:0", LocalDate.of(2011, 9, 30), false}, + + {"2012:1:92", LocalDate.of(2012, 4, 1), true}, + {"2012:2:92", LocalDate.of(2012, 7, 1), true}, + {"2012:2:93", LocalDate.of(2012, 7, 2), false}, + {"2012:3:93", LocalDate.of(2012, 10, 1), false}, + {"2012:4:93", LocalDate.of(2013, 1, 1), false}, + {"2012:4:182", LocalDate.of(2013, 3, 31), false}, + {"2012:4:183", LocalDate.of(2013, 4, 1), false}, + + {"2011:1:91", LocalDate.of(2011, 4, 1), true}, + {"2011:1:92", LocalDate.of(2011, 4, 2), true}, + }; + } + + @Test(dataProvider = "parseLenientQuarter", expectedExceptions = DateTimeParseException.class) + public void test_parse_parseLenientQuarter_STRICT(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral(':') + .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':') + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.STRICT); + LocalDate.parse(str, f); + } + + @Test(dataProvider = "parseLenientQuarter") + public void test_parse_parseLenientQuarter_SMART(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral(':') + .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':') + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.SMART); + if (smart) { + LocalDate parsed = LocalDate.parse(str, f); + assertEquals(parsed, expected); + } else { + try { + LocalDate.parse(str, f); + fail("Should have failed"); + } catch (DateTimeParseException ex) { + // expected + } + } + } + + @Test(dataProvider = "parseLenientQuarter") + public void test_parse_parseLenientQuarter_LENIENT(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(YEAR).appendLiteral(':') + .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':') + .appendValue(IsoFields.DAY_OF_QUARTER) + .toFormatter().withResolverStyle(ResolverStyle.LENIENT); + LocalDate parsed = LocalDate.parse(str, f); + assertEquals(parsed, expected); + } + //----------------------------------------------------------------------- // quarters between //----------------------------------------------------------------------- @@ -214,6 +315,11 @@ public class TCKIsoFields { assertEquals(date.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR), week); } + public void test_WOWBY_basics() { + assertEquals(IsoFields.WEEK_OF_WEEK_BASED_YEAR.isDateBased(), true); + assertEquals(IsoFields.WEEK_OF_WEEK_BASED_YEAR.isTimeBased(), false); + } + //----------------------------------------------------------------------- // WEEK_BASED_YEAR //----------------------------------------------------------------------- @@ -224,19 +330,105 @@ public class TCKIsoFields { assertEquals(date.get(IsoFields.WEEK_BASED_YEAR), wby); } + public void test_WBY_basics() { + assertEquals(IsoFields.WEEK_BASED_YEAR.isDateBased(), true); + assertEquals(IsoFields.WEEK_BASED_YEAR.isTimeBased(), false); + } + //----------------------------------------------------------------------- // parse weeks //----------------------------------------------------------------------- @Test(dataProvider="week") - public void test_parse_weeks(LocalDate date, DayOfWeek dow, int week, int wby) { + public void test_parse_weeks_STRICT(LocalDate date, DayOfWeek dow, int week, int wby) { DateTimeFormatter f = new DateTimeFormatterBuilder() .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral('-') .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral('-') - .appendValue(DAY_OF_WEEK).toFormatter(); + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.STRICT); LocalDate parsed = LocalDate.parse(wby + "-" + week + "-" + dow.getValue(), f); assertEquals(parsed, date); } + @Test(dataProvider="week") + public void test_parse_weeks_SMART(LocalDate date, DayOfWeek dow, int week, int wby) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral('-') + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral('-') + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.SMART); + LocalDate parsed = LocalDate.parse(wby + "-" + week + "-" + dow.getValue(), f); + assertEquals(parsed, date); + } + + @Test(dataProvider="week") + public void test_parse_weeks_LENIENT(LocalDate date, DayOfWeek dow, int week, int wby) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral('-') + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral('-') + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.LENIENT); + LocalDate parsed = LocalDate.parse(wby + "-" + week + "-" + dow.getValue(), f); + assertEquals(parsed, date); + } + + //----------------------------------------------------------------------- + @DataProvider(name="parseLenientWeek") + Object[][] data_parseLenientWeek() { + return new Object[][] { + {"2012:52:-1", LocalDate.of(2012, 12, 22), false}, + {"2012:52:0", LocalDate.of(2012, 12, 23), false}, + {"2012:52:8", LocalDate.of(2012, 12, 31), false}, + {"2012:52:9", LocalDate.of(2013, 1, 1), false}, + + {"2012:53:1", LocalDate.of(2012, 12, 31), true}, + {"2012:54:1", LocalDate.of(2013, 1, 7), false}, + + {"2013:0:1", LocalDate.of(2012, 12, 24), false}, + {"2013:0:0", LocalDate.of(2012, 12, 23), false}, + }; + } + + @Test(dataProvider = "parseLenientWeek", expectedExceptions = DateTimeParseException.class) + public void test_parse_parseLenientWeek_STRICT(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.STRICT); + LocalDate.parse(str, f); + } + + @Test(dataProvider = "parseLenientWeek") + public void test_parse_parseLenientWeek_SMART(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.SMART); + if (smart) { + LocalDate parsed = LocalDate.parse(str, f); + assertEquals(parsed, expected); + } else { + try { + LocalDate.parse(str, f); + fail("Should have failed"); + } catch (DateTimeParseException ex) { + // expected + } + } + } + + @Test(dataProvider = "parseLenientWeek") + public void test_parse_parseLenientWeek_LENIENT(String str, LocalDate expected, boolean smart) { + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral(':') + .appendValue(DAY_OF_WEEK) + .toFormatter().withResolverStyle(ResolverStyle.LENIENT); + LocalDate parsed = LocalDate.parse(str, f); + assertEquals(parsed, expected); + } + //----------------------------------------------------------------------- public void test_loop() { // loop round at least one 400 year cycle, including before 1970 diff --git a/jdk/test/java/time/tck/java/time/temporal/TCKJulianFields.java b/jdk/test/java/time/tck/java/time/temporal/TCKJulianFields.java index 94399e0fdd8..711792fbedb 100644 --- a/jdk/test/java/time/tck/java/time/temporal/TCKJulianFields.java +++ b/jdk/test/java/time/tck/java/time/temporal/TCKJulianFields.java @@ -65,7 +65,9 @@ import java.io.IOException; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; +import java.time.format.ResolverStyle; import java.time.temporal.ChronoField; +import java.time.temporal.IsoFields; import java.time.temporal.JulianFields; import java.time.temporal.TemporalField; @@ -125,6 +127,17 @@ public class TCKJulianFields extends AbstractTCKTest { assertSerializable(field); } + public void test_basics() { + assertEquals(JulianFields.JULIAN_DAY.isDateBased(), true); + assertEquals(JulianFields.JULIAN_DAY.isTimeBased(), false); + + assertEquals(JulianFields.MODIFIED_JULIAN_DAY.isDateBased(), true); + assertEquals(JulianFields.MODIFIED_JULIAN_DAY.isTimeBased(), false); + + assertEquals(JulianFields.RATA_DIE.isDateBased(), true); + assertEquals(JulianFields.RATA_DIE.isTimeBased(), false); + } + //----------------------------------------------------------------------- @Test(dataProvider="samples") public void test_samples_get(TemporalField field, LocalDate date, long expected) { @@ -142,8 +155,25 @@ public class TCKJulianFields extends AbstractTCKTest { //----------------------------------------------------------------------- @Test(dataProvider="samples") - public void test_samples_parse(TemporalField field, LocalDate date, long value) { - DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter(); + public void test_samples_parse_STRICT(TemporalField field, LocalDate date, long value) { + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field) + .toFormatter().withResolverStyle(ResolverStyle.STRICT); + LocalDate parsed = LocalDate.parse(Long.toString(value), f); + assertEquals(parsed, date); + } + + @Test(dataProvider="samples") + public void test_samples_parse_SMART(TemporalField field, LocalDate date, long value) { + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field) + .toFormatter().withResolverStyle(ResolverStyle.SMART); + LocalDate parsed = LocalDate.parse(Long.toString(value), f); + assertEquals(parsed, date); + } + + @Test(dataProvider="samples") + public void test_samples_parse_LENIENT(TemporalField field, LocalDate date, long value) { + DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field) + .toFormatter().withResolverStyle(ResolverStyle.LENIENT); LocalDate parsed = LocalDate.parse(Long.toString(value), f); assertEquals(parsed, date); } diff --git a/jdk/test/java/time/tck/java/time/temporal/TCKDateTimeAdjusters.java b/jdk/test/java/time/tck/java/time/temporal/TCKTemporalAdjusters.java similarity index 80% rename from jdk/test/java/time/tck/java/time/temporal/TCKDateTimeAdjusters.java rename to jdk/test/java/time/tck/java/time/temporal/TCKTemporalAdjusters.java index 231a16b5674..66f129c0906 100644 --- a/jdk/test/java/time/tck/java/time/temporal/TCKDateTimeAdjusters.java +++ b/jdk/test/java/time/tck/java/time/temporal/TCKTemporalAdjusters.java @@ -59,8 +59,6 @@ */ package tck.java.time.temporal; -import java.time.temporal.*; - import static java.time.DayOfWeek.MONDAY; import static java.time.DayOfWeek.TUESDAY; import static java.time.Month.DECEMBER; @@ -74,30 +72,46 @@ import static org.testng.Assert.assertTrue; import java.time.DayOfWeek; import java.time.LocalDate; import java.time.Month; +import java.time.temporal.TemporalAdjuster; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** - * Test Adjusters. + * Test TemporalAdjuster. */ @Test -public class TCKDateTimeAdjusters { +public class TCKTemporalAdjusters { + + //----------------------------------------------------------------------- + // ofDateAdjuster() + //----------------------------------------------------------------------- + @Test + public void factory_ofDateAdjuster() { + TemporalAdjuster test = TemporalAdjuster.ofDateAdjuster(date -> date.plusDays(2)); + assertEquals(LocalDate.of(2012, 6, 30).with(test), LocalDate.of(2012, 7, 2)); + } + + @Test(expectedExceptions = NullPointerException.class) + public void factory_ofDateAdjuster_null() { + TemporalAdjuster.ofDateAdjuster(null); + } + //----------------------------------------------------------------------- // firstDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_firstDayOfMonth() { - assertNotNull(Adjusters.firstDayOfMonth()); + assertNotNull(TemporalAdjuster.firstDayOfMonth()); } - @Test(groups={"tck"}) + @Test public void test_firstDayOfMonth_nonLeap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), 1); @@ -105,12 +119,12 @@ public class TCKDateTimeAdjusters { } } - @Test(groups={"tck"}) + @Test public void test_firstDayOfMonth_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), 1); @@ -121,17 +135,17 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // lastDayOfMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_lastDayOfMonth() { - assertNotNull(Adjusters.lastDayOfMonth()); + assertNotNull(TemporalAdjuster.lastDayOfMonth()); } - @Test(groups={"tck"}) + @Test public void test_lastDayOfMonth_nonLeap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.lastDayOfMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), month.length(false)); @@ -139,12 +153,12 @@ public class TCKDateTimeAdjusters { } } - @Test(groups={"tck"}) + @Test public void test_lastDayOfMonth_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.lastDayOfMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), month.length(true)); @@ -155,17 +169,17 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // firstDayOfNextMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_firstDayOfNextMonth() { - assertNotNull(Adjusters.firstDayOfNextMonth()); + assertNotNull(TemporalAdjuster.firstDayOfNextMonth()); } - @Test(groups={"tck"}) + @Test public void test_firstDayOfNextMonth_nonLeap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfNextMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextMonth().adjustInto(date); assertEquals(test.getYear(), month == DECEMBER ? 2008 : 2007); assertEquals(test.getMonth(), month.plus(1)); assertEquals(test.getDayOfMonth(), 1); @@ -173,12 +187,12 @@ public class TCKDateTimeAdjusters { } } - @Test(groups={"tck"}) + @Test public void test_firstDayOfNextMonth_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfNextMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextMonth().adjustInto(date); assertEquals(test.getYear(), month == DECEMBER ? 2009 : 2008); assertEquals(test.getMonth(), month.plus(1)); assertEquals(test.getDayOfMonth(), 1); @@ -189,17 +203,17 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // firstDayOfYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_firstDayOfYear() { - assertNotNull(Adjusters.firstDayOfYear()); + assertNotNull(TemporalAdjuster.firstDayOfYear()); } - @Test(groups={"tck"}) + @Test public void test_firstDayOfYear_nonLeap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfYear().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), Month.JANUARY); assertEquals(test.getDayOfMonth(), 1); @@ -207,12 +221,12 @@ public class TCKDateTimeAdjusters { } } - @Test(groups={"tck"}) + @Test public void test_firstDayOfYear_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfYear().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), Month.JANUARY); assertEquals(test.getDayOfMonth(), 1); @@ -223,17 +237,17 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // lastDayOfYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_lastDayOfYear() { - assertNotNull(Adjusters.lastDayOfYear()); + assertNotNull(TemporalAdjuster.lastDayOfYear()); } - @Test(groups={"tck"}) + @Test public void test_lastDayOfYear_nonLeap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.lastDayOfYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfYear().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); @@ -241,12 +255,12 @@ public class TCKDateTimeAdjusters { } } - @Test(groups={"tck"}) + @Test public void test_lastDayOfYear_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.lastDayOfYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfYear().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); @@ -257,17 +271,17 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // firstDayOfNextYear() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_firstDayOfNextYear() { - assertNotNull(Adjusters.firstDayOfNextYear()); + assertNotNull(TemporalAdjuster.firstDayOfNextYear()); } - @Test(groups={"tck"}) + @Test public void test_firstDayOfNextYear_nonLeap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfNextYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextYear().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), JANUARY); assertEquals(test.getDayOfMonth(), 1); @@ -275,12 +289,12 @@ public class TCKDateTimeAdjusters { } } - @Test(groups={"tck"}) + @Test public void test_firstDayOfNextYear_leap() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) Adjusters.firstDayOfNextYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextYear().adjustInto(date); assertEquals(test.getYear(), 2009); assertEquals(test.getMonth(), JANUARY); assertEquals(test.getDayOfMonth(), 1); @@ -291,14 +305,14 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // dayOfWeekInMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_dayOfWeekInMonth() { - assertNotNull(Adjusters.dayOfWeekInMonth(1, MONDAY)); + assertNotNull(TemporalAdjuster.dayOfWeekInMonth(1, MONDAY)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_dayOfWeekInMonth_nullDayOfWeek() { - Adjusters.dayOfWeekInMonth(1, null); + TemporalAdjuster.dayOfWeekInMonth(1, null); } @DataProvider(name = "dayOfWeekInMonth_positive") @@ -319,12 +333,12 @@ public class TCKDateTimeAdjusters { }; } - @Test(groups={"tck"}, dataProvider = "dayOfWeekInMonth_positive") + @Test(dataProvider = "dayOfWeekInMonth_positive") public void test_dayOfWeekInMonth_positive(int year, int month, DayOfWeek dow, LocalDate expected) { for (int ordinal = 1; ordinal <= 5; ordinal++) { for (int day = 1; day <= Month.of(month).length(false); day++) { LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) Adjusters.dayOfWeekInMonth(ordinal, dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.dayOfWeekInMonth(ordinal, dow).adjustInto(date); assertEquals(test, expected.plusWeeks(ordinal - 1)); } } @@ -348,11 +362,11 @@ public class TCKDateTimeAdjusters { }; } - @Test(groups={"tck"}, dataProvider = "dayOfWeekInMonth_zero") + @Test(dataProvider = "dayOfWeekInMonth_zero") public void test_dayOfWeekInMonth_zero(int year, int month, DayOfWeek dow, LocalDate expected) { for (int day = 1; day <= Month.of(month).length(false); day++) { LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) Adjusters.dayOfWeekInMonth(0, dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.dayOfWeekInMonth(0, dow).adjustInto(date); assertEquals(test, expected); } } @@ -375,12 +389,12 @@ public class TCKDateTimeAdjusters { }; } - @Test(groups={"tck"}, dataProvider = "dayOfWeekInMonth_negative") + @Test(dataProvider = "dayOfWeekInMonth_negative") public void test_dayOfWeekInMonth_negative(int year, int month, DayOfWeek dow, LocalDate expected) { for (int ordinal = 0; ordinal < 5; ordinal++) { for (int day = 1; day <= Month.of(month).length(false); day++) { LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) Adjusters.dayOfWeekInMonth(-1 - ordinal, dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.dayOfWeekInMonth(-1 - ordinal, dow).adjustInto(date); assertEquals(test, expected.minusWeeks(ordinal)); } } @@ -389,21 +403,21 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // firstInMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_firstInMonth() { - assertNotNull(Adjusters.firstInMonth(MONDAY)); + assertNotNull(TemporalAdjuster.firstInMonth(MONDAY)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_firstInMonth_nullDayOfWeek() { - Adjusters.firstInMonth(null); + TemporalAdjuster.firstInMonth(null); } - @Test(groups={"tck"}, dataProvider = "dayOfWeekInMonth_positive") + @Test(dataProvider = "dayOfWeekInMonth_positive") public void test_firstInMonth(int year, int month, DayOfWeek dow, LocalDate expected) { for (int day = 1; day <= Month.of(month).length(false); day++) { LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) Adjusters.firstInMonth(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.firstInMonth(dow).adjustInto(date); assertEquals(test, expected, "day-of-month=" + day); } } @@ -411,21 +425,21 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // lastInMonth() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_lastInMonth() { - assertNotNull(Adjusters.lastInMonth(MONDAY)); + assertNotNull(TemporalAdjuster.lastInMonth(MONDAY)); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void factory_lastInMonth_nullDayOfWeek() { - Adjusters.lastInMonth(null); + TemporalAdjuster.lastInMonth(null); } - @Test(groups={"tck"}, dataProvider = "dayOfWeekInMonth_negative") + @Test(dataProvider = "dayOfWeekInMonth_negative") public void test_lastInMonth(int year, int month, DayOfWeek dow, LocalDate expected) { for (int day = 1; day <= Month.of(month).length(false); day++) { LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) Adjusters.lastInMonth(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.lastInMonth(dow).adjustInto(date); assertEquals(test, expected, "day-of-month=" + day); } } @@ -433,24 +447,24 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // next() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_next() { - assertNotNull(Adjusters.next(MONDAY)); + assertNotNull(TemporalAdjuster.next(MONDAY)); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void factory_next_nullDayOfWeek() { - Adjusters.next(null); + TemporalAdjuster.next(null); } - @Test(groups={"tck"}) + @Test public void test_next() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) Adjusters.next(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.next(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow, date + " " + test); @@ -472,24 +486,24 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // nextOrSame() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_nextOrCurrent() { - assertNotNull(Adjusters.nextOrSame(MONDAY)); + assertNotNull(TemporalAdjuster.nextOrSame(MONDAY)); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void factory_nextOrCurrent_nullDayOfWeek() { - Adjusters.nextOrSame(null); + TemporalAdjuster.nextOrSame(null); } - @Test(groups={"tck"}) + @Test public void test_nextOrCurrent() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) Adjusters.nextOrSame(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.nextOrSame(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow); @@ -513,24 +527,24 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // previous() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_previous() { - assertNotNull(Adjusters.previous(MONDAY)); + assertNotNull(TemporalAdjuster.previous(MONDAY)); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void factory_previous_nullDayOfWeek() { - Adjusters.previous(null); + TemporalAdjuster.previous(null); } - @Test(groups={"tck"}) + @Test public void test_previous() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) Adjusters.previous(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.previous(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow, date + " " + test); @@ -552,24 +566,24 @@ public class TCKDateTimeAdjusters { //----------------------------------------------------------------------- // previousOrSame() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void factory_previousOrCurrent() { - assertNotNull(Adjusters.previousOrSame(MONDAY)); + assertNotNull(TemporalAdjuster.previousOrSame(MONDAY)); } - @Test(expectedExceptions = NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions = NullPointerException.class) public void factory_previousOrCurrent_nullDayOfWeek() { - Adjusters.previousOrSame(null); + TemporalAdjuster.previousOrSame(null); } - @Test(groups={"tck"}) + @Test public void test_previousOrCurrent() { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) Adjusters.previousOrSame(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjuster.previousOrSame(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow); diff --git a/jdk/test/java/time/tck/java/time/temporal/TCKWeekFields.java b/jdk/test/java/time/tck/java/time/temporal/TCKWeekFields.java index 76789cd00a2..748b5283068 100644 --- a/jdk/test/java/time/tck/java/time/temporal/TCKWeekFields.java +++ b/jdk/test/java/time/tck/java/time/temporal/TCKWeekFields.java @@ -61,6 +61,7 @@ import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; + import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertSame; @@ -69,6 +70,8 @@ import java.time.DayOfWeek; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; +import java.time.temporal.ChronoUnit; +import java.time.temporal.JulianFields; import java.time.temporal.TemporalField; import java.time.temporal.ValueRange; import java.time.temporal.WeekFields; @@ -91,6 +94,26 @@ public class TCKWeekFields extends AbstractTCKTest { assertSame(WeekFields.of(firstDayOfWeek, minDays), week); } + //----------------------------------------------------------------------- + @Test(dataProvider="weekFields") + public void test_basics(DayOfWeek firstDayOfWeek, int minDays) { + WeekFields week = WeekFields.of(firstDayOfWeek, minDays); + assertEquals(week.dayOfWeek().isDateBased(), true); + assertEquals(week.dayOfWeek().isTimeBased(), false); + + assertEquals(week.weekOfMonth().isDateBased(), true); + assertEquals(week.weekOfMonth().isTimeBased(), false); + + assertEquals(week.weekOfYear().isDateBased(), true); + assertEquals(week.weekOfYear().isTimeBased(), false); + + assertEquals(week.weekOfWeekBasedYear().isDateBased(), true); + assertEquals(week.weekOfWeekBasedYear().isTimeBased(), false); + + assertEquals(week.weekBasedYear().isDateBased(), true); + assertEquals(week.weekBasedYear().isTimeBased(), false); + } + //----------------------------------------------------------------------- @Test public void test_dayOfWeekField_simpleGet() { @@ -124,10 +147,8 @@ public class TCKWeekFields extends AbstractTCKTest { LocalDate day = LocalDate.of(2000, 1, 10); // Known to be ISO Monday WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField f = week.dayOfWeek(); - //System.out.printf(" Week: %s; field: %s%n", week, f); for (int i = 1; i <= 7; i++) { - //System.out.printf(" ISO Dow: %s, WeekDOW ordinal: %s%n", day.getDayOfWeek(), day.get(f)); assertEquals(day.get(f), (7 + day.getDayOfWeek().getValue() - firstDayOfWeek.getValue()) % 7 + 1); day = day.plusDays(1); } @@ -139,7 +160,6 @@ public class TCKWeekFields extends AbstractTCKTest { WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField dowField = week.dayOfWeek(); TemporalField womField = week.weekOfMonth(); - //System.err.printf("%n Week: %s; dowField: %s, domField: %s%n", week, dowField, womField); DayOfWeek isoDOW = day.getDayOfWeek(); int dow = (7 + isoDOW.getValue() - firstDayOfWeek.getValue()) % 7 + 1; @@ -152,23 +172,17 @@ public class TCKWeekFields extends AbstractTCKTest { // to reconstruct the same date. LocalDate day1 = day.withDayOfMonth(1); int offset = - (day1.get(dowField) - 1); - //System.err.printf(" refDay: %s%n", day1.plusDays(offset)); + int week1 = day1.get(womField); if (week1 == 0) { // week of the 1st is partial; start with first full week offset += 7; } - //System.err.printf(" refDay2: %s, offset: %d, week1: %d%n", day1.plusDays(offset), offset, week1); + offset += actualDOW - 1; - //System.err.printf(" refDay3: %s%n", day1.plusDays(offset)); offset += (actualWOM - 1) * 7; - //System.err.printf(" refDay4: %s%n", day1.plusDays(offset)); LocalDate result = day1.plusDays(offset); - if (!day.equals(result)) { - System.err.printf("FAIL ISO Dow: %s, offset: %s, actualDOW: %s, actualWOM: %s, expected: %s, result: %s%n", - day.getDayOfWeek(), offset, actualDOW, actualWOM, day, result); - } assertEquals(result, day, "Incorrect dayOfWeek or weekOfMonth: " + String.format("%s, ISO Dow: %s, offset: %s, actualDOW: %s, actualWOM: %s, expected: %s, result: %s%n", week, day.getDayOfWeek(), offset, actualDOW, actualWOM, day, result)); @@ -182,7 +196,6 @@ public class TCKWeekFields extends AbstractTCKTest { WeekFields week = WeekFields.of(firstDayOfWeek, minDays); TemporalField dowField = week.dayOfWeek(); TemporalField woyField = week.weekOfYear(); - //System.err.printf("%n Year: %s; dowField: %s, woyField: %s%n", week, dowField, woyField); DayOfWeek isoDOW = day.getDayOfWeek(); int dow = (7 + isoDOW.getValue() - firstDayOfWeek.getValue()) % 7 + 1; @@ -195,24 +208,15 @@ public class TCKWeekFields extends AbstractTCKTest { // to reconstruct the same date. LocalDate day1 = day.withDayOfYear(1); int offset = - (day1.get(dowField) - 1); - //System.err.printf(" refDay: %s%n", day1.plusDays(offset)); int week1 = day1.get(woyField); if (week1 == 0) { // week of the 1st is partial; start with first full week offset += 7; } - //System.err.printf(" refDay2: %s, offset: %d, week1: %d%n", day1.plusDays(offset), offset, week1); offset += actualDOW - 1; - //System.err.printf(" refDay3: %s%n", day1.plusDays(offset)); offset += (actualWOY - 1) * 7; - //System.err.printf(" refDay4: %s%n", day1.plusDays(offset)); LocalDate result = day1.plusDays(offset); - - if (!day.equals(result)) { - System.err.printf("FAIL ISO Dow: %s, offset: %s, actualDOW: %s, actualWOY: %s, expected: %s, result: %s%n", - day.getDayOfWeek(), offset, actualDOW, actualWOY, day, result); - } assertEquals(result, day, "Incorrect dayOfWeek or weekOfYear " + String.format("%s, ISO Dow: %s, offset: %s, actualDOW: %s, actualWOM: %s, expected: %s, result: %s%n", week, day.getDayOfWeek(), offset, actualDOW, actualWOY, day, result)); @@ -220,6 +224,48 @@ public class TCKWeekFields extends AbstractTCKTest { } } + /** + * Verify that the date can be reconstructed from the DOW, WeekOfWeekBasedYear, + * and WeekBasedYear for every combination of start of week + * and minimal days in week. + * @param firstDayOfWeek the first day of the week + * @param minDays the minimum number of days in the week + */ + @Test(dataProvider="weekFields") + public void test_weekOfWeekBasedYearField(DayOfWeek firstDayOfWeek, int minDays) { + LocalDate day = LocalDate.of(2012, 12, 31); // Known to be ISO Monday + WeekFields weekDef = WeekFields.of(firstDayOfWeek, minDays); + TemporalField dowField = weekDef.dayOfWeek(); + TemporalField wowbyField = weekDef.weekOfWeekBasedYear(); + TemporalField yowbyField = weekDef.weekBasedYear(); + + for (int i = 1; i <= 15; i++) { + int actualDOW = day.get(dowField); + int actualWOWBY = day.get(wowbyField); + int actualYOWBY = day.get(yowbyField); + + // Verify that the combination of day of week and week of month can be used + // to reconstruct the same date. + LocalDate day1 = LocalDate.of(actualYOWBY, 1, 1); + DayOfWeek isoDOW = day1.getDayOfWeek(); + int dow = (7 + isoDOW.getValue() - firstDayOfWeek.getValue()) % 7 + 1; + + int weekStart = Math.floorMod(1 - dow, 7); + if (weekStart + 1 > weekDef.getMinimalDaysInFirstWeek()) { + // The previous week has the minimum days in the current month to be a 'week' + weekStart -= 7; + } + weekStart += actualDOW - 1; + weekStart += (actualWOWBY - 1) * 7; + LocalDate result = day1.plusDays(weekStart); + + assertEquals(result, day, "Incorrect dayOfWeek or weekOfYear " + + String.format("%s, ISO Dow: %s, weekStart: %s, actualDOW: %s, actualWOWBY: %s, YearOfWBY: %d, expected day: %s, result: %s%n", + weekDef, day.getDayOfWeek(), weekStart, actualDOW, actualWOWBY, actualYOWBY, day, result)); + day = day.plusDays(1); + } + } + @Test(dataProvider="weekFields") public void test_fieldRanges(DayOfWeek firstDayOfWeek, int minDays) { WeekFields weekDef = WeekFields.of(firstDayOfWeek, minDays); @@ -272,24 +318,63 @@ public class TCKWeekFields extends AbstractTCKTest { int woy = day.get(woyField); for (int dow = 1; dow <= 7; dow++) { LocalDate result = day.with(dowField, dow); - if (result.get(dowField) != dow) { - System.err.printf(" DOW actual: %d, expected: %d, week:%s%n", - result.get(dowField), dow, week); - } - if (result.get(womField) != wom) { - System.err.printf(" WOM actual: %d, expected: %d, week:%s%n", - result.get(womField), wom, week); - } - if (result.get(woyField) != woy) { - System.err.printf(" WOY actual: %d, expected: %d, week:%s%n", - result.get(woyField), woy, week); - } assertEquals(result.get(dowField), dow, String.format("Incorrect new Day of week: %s", result)); assertEquals(result.get(womField), wom, "Week of Month should not change"); assertEquals(result.get(woyField), woy, "Week of Year should not change"); } } + @Test(dataProvider="weekFields") + public void test_rangeWeekOfWeekBasedYear(DayOfWeek firstDayOfWeek, int minDays) { + WeekFields weekFields = WeekFields.of(firstDayOfWeek, minDays); + TemporalField dowField = weekFields.dayOfWeek(); + TemporalField wowByField = weekFields.weekOfWeekBasedYear(); + + LocalDate day1 = LocalDate.of(2012, 1, weekFields.getMinimalDaysInFirstWeek()); + day1 = day1.with(wowByField, 1).with(dowField, 1); + + LocalDate day2 = LocalDate.of(2013, 1, weekFields.getMinimalDaysInFirstWeek()); + day2 = day2.with(wowByField, 1).with(dowField, 1); + + int expectedWeeks = (int)ChronoUnit.DAYS.between(day1, day2) / 7; + + ValueRange range = day1.range(wowByField); + assertEquals(range.getMaximum(), expectedWeeks, "Range incorrect"); + } + + @Test(dataProvider="weekFields") + public void test_withWeekOfWeekBasedYear(DayOfWeek firstDayOfWeek, int minDays) { + LocalDate day = LocalDate.of(2012, 12, 31); + WeekFields week = WeekFields.of(firstDayOfWeek, minDays); + TemporalField dowField = week.dayOfWeek(); + TemporalField wowbyField = week.weekOfWeekBasedYear(); + TemporalField yowbyField = week.weekBasedYear(); + + int dowExpected = (day.get(dowField) - 1) % 7 + 1; + LocalDate dowDate = day.with(dowField, dowExpected); + int dowResult = dowDate.get(dowField); + assertEquals(dowResult, dowExpected, "Localized DayOfWeek not correct; " + day + " -->" + dowDate); + + int weekExpected = day.get(wowbyField) + 1; + ValueRange range = day.range(wowbyField); + weekExpected = ((weekExpected - 1) % (int)range.getMaximum()) + 1; + LocalDate weekDate = day.with(wowbyField, weekExpected); + int weekResult = weekDate.get(wowbyField); + assertEquals(weekResult, weekExpected, "Localized WeekOfWeekBasedYear not correct; " + day + " -->" + weekDate); + + int yearExpected = day.get(yowbyField) + 1; + + LocalDate yearDate = day.with(yowbyField, yearExpected); + int yearResult = yearDate.get(yowbyField); + assertEquals(yearResult, yearExpected, "Localized WeekBasedYear not correct; " + day + " --> " + yearDate); + + range = yearDate.range(wowbyField); + weekExpected = Math.min(day.get(wowbyField), (int)range.getMaximum()); + + int weekActual = yearDate.get(wowbyField); + assertEquals(weekActual, weekExpected, "Localized WeekOfWeekBasedYear week should not change; " + day + " --> " + yearDate + ", actual: " + weekActual + ", weekExpected: " + weekExpected); + } + //----------------------------------------------------------------------- @Test(dataProvider="weekFields") public void test_parse_resolve_localizedWom(DayOfWeek firstDayOfWeek, int minDays) { @@ -381,6 +466,29 @@ public class TCKWeekFields extends AbstractTCKTest { } } + @Test(dataProvider="weekFields") + public void test_parse_resolve_localizedWoWBY(DayOfWeek firstDayOfWeek, int minDays) { + LocalDate date = LocalDate.of(2012, 12, 31); + WeekFields week = WeekFields.of(firstDayOfWeek, minDays); + TemporalField dowField = week.dayOfWeek(); + TemporalField wowbyField = week.weekOfWeekBasedYear(); + TemporalField yowbyField = week.weekBasedYear(); + + for (int i = 1; i <= 60; i++) { + // Test that with dayOfWeek, week of year and year of week-based-year it computes the date + DateTimeFormatter f = new DateTimeFormatterBuilder() + .appendValue(yowbyField).appendLiteral('-') + .appendValue(wowbyField).appendLiteral('-') + .appendValue(dowField).toFormatter(); + String str = date.get(yowbyField) + "-" + date.get(wowbyField) + "-" + + date.get(dowField); + LocalDate parsed = LocalDate.parse(str, f); + assertEquals(parsed, date, " :: " + str + " " + i); + + date = date.plusDays(1); + } + } + //----------------------------------------------------------------------- @Test(dataProvider="weekFields") public void test_serializable_singleton(DayOfWeek firstDayOfWeek, int minDays) throws IOException, ClassNotFoundException { @@ -401,4 +509,67 @@ public class TCKWeekFields extends AbstractTCKTest { return objects; } + //----------------------------------------------------------------------- + @DataProvider(name="WeekBasedYearData") + Object[][] provider_WeekBasedYearData() { + return new Object[][] { + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2008, 52, 7, LocalDate.of(2008, 12, 27)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 1, 1, LocalDate.of(2008, 12, 28)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 1, 2, LocalDate.of(2008, 12, 29)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 1, 3, LocalDate.of(2008, 12, 30)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 1, 4, LocalDate.of(2008, 12, 31)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 1, 5, LocalDate.of(2009, 1, 1)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 2, 1, LocalDate.of(2009, 1, 4)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 2, 2, LocalDate.of(2009, 1, 5)}, + {WeekFields.of(DayOfWeek.SUNDAY, 1), 2009, 2, 3, LocalDate.of(2009, 1, 6)}, + }; + } + + @Test(dataProvider="WeekBasedYearData") + public void test_weekBasedYears(WeekFields weekDef, int weekBasedYear, + int weekOfWeekBasedYear, int dayOfWeek, LocalDate date) { + TemporalField dowField = weekDef.dayOfWeek(); + TemporalField wowbyField = weekDef.weekOfWeekBasedYear(); + TemporalField yowbyField = weekDef.weekBasedYear(); + assertEquals(date.get(dowField), dayOfWeek, "DayOfWeek mismatch"); + assertEquals(date.get(wowbyField), weekOfWeekBasedYear, "Week of WeekBasedYear mismatch"); + assertEquals(date.get(yowbyField), weekBasedYear, "Year of WeekBasedYear mismatch"); + } + + + //----------------------------------------------------------------------- + @DataProvider(name="IsoWeekData") + Object[][] data_week() { + return new Object[][] { + {LocalDate.of(1969, 12, 29), DayOfWeek.MONDAY, 1, 1970}, + {LocalDate.of(2012, 12, 23), DayOfWeek.SUNDAY, 51, 2012}, + {LocalDate.of(2012, 12, 24), DayOfWeek.MONDAY, 52, 2012}, + {LocalDate.of(2012, 12, 27), DayOfWeek.THURSDAY, 52, 2012}, + {LocalDate.of(2012, 12, 28), DayOfWeek.FRIDAY, 52, 2012}, + {LocalDate.of(2012, 12, 29), DayOfWeek.SATURDAY, 52, 2012}, + {LocalDate.of(2012, 12, 30), DayOfWeek.SUNDAY, 52, 2012}, + {LocalDate.of(2012, 12, 31), DayOfWeek.MONDAY, 1, 2013}, + {LocalDate.of(2013, 1, 1), DayOfWeek.TUESDAY, 1, 2013}, + {LocalDate.of(2013, 1, 2), DayOfWeek.WEDNESDAY, 1, 2013}, + {LocalDate.of(2013, 1, 6), DayOfWeek.SUNDAY, 1, 2013}, + {LocalDate.of(2013, 1, 7), DayOfWeek.MONDAY, 2, 2013}, + }; + } + + //----------------------------------------------------------------------- + // WEEK_OF_WEEK_BASED_YEAR + // Validate with the same data used by IsoFields. + //----------------------------------------------------------------------- + @Test(dataProvider="IsoWeekData") + public void test_WOWBY(LocalDate date, DayOfWeek dow, int week, int wby) { + WeekFields weekDef = WeekFields.ISO; + TemporalField dowField = weekDef.dayOfWeek(); + TemporalField wowbyField = weekDef.weekOfWeekBasedYear(); + TemporalField yowbyField = weekDef.weekBasedYear(); + + assertEquals(date.get(dowField), dow.getValue()); + assertEquals(date.get(wowbyField), week); + assertEquals(date.get(yowbyField), wby); + } + } diff --git a/jdk/test/java/time/tck/java/time/temporal/TestChronoLocalDate.java b/jdk/test/java/time/tck/java/time/temporal/TestChronoLocalDate.java deleted file mode 100644 index 6d156839dc8..00000000000 --- a/jdk/test/java/time/tck/java/time/temporal/TestChronoLocalDate.java +++ /dev/null @@ -1,503 +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. 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. - */ - -/* - * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * * Neither the name of JSR-310 nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tck.java.time.temporal; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.time.Duration; -import java.time.LocalDate; -import java.time.chrono.Chronology; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.IsoChronology; -import java.time.temporal.ChronoUnit; -import java.time.temporal.Temporal; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalAdjuster; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalField; -import java.time.temporal.TemporalUnit; -import java.time.temporal.ValueRange; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -/** - * Test assertions that must be true for the built-in ISO chronology. - */ -@Test -public class TestChronoLocalDate { - - //----------------------------------------------------------------------- - // regular data factory for names and descriptions of ISO calendar - //----------------------------------------------------------------------- - @DataProvider(name = "calendars") - Chronology[][] data_of_calendars() { - return new Chronology[][]{ - {IsoChronology.INSTANCE}, - }; - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badWithAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalAdjuster adjuster = new FixedAdjuster(date2); - if (chrono != chrono2) { - try { - date.with(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException"); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.with(adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalAmount adjuster = new FixedAdjuster(date2); - if (chrono != chrono2) { - try { - date.plus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException"); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.plus(adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusAdjusterChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalAmount adjuster = new FixedAdjuster(date2); - if (chrono != chrono2) { - try { - date.minus(adjuster); - Assert.fail("WithAdjuster should have thrown a ClassCastException"); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.minus(adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badPlusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalUnit adjuster = new FixedTemporalUnit(date2); - if (chrono != chrono2) { - try { - date.plus(1, adjuster); - Assert.fail("TemporalUnit.doPlus plus should have thrown a ClassCastException" + date.getClass() - + ", can not be cast to " + date2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.plus(1, adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badMinusTemporalUnitChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalUnit adjuster = new FixedTemporalUnit(date2); - if (chrono != chrono2) { - try { - date.minus(1, adjuster); - Assert.fail("TemporalUnit.doPlus minus should have thrown a ClassCastException" + date.getClass() - + ", can not be cast to " + date2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.minus(1, adjuster); - assertEquals(result, date2, "WithAdjuster failed to replace date"); - } - } - } - - @Test(groups={"tck"}, dataProvider="calendars") - public void test_badTemporalFieldChrono(Chronology chrono) { - LocalDate refDate = LocalDate.of(1900, 1, 1); - ChronoLocalDate date = chrono.date(refDate); - for (Chronology[] clist : data_of_calendars()) { - Chronology chrono2 = clist[0]; - ChronoLocalDate date2 = chrono2.date(refDate); - TemporalField adjuster = new FixedTemporalField(date2); - if (chrono != chrono2) { - try { - date.with(adjuster, 1); - Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + date.getClass() - + ", can not be cast to " + date2.getClass()); - } catch (ClassCastException cce) { - // Expected exception; not an error - } - } else { - // Same chronology, - ChronoLocalDate result = date.with(adjuster, 1); - assertEquals(result, date2, "TemporalField doWith() failed to replace date"); - } - } - } - - //----------------------------------------------------------------------- - // isBefore, isAfter, isEqual, DATE_COMPARATOR - //----------------------------------------------------------------------- - @Test(groups={"tck"}, dataProvider="calendars") - public void test_date_comparisons(Chronology chrono) { - List dates = new ArrayList<>(); - - ChronoLocalDate date = chrono.date(LocalDate.of(1900, 1, 1)); - - // Insert dates in order, no duplicates - dates.add(date.minus(1000, ChronoUnit.YEARS)); - dates.add(date.minus(100, ChronoUnit.YEARS)); - dates.add(date.minus(10, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.MONTHS)); - dates.add(date.minus(1, ChronoUnit.WEEKS)); - dates.add(date.minus(1, ChronoUnit.DAYS)); - dates.add(date); - dates.add(date.plus(1, ChronoUnit.DAYS)); - dates.add(date.plus(1, ChronoUnit.WEEKS)); - dates.add(date.plus(1, ChronoUnit.MONTHS)); - dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(10, ChronoUnit.YEARS)); - dates.add(date.plus(100, ChronoUnit.YEARS)); - dates.add(date.plus(1000, ChronoUnit.YEARS)); - - // Check these dates against the corresponding dates for every calendar - for (Chronology[] clist : data_of_calendars()) { - List otherDates = new ArrayList<>(); - Chronology chrono2 = clist[0]; - for (ChronoLocalDate d : dates) { - otherDates.add(chrono2.date(d)); - } - - // Now compare the sequence of original dates with the sequence of converted dates - for (int i = 0; i < dates.size(); i++) { - ChronoLocalDate a = dates.get(i); - for (int j = 0; j < otherDates.size(); j++) { - ChronoLocalDate b = otherDates.get(j); - int cmp = ChronoLocalDate.DATE_COMPARATOR.compare(a, b); - if (i < j) { - assertTrue(cmp < 0, a + " compare " + b); - assertEquals(a.isBefore(b), true, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else if (i > j) { - assertTrue(cmp > 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), true, a + " isAfter " + b); - assertEquals(a.isEqual(b), false, a + " isEqual " + b); - } else { - assertTrue(cmp == 0, a + " compare " + b); - assertEquals(a.isBefore(b), false, a + " isBefore " + b); - assertEquals(a.isAfter(b), false, a + " isAfter " + b); - assertEquals(a.isEqual(b), true, a + " isEqual " + b); - } - } - } - } - } - - public void test_date_comparator_checkGenerics_ISO() { - List dates = new ArrayList<>(); - LocalDate date = LocalDate.of(1900, 1, 1); - - // Insert dates in order, no duplicates - dates.add(date.minus(10, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.MONTHS)); - dates.add(date.minus(1, ChronoUnit.WEEKS)); - dates.add(date.minus(1, ChronoUnit.DAYS)); - dates.add(date); - dates.add(date.plus(1, ChronoUnit.DAYS)); - dates.add(date.plus(1, ChronoUnit.WEEKS)); - dates.add(date.plus(1, ChronoUnit.MONTHS)); - dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(10, ChronoUnit.YEARS)); - - List copy = new ArrayList<>(dates); - Collections.shuffle(copy); - Collections.sort(copy, ChronoLocalDate.DATE_COMPARATOR); - assertEquals(copy, dates); - assertTrue(ChronoLocalDate.DATE_COMPARATOR.compare(copy.get(0), copy.get(1)) < 0); - } - - public void test_date_comparator_checkGenerics_LocalDate() { - List dates = new ArrayList<>(); - LocalDate date = LocalDate.of(1900, 1, 1); - - // Insert dates in order, no duplicates - dates.add(date.minus(10, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.YEARS)); - dates.add(date.minus(1, ChronoUnit.MONTHS)); - dates.add(date.minus(1, ChronoUnit.WEEKS)); - dates.add(date.minus(1, ChronoUnit.DAYS)); - dates.add(date); - dates.add(date.plus(1, ChronoUnit.DAYS)); - dates.add(date.plus(1, ChronoUnit.WEEKS)); - dates.add(date.plus(1, ChronoUnit.MONTHS)); - dates.add(date.plus(1, ChronoUnit.YEARS)); - dates.add(date.plus(10, ChronoUnit.YEARS)); - - List copy = new ArrayList<>(dates); - Collections.shuffle(copy); - Collections.sort(copy, ChronoLocalDate.DATE_COMPARATOR); - assertEquals(copy, dates); - assertTrue(ChronoLocalDate.DATE_COMPARATOR.compare(copy.get(0), copy.get(1)) < 0); - } - - //----------------------------------------------------------------------- - // Test Serialization of ISO via chrono API - //----------------------------------------------------------------------- - @Test( groups={"tck"}, dataProvider="calendars") - public void test_ChronoSerialization(Chronology chrono) throws Exception { - LocalDate ref = LocalDate.of(2000, 1, 5); - ChronoLocalDate orginal = chrono.date(ref); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); - out.writeObject(orginal); - out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - ObjectInputStream in = new ObjectInputStream(bais); - @SuppressWarnings("unchecked") - ChronoLocalDate ser = (ChronoLocalDate) in.readObject(); - assertEquals(ser, orginal, "deserialized date is wrong"); - } - - /** - * FixedAdjusted returns a fixed Temporal in all adjustments. - * Construct an adjuster with the Temporal that should be returned from adjust. - */ - static class FixedAdjuster implements TemporalAdjuster, TemporalAmount { - private Temporal datetime; - - FixedAdjuster(Temporal datetime) { - this.datetime = datetime; - } - - @Override - public Temporal adjustInto(Temporal ignore) { - return datetime; - } - - @Override - public Temporal addTo(Temporal ignore) { - return datetime; - } - - @Override - public Temporal subtractFrom(Temporal ignore) { - return datetime; - } - - @Override - public long get(TemporalUnit unit) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public List getUnits() { - throw new UnsupportedOperationException("Not supported yet."); - } - - } - - /** - * FixedTemporalUnit returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalUnit with the Temporal that should be returned from addTo. - */ - static class FixedTemporalUnit implements TemporalUnit { - private Temporal temporal; - - FixedTemporalUnit(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalUnit"; - } - - @Override - public Duration getDuration() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isDurationEstimated() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(Temporal temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R addTo(R temporal, long amount) { - return (R) this.temporal; - } - - @Override - public long between(Temporal temporal1, Temporal temporal2) { - throw new UnsupportedOperationException("Not supported yet."); - } - } - - /** - * FixedTemporalField returns a fixed Temporal in all adjustments. - * Construct an FixedTemporalField with the Temporal that should be returned from adjustInto. - */ - static class FixedTemporalField implements TemporalField { - private Temporal temporal; - FixedTemporalField(Temporal temporal) { - this.temporal = temporal; - } - - @Override - public String getName() { - return "FixedTemporalField"; - } - - @Override - public TemporalUnit getBaseUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public TemporalUnit getRangeUnit() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange range() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isSupportedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public ValueRange rangeRefinedBy(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getFrom(TemporalAccessor temporal) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @SuppressWarnings("unchecked") - @Override - public R adjustInto(R temporal, long newValue) { - return (R) this.temporal; - } - } -} diff --git a/jdk/test/java/time/tck/java/time/zone/TCKFixedZoneRules.java b/jdk/test/java/time/tck/java/time/zone/TCKFixedZoneRules.java index 3cf6053a2da..418d1ad9ec2 100644 --- a/jdk/test/java/time/tck/java/time/zone/TCKFixedZoneRules.java +++ b/jdk/test/java/time/tck/java/time/zone/TCKFixedZoneRules.java @@ -65,7 +65,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; - import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; @@ -108,7 +107,7 @@ public class TCKFixedZoneRules { //----------------------------------------------------------------------- // Basics //----------------------------------------------------------------------- - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_serialization(ZoneRules test, ZoneOffset expectedOffset) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); @@ -127,19 +126,19 @@ public class TCKFixedZoneRules { //----------------------------------------------------------------------- // basics //----------------------------------------------------------------------- - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getOffset_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getOffset(INSTANT), expectedOffset); assertEquals(test.getOffset((Instant) null), expectedOffset); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getOffset_LocalDateTime(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getOffset(LDT), expectedOffset); assertEquals(test.getOffset((LocalDateTime) null), expectedOffset); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getValidOffsets_LDT(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getValidOffsets(LDT).size(), 1); assertEquals(test.getValidOffsets(LDT).get(0), expectedOffset); @@ -147,13 +146,13 @@ public class TCKFixedZoneRules { assertEquals(test.getValidOffsets(null).get(0), expectedOffset); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getTransition_LDT(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getTransition(LDT), null); assertEquals(test.getTransition(null), null); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_isValidOffset_LDT_ZO(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.isValidOffset(LDT, expectedOffset), true); assertEquals(test.isValidOffset(LDT, ZoneOffset.UTC), false); @@ -164,55 +163,55 @@ public class TCKFixedZoneRules { assertEquals(test.isValidOffset(null, null), false); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getStandardOffset_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getStandardOffset(INSTANT), expectedOffset); assertEquals(test.getStandardOffset(null), expectedOffset); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getDaylightSavings_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getDaylightSavings(INSTANT), Duration.ZERO); assertEquals(test.getDaylightSavings(null), Duration.ZERO); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_isDaylightSavings_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.isDaylightSavings(INSTANT), false); assertEquals(test.isDaylightSavings(null), false); } //------------------------------------------------------------------------- - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_nextTransition_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.nextTransition(INSTANT), null); assertEquals(test.nextTransition(null), null); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_previousTransition_Instant(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.previousTransition(INSTANT), null); assertEquals(test.previousTransition(null), null); } //------------------------------------------------------------------------- - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getTransitions(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getTransitions().size(), 0); } - @Test(expectedExceptions=UnsupportedOperationException.class, groups="tck") + @Test(expectedExceptions=UnsupportedOperationException.class) public void test_getTransitions_immutable() { ZoneRules test = make(OFFSET_PTWO); test.getTransitions().add(ZoneOffsetTransition.of(LDT, OFFSET_PONE, OFFSET_PTWO)); } - @Test(groups="tck", dataProvider="rules") + @Test(dataProvider="rules") public void test_getTransitionRules(ZoneRules test, ZoneOffset expectedOffset) { assertEquals(test.getTransitionRules().size(), 0); } - @Test(expectedExceptions=UnsupportedOperationException.class, groups="tck") + @Test(expectedExceptions=UnsupportedOperationException.class) public void test_getTransitionRules_immutable() { ZoneRules test = make(OFFSET_PTWO); test.getTransitionRules().add(ZoneOffsetTransitionRule.of(Month.JULY, 2, null, LocalTime.of(12, 30), false, TimeDefinition.STANDARD, OFFSET_PONE, OFFSET_PTWO, OFFSET_PONE)); @@ -221,7 +220,7 @@ public class TCKFixedZoneRules { //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- - @Test(groups="tck") + @Test public void test_equalsHashCode() { ZoneRules a = make(OFFSET_PONE); ZoneRules b = make(OFFSET_PTWO); diff --git a/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java b/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java index f98b82f1f18..c5da309d872 100644 --- a/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java +++ b/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java @@ -62,13 +62,14 @@ package tck.java.time.zone; import static java.time.temporal.ChronoUnit.HOURS; import static org.testng.Assert.assertEquals; -import tck.java.time.AbstractTCKTest; import java.time.Duration; import java.time.LocalDateTime; -import java.time.ZoneOffset; import java.time.Year; +import java.time.ZoneOffset; import java.time.zone.ZoneOffsetTransition; + import org.testng.annotations.Test; +import tck.java.time.AbstractTCKTest; /** * Test ZoneOffsetTransition. @@ -85,27 +86,27 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { //----------------------------------------------------------------------- // factory //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullTransition() { ZoneOffsetTransition.of(null, OFFSET_0100, OFFSET_0200); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullOffsetBefore() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), null, OFFSET_0200); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullOffsetAfter() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, null); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_sameOffset() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, OFFSET_0200); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_noNanos() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30, 0, 500), OFFSET_0200, OFFSET_0300); } @@ -113,7 +114,7 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { //----------------------------------------------------------------------- // getters //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_getters_gap() throws Exception { LocalDateTime before = LocalDateTime.of(2010, 3, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 3, 31, 2, 0); @@ -129,7 +130,7 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { assertSerializable(test); } - @Test(groups={"tck"}) + @Test public void test_getters_overlap() throws Exception { LocalDateTime before = LocalDateTime.of(2010, 10, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 10, 31, 0, 0); @@ -163,7 +164,7 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { //----------------------------------------------------------------------- // isValidOffset() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_isValidOffset_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); @@ -174,7 +175,7 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { assertEquals(test.isValidOffset(OFFSET_0400), false); } - @Test(groups={"tck"}) + @Test public void test_isValidOffset_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); @@ -188,7 +189,7 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { //----------------------------------------------------------------------- // compareTo() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_compareTo() { ZoneOffsetTransition a = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L - 1, 0, OFFSET_0200), OFFSET_0200, OFFSET_0300); @@ -210,7 +211,7 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { assertEquals(c.compareTo(c) == 0, true); } - @Test(groups={"tck"}) + @Test public void test_compareTo_sameInstant() { ZoneOffsetTransition a = ZoneOffsetTransition.of( LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0200), OFFSET_0200, OFFSET_0300); @@ -235,7 +236,7 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals() { LocalDateTime ldtA = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition a1 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); @@ -260,7 +261,7 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_hashCode_floatingWeek_gap_notEndOfDay() { LocalDateTime ldtA = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition a1 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); @@ -276,14 +277,14 @@ public class TCKZoneOffsetTransition extends AbstractTCKTest { //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); assertEquals(test.toString(), "Transition[Gap at 2010-03-31T01:00+02:00 to +03:00]"); } - @Test(groups={"tck"}) + @Test public void test_toString_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); diff --git a/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java b/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java index c98ddf02102..fedded75337 100644 --- a/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java +++ b/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java @@ -61,7 +61,6 @@ package tck.java.time.zone; import static org.testng.Assert.assertEquals; -import tck.java.time.AbstractTCKTest; import java.time.DayOfWeek; import java.time.LocalDateTime; import java.time.LocalTime; @@ -72,6 +71,7 @@ import java.time.zone.ZoneOffsetTransitionRule; import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; import org.testng.annotations.Test; +import tck.java.time.AbstractTCKTest; /** * Test ZoneOffsetTransitionRule. @@ -86,70 +86,70 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { //----------------------------------------------------------------------- // factory //----------------------------------------------------------------------- - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullMonth() { ZoneOffsetTransitionRule.of( null, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullTime() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, null, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullTimeDefinition() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, null, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullStandardOffset() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, null, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullOffsetBefore() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, null, OFFSET_0300); } - @Test(expectedExceptions=NullPointerException.class, groups={"tck"}) + @Test(expectedExceptions=NullPointerException.class) public void test_factory_nullOffsetAfter() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, null); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_invalidDayOfMonthIndicator_tooSmall() { ZoneOffsetTransitionRule.of( Month.MARCH, -29, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_invalidDayOfMonthIndicator_zero() { ZoneOffsetTransitionRule.of( Month.MARCH, 0, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_invalidDayOfMonthIndicator_tooLarge() { ZoneOffsetTransitionRule.of( Month.MARCH, 32, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); } - @Test(expectedExceptions=IllegalArgumentException.class, groups={"tck"}) + @Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_invalidMidnightFlag() { ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, true, TimeDefinition.WALL, @@ -239,7 +239,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { //----------------------------------------------------------------------- // createTransition() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_createTransition_floatingWeek_gap_notEndOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -249,7 +249,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(test.createTransition(2000), trans); } - @Test(groups={"tck"}) + @Test public void test_createTransition_floatingWeek_overlap_endOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, @@ -259,7 +259,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(test.createTransition(2000), trans); } - @Test(groups={"tck"}) + @Test public void test_createTransition_floatingWeekBackwards_last() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -269,7 +269,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(test.createTransition(2000), trans); } - @Test(groups={"tck"}) + @Test public void test_createTransition_floatingWeekBackwards_seventhLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -7, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -279,7 +279,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(test.createTransition(2000), trans); } - @Test(groups={"tck"}) + @Test public void test_createTransition_floatingWeekBackwards_secondLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -289,7 +289,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(test.createTransition(2000), trans); } - @Test(groups={"tck"}) + @Test public void test_createTransition_fixedDate() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, @@ -302,7 +302,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { //----------------------------------------------------------------------- // equals() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_equals_monthDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -316,7 +316,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_dayOfMonthDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -330,7 +330,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_dayOfWeekDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -344,7 +344,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_dayOfWeekDifferentNull() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -358,7 +358,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_localTimeDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -372,7 +372,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_endOfDayDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, false, TimeDefinition.WALL, @@ -386,7 +386,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_timeDefinitionDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -400,7 +400,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_standardOffsetDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -414,7 +414,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_offsetBeforeDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -428,7 +428,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_offsetAfterDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -442,7 +442,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(b.equals(b), true); } - @Test(groups={"tck"}) + @Test public void test_equals_string_false() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -450,7 +450,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(a.equals("TZDB"), false); } - @Test(groups={"tck"}) + @Test public void test_equals_null_false() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -461,7 +461,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_hashCode_floatingWeek_gap_notEndOfDay() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -472,7 +472,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_hashCode_floatingWeek_overlap_endOfDay_nullDayOfWeek() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.OCTOBER, 20, null, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, @@ -483,7 +483,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_hashCode_floatingWeekBackwards() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -494,7 +494,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(a.hashCode(), b.hashCode()); } - @Test(groups={"tck"}) + @Test public void test_hashCode_fixedDate() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, @@ -508,7 +508,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { //----------------------------------------------------------------------- // toString() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_toString_floatingWeek_gap_notEndOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -516,7 +516,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or after MARCH 20 at 01:00 WALL, standard offset +02:00]"); } - @Test(groups={"tck"}) + @Test public void test_toString_floatingWeek_overlap_endOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.OCTOBER, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, @@ -524,7 +524,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(test.toString(), "TransitionRule[Overlap +03:00 to +02:00, SUNDAY on or after OCTOBER 20 at 24:00 WALL, standard offset +02:00]"); } - @Test(groups={"tck"}) + @Test public void test_toString_floatingWeekBackwards_last() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -532,7 +532,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day of MARCH at 01:00 WALL, standard offset +02:00]"); } - @Test(groups={"tck"}) + @Test public void test_toString_floatingWeekBackwards_secondLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, @@ -540,7 +540,7 @@ public class TCKZoneOffsetTransitionRule extends AbstractTCKTest { assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day minus 1 of MARCH at 01:00 WALL, standard offset +02:00]"); } - @Test(groups={"tck"}) + @Test public void test_toString_fixedDate() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, diff --git a/jdk/test/java/time/tck/java/time/zone/TCKZoneRules.java b/jdk/test/java/time/tck/java/time/zone/TCKZoneRules.java index 5feac51ecac..4cc630d50be 100644 --- a/jdk/test/java/time/tck/java/time/zone/TCKZoneRules.java +++ b/jdk/test/java/time/tck/java/time/zone/TCKZoneRules.java @@ -68,9 +68,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.util.Iterator; -import java.util.List; - import java.time.DayOfWeek; import java.time.Duration; import java.time.Instant; @@ -86,6 +83,8 @@ import java.time.zone.ZoneOffsetTransition; import java.time.zone.ZoneOffsetTransitionRule; import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition; import java.time.zone.ZoneRules; +import java.util.Iterator; +import java.util.List; import org.testng.annotations.Test; diff --git a/jdk/test/java/time/tck/java/time/zone/TCKZoneRulesProvider.java b/jdk/test/java/time/tck/java/time/zone/TCKZoneRulesProvider.java index a8081268ee4..a30424f4572 100644 --- a/jdk/test/java/time/tck/java/time/zone/TCKZoneRulesProvider.java +++ b/jdk/test/java/time/tck/java/time/zone/TCKZoneRulesProvider.java @@ -59,23 +59,21 @@ */ package tck.java.time.zone; -import java.time.ZoneId; - import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.zone.ZoneRules; +import java.time.zone.ZoneRulesException; +import java.time.zone.ZoneRulesProvider; import java.util.Collections; import java.util.HashSet; import java.util.NavigableMap; import java.util.Set; import java.util.TreeMap; -import java.time.ZoneOffset; -import java.time.zone.ZoneRules; -import java.time.zone.ZoneRulesException; -import java.time.zone.ZoneRulesProvider; - import org.testng.annotations.Test; /** @@ -172,7 +170,7 @@ public class TCKZoneRulesProvider { //----------------------------------------------------------------------- // registerProvider() //----------------------------------------------------------------------- - @Test(groups={"tck"}) + @Test public void test_registerProvider() { Set pre = ZoneRulesProvider.getAvailableZoneIds(); assertEquals(pre.contains("FooLocation"), false); diff --git a/jdk/test/java/time/test/java/time/MockSimplePeriod.java b/jdk/test/java/time/test/java/time/MockSimplePeriod.java index 662c8b12100..2d8f7d5ba9c 100644 --- a/jdk/test/java/time/test/java/time/MockSimplePeriod.java +++ b/jdk/test/java/time/test/java/time/MockSimplePeriod.java @@ -59,19 +59,16 @@ */ package test.java.time; -import java.time.*; - import static java.time.temporal.ChronoUnit.DAYS; import static java.time.temporal.ChronoUnit.FOREVER; import static java.time.temporal.ChronoUnit.SECONDS; -import java.util.Objects; - +import java.time.DateTimeException; import java.time.temporal.Temporal; import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalUnit; import java.util.List; +import java.util.Objects; /** * Mock period of time measured using a single unit, such as {@code 3 Days}. diff --git a/jdk/test/java/time/test/java/time/TestClock_System.java b/jdk/test/java/time/test/java/time/TestClock_System.java index 00e9bbffe84..881a76060a1 100644 --- a/jdk/test/java/time/test/java/time/TestClock_System.java +++ b/jdk/test/java/time/test/java/time/TestClock_System.java @@ -59,11 +59,12 @@ */ package test.java.time; -import java.time.*; - import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertSame; +import java.time.Clock; +import java.time.ZoneId; + import org.testng.annotations.Test; /** diff --git a/jdk/test/java/time/test/java/time/TestDuration.java b/jdk/test/java/time/test/java/time/TestDuration.java index 786bfc0f05f..23aedd84aa5 100644 --- a/jdk/test/java/time/test/java/time/TestDuration.java +++ b/jdk/test/java/time/test/java/time/TestDuration.java @@ -65,11 +65,9 @@ import static org.testng.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; - import java.time.Duration; import org.testng.annotations.Test; @@ -87,7 +85,7 @@ public class TestDuration extends AbstractTest { } //----------------------------------------------------------------------- - @Test(groups={"implementation"}) + @Test public void test_interfaces() { assertTrue(Serializable.class.isAssignableFrom(Duration.class)); assertTrue(Comparable.class.isAssignableFrom(Duration.class)); @@ -96,7 +94,7 @@ public class TestDuration extends AbstractTest { //----------------------------------------------------------------------- // serialization //----------------------------------------------------------------------- - @Test(groups={"implementation"}) + @Test public void test_deserializationSingleton() throws Exception { Duration orginal = Duration.ZERO; ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -109,103 +107,103 @@ public class TestDuration extends AbstractTest { assertSame(ser, Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void plus_zeroReturnsThis() { Duration t = Duration.ofSeconds(-1); assertSame(t.plus(Duration.ZERO), t); } - @Test(groups={"implementation"}) + @Test public void plus_zeroSingleton() { Duration t = Duration.ofSeconds(-1); assertSame(t.plus(Duration.ofSeconds(1)), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void plusSeconds_zeroReturnsThis() { Duration t = Duration.ofSeconds(-1); assertSame(t.plusSeconds(0), t); } - @Test(groups={"implementation"}) + @Test public void plusSeconds_zeroSingleton() { Duration t = Duration.ofSeconds(-1); assertSame(t.plusSeconds(1), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void plusMillis_zeroReturnsThis() { Duration t = Duration.ofSeconds(-1, 2000000); assertSame(t.plusMillis(0), t); } - @Test(groups={"implementation"}) + @Test public void plusMillis_zeroSingleton() { Duration t = Duration.ofSeconds(-1, 2000000); assertSame(t.plusMillis(998), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void plusNanos_zeroReturnsThis() { Duration t = Duration.ofSeconds(-1, 2000000); assertSame(t.plusNanos(0), t); } - @Test(groups={"implementation"}) + @Test public void plusNanos_zeroSingleton() { Duration t = Duration.ofSeconds(-1, 2000000); assertSame(t.plusNanos(998000000), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void minus_zeroReturnsThis() { Duration t = Duration.ofSeconds(1); assertSame(t.minus(Duration.ZERO), t); } - @Test(groups={"implementation"}) + @Test public void minus_zeroSingleton() { Duration t = Duration.ofSeconds(1); assertSame(t.minus(Duration.ofSeconds(1)), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void minusSeconds_zeroReturnsThis() { Duration t = Duration.ofSeconds(1); assertSame(t.minusSeconds(0), t); } - @Test(groups={"implementation"}) + @Test public void minusSeconds_zeroSingleton() { Duration t = Duration.ofSeconds(1); assertSame(t.minusSeconds(1), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void minusMillis_zeroReturnsThis() { Duration t = Duration.ofSeconds(1, 2000000); assertSame(t.minusMillis(0), t); } - @Test(groups={"implementation"}) + @Test public void minusMillis_zeroSingleton() { Duration t = Duration.ofSeconds(1, 2000000); assertSame(t.minusMillis(1002), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void minusNanos_zeroReturnsThis() { Duration t = Duration.ofSeconds(1, 2000000); assertSame(t.minusNanos(0), t); } - @Test(groups={"implementation"}) + @Test public void minusNanos_zeroSingleton() { Duration t = Duration.ofSeconds(1, 2000000); assertSame(t.minusNanos(1002000000), Duration.ZERO); } - @Test(groups={"implementation"}) + @Test public void test_abs_same() { Duration base = Duration.ofSeconds(12); assertSame(base.abs(), base); diff --git a/jdk/test/java/time/test/java/time/TestLocalDate.java b/jdk/test/java/time/test/java/time/TestLocalDate.java index 44033123cdf..a6bd18c5bb3 100644 --- a/jdk/test/java/time/test/java/time/TestLocalDate.java +++ b/jdk/test/java/time/test/java/time/TestLocalDate.java @@ -80,7 +80,7 @@ public class TestLocalDate extends AbstractTest { private LocalDate TEST_2007_07_15; - @BeforeMethod(groups={"tck", "implementation"}) + @BeforeMethod public void setUp() { TEST_2007_07_15 = LocalDate.of(2007, 7, 15); } @@ -117,55 +117,55 @@ public class TestLocalDate extends AbstractTest { return date.withDayOfMonth(date.getMonth().length(isIsoLeap(date.getYear()))); } - @Test(groups={"implementation"}) + @Test public void test_with_DateTimeField_long_noChange_same() { LocalDate t = TEST_2007_07_15.with(YEAR, 2007); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_withYear_int_noChange_same() { LocalDate t = TEST_2007_07_15.withYear(2007); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_withMonth_int_noChange_same() { LocalDate t = TEST_2007_07_15.withMonth(7); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfMonth_noChange_same() { LocalDate t = TEST_2007_07_15.withDayOfMonth(15); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfYear_noChange_same() { LocalDate t = TEST_2007_07_15.withDayOfYear(31 + 28 + 31 + 30 + 31 + 30 + 15); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_plus_Period_zero() { LocalDate t = TEST_2007_07_15.plus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_plus_longPeriodUnit_zero() { LocalDate t = TEST_2007_07_15.plus(0, ChronoUnit.DAYS); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_plusYears_long_noChange_same() { LocalDate t = TEST_2007_07_15.plusYears(0); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_plusMonths_long_noChange_same() { LocalDate t = TEST_2007_07_15.plusMonths(0); assertSame(t, TEST_2007_07_15); @@ -206,7 +206,7 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="samplePlusWeeksSymmetry", groups={"implementation"}) + @Test(dataProvider="samplePlusWeeksSymmetry") public void test_plusWeeks_symmetry(LocalDate reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDate t = reference.plusWeeks(weeks).plusWeeks(-weeks); @@ -217,7 +217,7 @@ public class TestLocalDate extends AbstractTest { } } - @Test(groups={"implementation"}) + @Test public void test_plusWeeks_noChange_same() { LocalDate t = TEST_2007_07_15.plusWeeks(0); assertSame(t, TEST_2007_07_15); @@ -258,7 +258,7 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="samplePlusDaysSymmetry", groups={"implementation"}) + @Test(dataProvider="samplePlusDaysSymmetry") public void test_plusDays_symmetry(LocalDate reference) { for (int days = 0; days < 365 * 8; days++) { LocalDate t = reference.plusDays(days).plusDays(-days); @@ -269,31 +269,31 @@ public class TestLocalDate extends AbstractTest { } } - @Test(groups={"implementation"}) + @Test public void test_plusDays_noChange_same() { LocalDate t = TEST_2007_07_15.plusDays(0); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_minus_Period_zero() { LocalDate t = TEST_2007_07_15.minus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_minus_longPeriodUnit_zero() { LocalDate t = TEST_2007_07_15.minus(0, ChronoUnit.DAYS); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_minusYears_long_noChange_same() { LocalDate t = TEST_2007_07_15.minusYears(0); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_minusMonths_long_noChange_same() { LocalDate t = TEST_2007_07_15.minusMonths(0); assertSame(t, TEST_2007_07_15); @@ -334,7 +334,7 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="sampleMinusWeeksSymmetry", groups={"implementation"}) + @Test(dataProvider="sampleMinusWeeksSymmetry") public void test_minusWeeks_symmetry(LocalDate reference) { for (int weeks = 0; weeks < 365 * 8; weeks++) { LocalDate t = reference.minusWeeks(weeks).minusWeeks(-weeks); @@ -345,7 +345,7 @@ public class TestLocalDate extends AbstractTest { } } - @Test(groups={"implementation"}) + @Test public void test_minusWeeks_noChange_same() { LocalDate t = TEST_2007_07_15.minusWeeks(0); assertSame(t, TEST_2007_07_15); @@ -386,7 +386,7 @@ public class TestLocalDate extends AbstractTest { }; } - @Test(dataProvider="sampleMinusDaysSymmetry", groups={"implementation"}) + @Test(dataProvider="sampleMinusDaysSymmetry") public void test_minusDays_symmetry(LocalDate reference) { for (int days = 0; days < 365 * 8; days++) { LocalDate t = reference.minusDays(days).minusDays(-days); @@ -397,13 +397,13 @@ public class TestLocalDate extends AbstractTest { } } - @Test(groups={"implementation"}) + @Test public void test_minusDays_noChange_same() { LocalDate t = TEST_2007_07_15.minusDays(0); assertSame(t, TEST_2007_07_15); } - @Test(groups={"implementation"}) + @Test public void test_toEpochDay_fromMJDays_symmetry() { long date_0000_01_01 = -678941 - 40587; diff --git a/jdk/test/java/time/test/java/time/TestLocalDateTime.java b/jdk/test/java/time/test/java/time/TestLocalDateTime.java index 90c3927406f..80469ed0621 100644 --- a/jdk/test/java/time/test/java/time/TestLocalDateTime.java +++ b/jdk/test/java/time/test/java/time/TestLocalDateTime.java @@ -121,365 +121,365 @@ public class TestLocalDateTime extends AbstractTest { }; } - @Test(groups={"implementation"}) + @Test public void test_withYear_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withYear(2007); assertSame(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate()); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_withMonth_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withMonth(7); assertSame(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate()); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfMonth_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withDayOfMonth(15); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfYear_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withDayOfYear(31 + 28 + 31 + 30 + 31 + 30 + 15); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withHour_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withHour(12); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withHour_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0)).withHour(0); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_withHour_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0)).withHour(12); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_withMinute_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withMinute(30); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withMinute_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 1)).withMinute(0); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_withMinute_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 1)).withMinute(0); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_withSecond_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withSecond(40); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withSecond_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 0, 1)).withSecond(0); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_withSecond_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 0, 1)).withSecond(0); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_withNanoOfSecond_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.withNano(987654321); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_withNanoOfSecond_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 0, 0, 1)).withNano(0); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_withNanoOfSecond_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 0, 0, 1)).withNano(0); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_plus_adjuster_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plus(Period.ZERO); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plus_Period_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plus_longPeriodUnit_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plus(0, ChronoUnit.DAYS); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusYears_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(0); assertSame(TEST_2007_07_15_12_30_40_987654321, t); } - @Test(groups={"implementation"}) + @Test public void test_plusMonths_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMonths(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusWeeks_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusWeeks(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusDays_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusDays(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusHours_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusHours(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusHours_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(23, 0)).plusHours(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_plusHours_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(11, 0)).plusHours(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_plusMinutes_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMinutes(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusMinutes_noChange_oneDay_same() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusMinutes(24 * 60); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_plusMinutes_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(23, 59)).plusMinutes(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_plusMinutes_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(11, 59)).plusMinutes(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_plusSeconds_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusSeconds(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusSeconds_noChange_oneDay_same() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusSeconds(24 * 60 * 60); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_plusSeconds_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(23, 59, 59)).plusSeconds(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_plusSeconds_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(11, 59, 59)).plusSeconds(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_plusNanos_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusNanos(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_plusNanos_noChange_oneDay_same() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusNanos(24 * 60 * 60 * 1000000000L); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_plusNanos_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(23, 59, 59, 999999999)).plusNanos(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_plusNanos_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(11, 59, 59, 999999999)).plusNanos(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_minus_adjuster_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minus(Period.ZERO); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minus_Period_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minus_longPeriodUnit_zero() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minus(0, ChronoUnit.DAYS); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusYears_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusYears(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusMonths_int_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMonths(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusWeeks_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusWeeks(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusDays_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusDays(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusHours_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusHours(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusHours_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0)).minusHours(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_minusHours_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(13, 0)).minusHours(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_minusMinutes_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMinutes(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusMinutes_noChange_oneDay_same() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusMinutes(24 * 60); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_minusMinutes_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 1)).minusMinutes(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_minusMinutes_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 1)).minusMinutes(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_minusSeconds_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusSeconds(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusSeconds_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusSeconds(24 * 60 * 60); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1)); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_minusSeconds_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 0, 1)).minusSeconds(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_minusSeconds_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 0, 1)).minusSeconds(1); assertSame(t.toLocalTime(), LocalTime.NOON); } - @Test(groups={"implementation"}) + @Test public void test_minusNanos_noChange() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusNanos(0); assertSame(t, TEST_2007_07_15_12_30_40_987654321); } - @Test(groups={"implementation"}) + @Test public void test_minusNanos_noChange_oneDay() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusNanos(24 * 60 * 60 * 1000000000L); assertEquals(t.toLocalDate(), TEST_2007_07_15_12_30_40_987654321.toLocalDate().minusDays(1)); assertSame(t.toLocalTime(), TEST_2007_07_15_12_30_40_987654321.toLocalTime()); } - @Test(groups={"implementation"}) + @Test public void test_minusNanos_toMidnight() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(0, 0, 0, 1)).minusNanos(1); assertSame(t.toLocalTime(), LocalTime.MIDNIGHT); } - @Test(groups={"implementation"}) + @Test public void test_minusNanos_toMidday() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(12, 0, 0, 1)).minusNanos(1); assertSame(t.toLocalTime(), LocalTime.NOON); @@ -488,7 +488,7 @@ public class TestLocalDateTime extends AbstractTest { //----------------------------------------------------------------------- // toLocalDate() //----------------------------------------------------------------------- - @Test(dataProvider="sampleDates", groups={"implementation"}) + @Test(dataProvider="sampleDates") public void test_getDate(int year, int month, int day) { LocalDate d = LocalDate.of(year, month, day); LocalDateTime dt = LocalDateTime.of(d, LocalTime.MIDNIGHT); @@ -498,7 +498,7 @@ public class TestLocalDateTime extends AbstractTest { //----------------------------------------------------------------------- // toLocalTime() //----------------------------------------------------------------------- - @Test(dataProvider="sampleTimes", groups={"implementation"}) + @Test(dataProvider="sampleTimes") public void test_getTime(int h, int m, int s, int ns) { LocalTime t = LocalTime.of(h, m, s, ns); LocalDateTime dt = LocalDateTime.of(LocalDate.of(2011, 7, 30), t); diff --git a/jdk/test/java/time/test/java/time/TestLocalTime.java b/jdk/test/java/time/test/java/time/TestLocalTime.java index 47aa94a7ecd..ddd7b0f572e 100644 --- a/jdk/test/java/time/test/java/time/TestLocalTime.java +++ b/jdk/test/java/time/test/java/time/TestLocalTime.java @@ -87,51 +87,51 @@ public class TestLocalTime extends AbstractTest { } //----------------------------------------------------------------------- - @Test(groups={"tck","implementation"}) + @Test public void constant_MIDNIGHT() { check(LocalTime.MIDNIGHT, 0, 0, 0, 0); } - @Test(groups={"implementation"}) + @Test public void constant_MIDNIGHT_same() { assertSame(LocalTime.MIDNIGHT, LocalTime.MIDNIGHT); assertSame(LocalTime.MIDNIGHT, LocalTime.of(0, 0)); } - @Test(groups={"tck","implementation"}) + @Test public void constant_MIDDAY() { check(LocalTime.NOON, 12, 0, 0, 0); } - @Test(groups={"implementation"}) + @Test public void constant_MIDDAY_same() { assertSame(LocalTime.NOON, LocalTime.NOON); assertSame(LocalTime.NOON, LocalTime.of(12, 0)); } //----------------------------------------------------------------------- - @Test(groups={"tck","implementation"}) + @Test public void constant_MIN_TIME() { check(LocalTime.MIN, 0, 0, 0, 0); } - @Test(groups={"implementation"}) + @Test public void constant_MIN_TIME_same() { assertSame(LocalTime.MIN, LocalTime.of(0, 0)); } - @Test(groups={"tck","implementation"}) + @Test public void constant_MAX_TIME() { check(LocalTime.MAX, 23, 59, 59, 999999999); } - @Test(groups={"implementation"}) + @Test public void constant_MAX_TIME_same() { assertSame(LocalTime.NOON, LocalTime.NOON); assertSame(LocalTime.NOON, LocalTime.of(12, 0)); } - @Test(groups={"implementation"}) + @Test public void factory_time_2ints_singletons() { for (int i = 0; i < 24; i++) { LocalTime test1 = LocalTime.of(i, 0); @@ -140,7 +140,7 @@ public class TestLocalTime extends AbstractTest { } } - @Test(groups={"implementation"}) + @Test public void factory_time_3ints_singletons() { for (int i = 0; i < 24; i++) { LocalTime test1 = LocalTime.of(i, 0, 0); @@ -149,7 +149,7 @@ public class TestLocalTime extends AbstractTest { } } - @Test(groups={"implementation"}) + @Test public void factory_time_4ints_singletons() { for (int i = 0; i < 24; i++) { LocalTime test1 = LocalTime.of(i, 0, 0, 0); @@ -158,7 +158,7 @@ public class TestLocalTime extends AbstractTest { } } - @Test(groups={"implementation"}) + @Test public void factory_ofSecondOfDay_singletons() { for (int i = 0; i < 24; i++) { LocalTime test1 = LocalTime.ofSecondOfDay(i * 60L * 60L); @@ -167,7 +167,7 @@ public class TestLocalTime extends AbstractTest { } } - @Test(groups={"implementation"}) + @Test public void factory_ofNanoOfDay_singletons() { for (int i = 0; i < 24; i++) { LocalTime test1 = LocalTime.ofNanoOfDay(i * 1000000000L * 60L * 60L); diff --git a/jdk/test/java/time/test/java/time/TestMonthDay.java b/jdk/test/java/time/test/java/time/TestMonthDay.java index ebfdc6de6e5..b03878be1a5 100644 --- a/jdk/test/java/time/test/java/time/TestMonthDay.java +++ b/jdk/test/java/time/test/java/time/TestMonthDay.java @@ -78,7 +78,7 @@ public class TestMonthDay extends AbstractTest { private MonthDay TEST_07_15; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_07_15 = MonthDay.of(7, 15); } @@ -95,24 +95,24 @@ public class TestMonthDay extends AbstractTest { assertEquals(test.getDayOfMonth(), d); } - @Test(groups={"implementation"}) + @Test public void test_with_Month_noChangeSame() { MonthDay test = MonthDay.of(6, 30); assertSame(test.with(Month.JUNE), test); } - @Test(groups={"implementation"}) + @Test public void test_withMonth_int_noChangeSame() { MonthDay test = MonthDay.of(6, 30); assertSame(test.withMonth(6), test); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfMonth_noChangeSame() { MonthDay test = MonthDay.of(6, 30); assertSame(test.withDayOfMonth(30), test); } - @Test(groups={"implementation"}) + @Test public void test_adjustDate_same() { MonthDay test = MonthDay.of(6, 30); LocalDate date = LocalDate.of(2007, 6, 30); diff --git a/jdk/test/java/time/test/java/time/TestOffsetDateTime.java b/jdk/test/java/time/test/java/time/TestOffsetDateTime.java index 7766b5ffb3b..4279a433af7 100644 --- a/jdk/test/java/time/test/java/time/TestOffsetDateTime.java +++ b/jdk/test/java/time/test/java/time/TestOffsetDateTime.java @@ -64,8 +64,8 @@ import static org.testng.Assert.assertSame; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; -import java.time.ZoneOffset; import java.time.OffsetDateTime; +import java.time.ZoneOffset; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; @@ -81,7 +81,7 @@ public class TestOffsetDateTime extends AbstractTest { private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2); private OffsetDateTime TEST_2008_6_30_11_30_59_000000500; - @BeforeMethod(groups={"tck","implementation"}) + @BeforeMethod public void setUp() { TEST_2008_6_30_11_30_59_000000500 = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 500), OFFSET_PONE); } @@ -104,7 +104,7 @@ public class TestOffsetDateTime extends AbstractTest { }; } - @Test(dataProvider="sampleTimes", groups={"implementation"}) + @Test(dataProvider="sampleTimes") public void test_get_same(int y, int o, int d, int h, int m, int s, int n, ZoneOffset offset) { LocalDate localDate = LocalDate.of(y, o, d); LocalTime localTime = LocalTime.of(h, m, s, n); @@ -120,7 +120,7 @@ public class TestOffsetDateTime extends AbstractTest { //----------------------------------------------------------------------- // withOffsetSameLocal() //----------------------------------------------------------------------- - @Test(groups={"implementation"}) + @Test public void test_withOffsetSameLocal() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withOffsetSameLocal(OFFSET_PTWO); @@ -128,192 +128,192 @@ public class TestOffsetDateTime extends AbstractTest { assertSame(test.getOffset(), OFFSET_PTWO); } - @Test(groups={"implementation"}) + @Test public void test_withOffsetSameLocal_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withOffsetSameLocal(OFFSET_PONE); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withOffsetSameInstant_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withOffsetSameInstant(OFFSET_PONE); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withYear_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withYear(2008); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withMonth_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withMonth(6); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfMonth_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withDayOfMonth(30); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withDayOfYear_noChange() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.withDayOfYear(31 + 29 + 31 + 30 + 31 + 30); assertSame(t, TEST_2008_6_30_11_30_59_000000500); } - @Test(groups={"implementation"}) + @Test public void test_withHour_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withHour(11); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withMinute_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withMinute(30); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withSecond_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.withSecond(59); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_withNanoOfSecond_noChange() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE); OffsetDateTime test = base.withNano(1); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plus_Period_zero() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2008_6_30_11_30_59_000000500); } - @Test(groups={"implementation"}) + @Test public void test_plusYears_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusYears(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusMonths_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusMonths(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusWeeks_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusWeeks(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusDays_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusDays(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusHours_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusHours(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusMinutes_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusMinutes(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusSeconds_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusSeconds(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_plusNanos_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.plusNanos(0); } - @Test(groups={"implementation"}) + @Test public void test_minus_Period_zero() { OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.minus(MockSimplePeriod.ZERO_DAYS); assertSame(t, TEST_2008_6_30_11_30_59_000000500); } - @Test(groups={"implementation"}) + @Test public void test_minusYears_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2007, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusYears(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusMonths_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusMonths(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusWeeks_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusWeeks(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusDays_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusDays(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusHours_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusHours(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusMinutes_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusMinutes(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusSeconds_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusSeconds(0); assertSame(test, base); } - @Test(groups={"implementation"}) + @Test public void test_minusNanos_zero() { OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE); OffsetDateTime test = base.minusNanos(0); diff --git a/jdk/test/java/time/test/java/time/TestOffsetDateTime_instants.java b/jdk/test/java/time/test/java/time/TestOffsetDateTime_instants.java index 86c887ac829..28b32ba2811 100644 --- a/jdk/test/java/time/test/java/time/TestOffsetDateTime_instants.java +++ b/jdk/test/java/time/test/java/time/TestOffsetDateTime_instants.java @@ -59,17 +59,16 @@ */ package test.java.time; +import static org.testng.Assert.assertEquals; + import java.time.DateTimeException; import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; import java.time.Month; -import java.time.ZoneOffset; - import java.time.OffsetDateTime; import java.time.Year; - -import static org.testng.Assert.assertEquals; +import java.time.ZoneOffset; import org.testng.annotations.Test; diff --git a/jdk/test/java/time/test/java/time/TestPeriod.java b/jdk/test/java/time/test/java/time/TestPeriod.java index 6559947b145..2c6d4030d84 100644 --- a/jdk/test/java/time/test/java/time/TestPeriod.java +++ b/jdk/test/java/time/test/java/time/TestPeriod.java @@ -80,6 +80,7 @@ public class TestPeriod extends AbstractTest { //----------------------------------------------------------------------- // factories //----------------------------------------------------------------------- + @Test public void factory_zeroSingleton() { assertSame(Period.ZERO, Period.ZERO); assertSame(Period.ofYears(0), Period.ZERO); @@ -91,6 +92,7 @@ public class TestPeriod extends AbstractTest { //----------------------------------------------------------------------- // hashCode() //----------------------------------------------------------------------- + @Test public void test_hashCode() { Period test5 = Period.ofDays(5); Period test6 = Period.ofDays(6); diff --git a/jdk/test/java/time/test/java/time/TestZoneId.java b/jdk/test/java/time/test/java/time/TestZoneId.java index 6aa373288a7..df2bbbc519e 100644 --- a/jdk/test/java/time/test/java/time/TestZoneId.java +++ b/jdk/test/java/time/test/java/time/TestZoneId.java @@ -62,7 +62,6 @@ package test.java.time; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; import java.lang.reflect.Field; @@ -82,7 +81,6 @@ import java.util.Locale; import java.util.SimpleTimeZone; import java.util.TimeZone; -import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -121,7 +119,6 @@ public class TestZoneId extends AbstractTest { assertEquals(test.getRules().isFixedOffset(), true); assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), ZoneOffset.UTC); checkOffset(test.getRules(), createLDT(2008, 6, 30), ZoneOffset.UTC, 1); - assertSame(test, ZoneId.of("UTC+00")); } //----------------------------------------------------------------------- @@ -129,9 +126,7 @@ public class TestZoneId extends AbstractTest { //----------------------------------------------------------------------- public void test_systemDefault() { ZoneId test = ZoneId.systemDefault(); - assertEquals(test.getId(), TimeZone.getDefault() - .getID() - .replaceAll("GMT|UTC|UT", "Z")); + assertEquals(test.getId(), TimeZone.getDefault().getID()); } @Test(expectedExceptions = DateTimeException.class) @@ -156,58 +151,6 @@ public class TestZoneId extends AbstractTest { } } - //----------------------------------------------------------------------- - @DataProvider(name="String_Fixed") - Object[][] data_of_string_Fixed() { - return new Object[][] { - {"+0", "Z"}, - {"+5", "+05:00"}, - {"+01", "+01:00"}, - {"+0100", "+01:00"},{"+01:00", "+01:00"}, - {"+010000", "+01:00"},{"+01:00:00", "+01:00"}, - {"+12", "+12:00"}, - {"+1234", "+12:34"},{"+12:34", "+12:34"}, - {"+123456", "+12:34:56"},{"+12:34:56", "+12:34:56"}, - {"-02", "-02:00"}, - {"-5", "-05:00"}, - {"-0200", "-02:00"},{"-02:00", "-02:00"}, - {"-020000", "-02:00"},{"-02:00:00", "-02:00"}, - }; - } - - @Test(dataProvider="String_Fixed") - public void test_of_string_offset(String input, String id) { - ZoneId test = ZoneId.of(input); - assertEquals(test.getId(), id); - assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), id); - assertEquals(test.getRules().isFixedOffset(), true); - ZoneOffset offset = ZoneOffset.of(id); - assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), offset); - checkOffset(test.getRules(), createLDT(2008, 6, 30), offset, 1); - } - - @Test(dataProvider="String_Fixed") - public void test_of_string_FixedUTC(String input, String id) { - ZoneId test = ZoneId.of("UTC" + input); - assertEquals(test.getId(), id); - assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), id); - assertEquals(test.getRules().isFixedOffset(), true); - ZoneOffset offset = ZoneOffset.of(id); - assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), offset); - checkOffset(test.getRules(), createLDT(2008, 6, 30), offset, 1); - } - - @Test(dataProvider="String_Fixed") - public void test_of_string_FixedGMT(String input, String id) { - ZoneId test = ZoneId.of("GMT" + input); - assertEquals(test.getId(), id); - assertEquals(test.getDisplayName(TextStyle.FULL, Locale.UK), id); - assertEquals(test.getRules().isFixedOffset(), true); - ZoneOffset offset = ZoneOffset.of(id); - assertEquals(test.getRules().getOffset(Instant.ofEpochSecond(0L)), offset); - checkOffset(test.getRules(), createLDT(2008, 6, 30), offset, 1); - } - //----------------------------------------------------------------------- // Europe/London //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/test/java/time/chrono/TestChronoLocalDate.java b/jdk/test/java/time/test/java/time/chrono/TestChronoLocalDate.java new file mode 100644 index 00000000000..7865985998e --- /dev/null +++ b/jdk/test/java/time/test/java/time/chrono/TestChronoLocalDate.java @@ -0,0 +1,233 @@ +/* + * 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. 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. + */ + +/* + * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package test.java.time.chrono; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.time.LocalDate; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistDate; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.testng.annotations.Test; + +/** + * Test chrono local date. + */ +@Test +public class TestChronoLocalDate { + // this class primarily tests whether the generics work OK + + //----------------------------------------------------------------------- + public void test_date_comparator_checkGenerics_ISO() { + List> dates = new ArrayList<>(); + ChronoLocalDate date = LocalDate.of(2013, 1, 1); + + // Insert dates in order, no duplicates + dates.add(date.minus(10, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.MONTHS)); + dates.add(date.minus(1, ChronoUnit.WEEKS)); + dates.add(date.minus(1, ChronoUnit.DAYS)); + dates.add(date); + dates.add(date.plus(1, ChronoUnit.DAYS)); + dates.add(date.plus(1, ChronoUnit.WEEKS)); + dates.add(date.plus(1, ChronoUnit.MONTHS)); + dates.add(date.plus(1, ChronoUnit.YEARS)); + dates.add(date.plus(10, ChronoUnit.YEARS)); + + List> copy = new ArrayList<>(dates); + Collections.shuffle(copy); + Collections.sort(copy, ChronoLocalDate.timeLineOrder()); + assertEquals(copy, dates); + assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); + } + + public void test_date_comparator_checkGenerics_unknown() { + List> dates = new ArrayList<>(); + ChronoLocalDate date = LocalDate.of(2013, 1, 1); + + // Insert dates in order, no duplicates + dates.add(date.minus(10, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.MONTHS)); + dates.add(date.minus(1, ChronoUnit.WEEKS)); + dates.add(date.minus(1, ChronoUnit.DAYS)); + dates.add(date); + dates.add(date.plus(1, ChronoUnit.DAYS)); + dates.add(date.plus(1, ChronoUnit.WEEKS)); + dates.add(date.plus(1, ChronoUnit.MONTHS)); + dates.add(date.plus(1, ChronoUnit.YEARS)); + dates.add(date.plus(10, ChronoUnit.YEARS)); + + List> copy = new ArrayList<>(dates); + Collections.shuffle(copy); + Collections.sort(copy, ChronoLocalDate.timeLineOrder()); + assertEquals(copy, dates); + assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); + } + + public > void test_date_comparator_checkGenerics_unknownExtends() { + List> dates = new ArrayList<>(); + ChronoLocalDate date = (ChronoLocalDate) LocalDate.of(2013, 1, 1); // TODO generics raw type + + // Insert dates in order, no duplicates + dates.add(date.minus(10, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.MONTHS)); + dates.add(date.minus(1, ChronoUnit.WEEKS)); + dates.add(date.minus(1, ChronoUnit.DAYS)); + dates.add(date); + dates.add(date.plus(1, ChronoUnit.DAYS)); + dates.add(date.plus(1, ChronoUnit.WEEKS)); + dates.add(date.plus(1, ChronoUnit.MONTHS)); + dates.add(date.plus(1, ChronoUnit.YEARS)); + dates.add(date.plus(10, ChronoUnit.YEARS)); + + List> copy = new ArrayList<>(dates); + Collections.shuffle(copy); + Collections.sort(copy, ChronoLocalDate.timeLineOrder()); + assertEquals(copy, dates); + assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); + } + + public void test_date_comparator_checkGenerics_LocalDate() { + List dates = new ArrayList<>(); + LocalDate date = LocalDate.of(2013, 1, 1); + + // Insert dates in order, no duplicates + dates.add(date.minus(10, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.YEARS)); + dates.add(date.minus(1, ChronoUnit.MONTHS)); + dates.add(date.minus(1, ChronoUnit.WEEKS)); + dates.add(date.minus(1, ChronoUnit.DAYS)); + dates.add(date); + dates.add(date.plus(1, ChronoUnit.DAYS)); + dates.add(date.plus(1, ChronoUnit.WEEKS)); + dates.add(date.plus(1, ChronoUnit.MONTHS)); + dates.add(date.plus(1, ChronoUnit.YEARS)); + dates.add(date.plus(10, ChronoUnit.YEARS)); + + List copy = new ArrayList<>(dates); + Collections.shuffle(copy); + Collections.sort(copy, ChronoLocalDate.timeLineOrder()); + assertEquals(copy, dates); + assertTrue(ChronoLocalDate.timeLineOrder().compare(copy.get(0), copy.get(1)) < 0); + } + + //----------------------------------------------------------------------- + public void test_date_checkGenerics_genericsMethod() { + Chronology chrono = ThaiBuddhistChronology.INSTANCE; + ChronoLocalDate date = chrono.dateNow(); + // date = processOK(date); // does not compile + date = processClassOK(ThaiBuddhistDate.class); + date = dateSupplier(); + + // date = processWeird(date); // does not compile (correct) + // date = processClassWeird(ThaiBuddhistDate.class); // does not compile (correct) + } + + public void test_date_checkGenerics_genericsMethod_concreteType() { + ThaiBuddhistChronology chrono = ThaiBuddhistChronology.INSTANCE; + ThaiBuddhistDate date = chrono.dateNow(); + date = ThaiBuddhistDate.now(); + date = processOK(date); + date = processClassOK(ThaiBuddhistDate.class); + date = dateSupplier(); + + // date = processWeird(date); // does not compile (correct) + // date = processClassWeird(ThaiBuddhistDate.class); // does not compile (correct) + } + + public > void test_date_checkGenerics_genericsMethod_withType() { + Chronology chrono = ThaiBuddhistChronology.INSTANCE; + D date = (D) chrono.dateNow(); + date = processOK(date); + // date = processClassOK(ThaiBuddhistDate.class); // does not compile (correct) + date = dateSupplier(); + + // date = processWeird(date); // does not compile (correct) + // date = processClassWeird(ThaiBuddhistDate.class); // does not compile (correct) + } + + private > D dateSupplier() { + return (D) (ChronoLocalDate) ThaiBuddhistChronology.INSTANCE.dateNow(); // TODO raw types + } + + // decent generics signatures that need to work + private > D processOK(D date) { + return date; + } + private > D processClassOK(Class cls) { + return null; + } + + // weird generics signatures that shouldn't really work + private > ChronoLocalDate processWeird(ChronoLocalDate date) { + return date; + } + private > ChronoLocalDate processClassWeird(Class cls) { + return null; + } + +} diff --git a/jdk/test/java/time/test/java/time/chrono/TestChronologyPerf.java b/jdk/test/java/time/test/java/time/chrono/TestChronologyPerf.java new file mode 100644 index 00000000000..8d73568b146 --- /dev/null +++ b/jdk/test/java/time/test/java/time/chrono/TestChronologyPerf.java @@ -0,0 +1,48 @@ +/* + * 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. 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 test.java.time.chrono; + +import java.time.Duration; +import java.time.chrono.Chronology; +import java.time.temporal.ChronoUnit; +import java.util.Set; + +import org.testng.annotations.Test; + +/** + * Test the speed of initializing all calendars. + */ +public class TestChronologyPerf { + + @Test + public void test_chronologyGetAvailablePerf() { + long start = System.nanoTime(); + Set chronos = Chronology.getAvailableChronologies(); + long end = System.nanoTime(); + Duration d = Duration.of(end - start, ChronoUnit.NANOS); + System.out.printf(" Duration of Chronology.getAvailableChronologies(): %s%n", d); + } + +} diff --git a/jdk/test/java/time/test/java/time/chrono/TestExampleCode.java b/jdk/test/java/time/test/java/time/chrono/TestExampleCode.java index bfdec45c198..d387c88fd65 100644 --- a/jdk/test/java/time/test/java/time/chrono/TestExampleCode.java +++ b/jdk/test/java/time/test/java/time/chrono/TestExampleCode.java @@ -57,16 +57,20 @@ package test.java.time.chrono; +import static org.testng.Assert.assertEquals; + import java.time.LocalTime; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.ChronoLocalDateTime; +import java.time.chrono.Chronology; import java.time.chrono.HijrahDate; import java.time.chrono.ThaiBuddhistDate; -import java.time.chrono.ChronoLocalDateTime; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.Chronology; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; +import java.util.Locale; import java.util.Set; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -104,6 +108,30 @@ public class TestExampleCode { first, last); } + //----------------------------------------------------------------------- + // Data provider for Hijrah Variant names + //----------------------------------------------------------------------- + @DataProvider(name = "HijrahVariantNames") + Object[][] data_of_ummalqura() { + return new Object[][]{ + { "Hijrah-umalqura", "islamic", "umalqura"}, + }; + } + + @Test(dataProvider= "HijrahVariantNames") + public void test_HijrahVariantViaLocale(String calendarId, String calendarType, String variant) { + Locale.Builder builder = new Locale.Builder(); + builder.setLanguage("en").setRegion("US"); + builder.setUnicodeLocaleKeyword("ca", calendarType); + builder.setUnicodeLocaleKeyword("cv", variant); + Locale locale = builder.build(); + Chronology chrono = Chronology.ofLocale(locale); + System.out.printf(" Locale language tag: %s, Chronology ID: %s, type: %s%n", + locale.toLanguageTag(), chrono, chrono.getCalendarType()); + Chronology expected = Chronology.of(calendarId); + assertEquals(chrono, expected, "Expected chronology not found"); + } + @Test public void test_calendarPackageExample() { diff --git a/jdk/test/java/time/test/java/time/chrono/TestIsoChronoImpl.java b/jdk/test/java/time/test/java/time/chrono/TestIsoChronoImpl.java index 1e66574a4a8..6b3a4e87fee 100644 --- a/jdk/test/java/time/test/java/time/chrono/TestIsoChronoImpl.java +++ b/jdk/test/java/time/test/java/time/chrono/TestIsoChronoImpl.java @@ -60,19 +60,16 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; - import static org.testng.Assert.assertEquals; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.TimeZone; - import java.time.DayOfWeek; import java.time.LocalDate; -import java.time.chrono.ChronoLocalDate; import java.time.chrono.IsoChronology; import java.time.temporal.ChronoUnit; import java.time.temporal.WeekFields; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.TimeZone; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -86,15 +83,14 @@ public class TestIsoChronoImpl { @DataProvider(name = "RangeVersusCalendar") Object[][] provider_rangeVersusCalendar() { return new Object[][]{ - {LocalDate.of(1900, 1, 4), LocalDate.of(2100, 1, 8)}, - //{LocalDate.of(1583, 1, 1), LocalDate.of(2100, 1, 1)}, + {LocalDate.of(1583, 1, 1), LocalDate.of(2100, 1, 1)}, }; } //----------------------------------------------------------------------- // Verify ISO Calendar matches java.util.Calendar for range //----------------------------------------------------------------------- - @Test(groups = {"implementation"}, dataProvider = "RangeVersusCalendar") + @Test(dataProvider = "RangeVersusCalendar") public void test_IsoChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { GregorianCalendar cal = new GregorianCalendar(); assertEquals(cal.getCalendarType(), "gregory", "Unexpected calendar type"); @@ -119,7 +115,7 @@ public class TestIsoChronoImpl { // Verify ISO Calendar matches java.util.Calendar // DayOfWeek, WeekOfMonth, WeekOfYear for range //----------------------------------------------------------------------- - @Test(groups = {"implementation"}, dataProvider = "RangeVersusCalendar") + @Test(dataProvider = "RangeVersusCalendar") public void test_DayOfWeek_IsoChronology_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { GregorianCalendar cal = new GregorianCalendar(); assertEquals(cal.getCalendarType(), "gregory", "Unexpected calendar type"); @@ -136,32 +132,31 @@ public class TestIsoChronoImpl { cal.set(Calendar.MONTH, isoDate.get(MONTH_OF_YEAR) - 1); cal.set(Calendar.DAY_OF_MONTH, isoDate.get(DAY_OF_MONTH)); + // For every date in the range while (isoDate.isBefore(isoEndDate)) { assertEquals(isoDate.get(DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + isoDate + "; cal: " + cal); assertEquals(isoDate.get(MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + isoDate); assertEquals(isoDate.get(YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + isoDate); - int jDOW = Math.floorMod(cal.get(Calendar.DAY_OF_WEEK) - 2, 7) + 1; - int isoDOW = isoDate.get(weekDef.dayOfWeek()); - if (jDOW != isoDOW) { - System.err.printf(" DOW vs Calendar jdow: %s, isoDate(DOW): %s, isoDate: %s, WeekDef: %s%n", jDOW, isoDOW, isoDate, weekDef); - } - assertEquals(jDOW, isoDOW, "Calendar DayOfWeek does not match ISO DayOfWeek"); + + int jdow = Math.floorMod(cal.get(Calendar.DAY_OF_WEEK) - 2, 7) + 1; + int dow = isoDate.get(weekDef.dayOfWeek()); + assertEquals(jdow, dow, "Calendar DayOfWeek does not match ISO DayOfWeek"); int jweekOfMonth = cal.get(Calendar.WEEK_OF_MONTH); int isoWeekOfMonth = isoDate.get(weekDef.weekOfMonth()); - if (jweekOfMonth != isoWeekOfMonth) { - System.err.printf(" WeekOfMonth jWeekOfMonth: %s, isoWeekOfMonth: %s, isoDate: %s, %s%n", - jweekOfMonth, isoWeekOfMonth, isoDate, weekDef); - } assertEquals(jweekOfMonth, isoWeekOfMonth, "Calendar WeekOfMonth does not match ISO WeekOfMonth"); int jweekOfYear = cal.get(Calendar.WEEK_OF_YEAR); - int isoWeekOfYear = isoDate.get(weekDef.weekOfYear()); - if (jweekOfYear != isoWeekOfYear) { - // TBD: Issue #186 Remove misleading output pending resolution - // System.err.printf(" Mismatch WeekOfYear jweekOfYear: %s, isoWeekOfYear: %s, isoDate: %s, WeekDef: %s%n", jweekOfYear, isoWeekOfYear, isoDate, weekDef); - } - //assertEquals(jweekOfYear, isoWeekOfYear, "Calendar WeekOfYear does not match ISO WeekOfYear"); + int weekOfYear = isoDate.get(weekDef.weekOfWeekBasedYear()); + assertEquals(jweekOfYear, weekOfYear, "GregorianCalendar WeekOfYear does not match WeekOfWeekBasedYear"); + + int jWeekYear = cal.getWeekYear(); + int weekBasedYear = isoDate.get(weekDef.weekBasedYear()); + assertEquals(jWeekYear, weekBasedYear, "GregorianCalendar getWeekYear does not match YearOfWeekBasedYear"); + + int jweeksInWeekyear = cal.getWeeksInWeekYear(); + int weeksInWeekBasedYear = (int)isoDate.range(weekDef.weekOfWeekBasedYear()).getMaximum(); + assertEquals(jweeksInWeekyear, weeksInWeekBasedYear, "length of weekBasedYear"); isoDate = isoDate.plus(1, ChronoUnit.DAYS); cal.add(Calendar.DAY_OF_MONTH, 1); diff --git a/jdk/test/java/time/test/java/time/temporal/TestJapaneseChronoImpl.java b/jdk/test/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java similarity index 97% rename from jdk/test/java/time/test/java/time/temporal/TestJapaneseChronoImpl.java rename to jdk/test/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java index ababf14cb4a..282a9f2231d 100644 --- a/jdk/test/java/time/test/java/time/temporal/TestJapaneseChronoImpl.java +++ b/jdk/test/java/time/test/java/time/chrono/TestJapaneseChronoImpl.java @@ -54,22 +54,21 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package test.java.time.temporal; +package test.java.time.chrono; import static org.testng.Assert.assertEquals; -import java.util.Calendar; -import java.util.Locale; -import java.util.TimeZone; import java.time.LocalDate; import java.time.LocalTime; import java.time.OffsetDateTime; import java.time.ZoneOffset; -import java.time.temporal.ChronoField; -import java.time.chrono.ChronoLocalDate; -import java.time.temporal.ChronoUnit; import java.time.chrono.JapaneseChronology; import java.time.chrono.JapaneseDate; +import java.time.temporal.ChronoField; +import java.time.temporal.ChronoUnit; +import java.util.Calendar; +import java.util.Locale; +import java.util.TimeZone; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -93,7 +92,7 @@ public class TestJapaneseChronoImpl { //----------------------------------------------------------------------- // Verify Japanese Calendar matches java.util.Calendar for range //----------------------------------------------------------------------- - @Test(groups={"implementation"}, dataProvider="RangeVersusCalendar") + @Test(dataProvider="RangeVersusCalendar") public void test_JapaneseChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese"); assertEquals(locale.toString(), "ja_JP_#u-ca-japanese", "Unexpected locale"); diff --git a/jdk/test/java/time/test/java/time/chrono/TestServiceLoader.java b/jdk/test/java/time/test/java/time/chrono/TestServiceLoader.java index 99304a74cd5..b64f8f4d05b 100644 --- a/jdk/test/java/time/test/java/time/chrono/TestServiceLoader.java +++ b/jdk/test/java/time/test/java/time/chrono/TestServiceLoader.java @@ -60,10 +60,11 @@ package test.java.time.chrono; import static org.testng.Assert.assertNotNull; +import java.time.chrono.Chronology; import java.util.HashMap; import java.util.Map; import java.util.ServiceLoader; -import java.time.chrono.Chronology; + import org.testng.annotations.Test; /** @@ -73,7 +74,7 @@ import org.testng.annotations.Test; @Test public class TestServiceLoader { - @Test(groups="implementation") + @Test public void test_copticServiceLoader() { Map chronos = new HashMap<>(); ServiceLoader loader = ServiceLoader.load(Chronology.class, null); diff --git a/jdk/test/java/time/test/java/time/temporal/TestThaiBuddhistChronoImpl.java b/jdk/test/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java similarity index 97% rename from jdk/test/java/time/test/java/time/temporal/TestThaiBuddhistChronoImpl.java rename to jdk/test/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java index 14b0a45fe0c..94bbe0f94dd 100644 --- a/jdk/test/java/time/test/java/time/temporal/TestThaiBuddhistChronoImpl.java +++ b/jdk/test/java/time/test/java/time/chrono/TestThaiBuddhistChronoImpl.java @@ -54,23 +54,21 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package test.java.time.temporal; +package test.java.time.chrono; import static org.testng.Assert.assertEquals; +import java.time.LocalDate; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.chrono.ThaiBuddhistDate; +import java.time.temporal.ChronoField; +import java.time.temporal.ChronoUnit; import java.util.Calendar; import java.util.Locale; import java.util.TimeZone; -import java.time.LocalDate; -import java.time.temporal.ChronoField; -import java.time.temporal.ChronoUnit; -import java.time.chrono.ChronoLocalDate; -import java.time.chrono.ThaiBuddhistChronology; -import java.time.chrono.ThaiBuddhistDate; - -import org.testng.annotations.Test; import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; /** * Test. @@ -91,7 +89,7 @@ public class TestThaiBuddhistChronoImpl { //----------------------------------------------------------------------- // Verify ThaiBuddhist Calendar matches java.util.Calendar for range //----------------------------------------------------------------------- - @Test(groups={"implementation"}, dataProvider="RangeVersusCalendar") + @Test(dataProvider="RangeVersusCalendar") public void test_ThaiBuddhistChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { Locale locale = Locale.forLanguageTag("th-TH--u-ca-buddhist"); assertEquals(locale.toString(), "th_TH", "Unexpected locale"); diff --git a/jdk/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java b/jdk/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java new file mode 100644 index 00000000000..3e1b8a85803 --- /dev/null +++ b/jdk/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java @@ -0,0 +1,225 @@ +/* + * 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. 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 test.java.time.chrono; + +import static java.time.temporal.ChronoField.DAY_OF_MONTH; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.YEAR; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +import java.time.DateTimeException; +import java.time.LocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.HijrahChronology; +import java.time.chrono.HijrahDate; +import java.time.temporal.ChronoField; +import java.time.temporal.ChronoUnit; +import java.time.temporal.ValueRange; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Tests for the Umm alQura chronology and data + */ +@Test +public class TestUmmAlQuraChronology { + + @Test + public void test_aliases() { + HijrahChronology hc = (HijrahChronology) Chronology.of("Hijrah"); + assertEquals(hc, HijrahChronology.INSTANCE, "Alias for Hijrah-umalqura"); + hc = (HijrahChronology) Chronology.of("islamic"); + assertEquals(hc, HijrahChronology.INSTANCE, "Alias for Hijrah-umalqura"); + } + + //----------------------------------------------------------------------- + // regular data factory for Umm alQura dates and the corresponding ISO dates + //----------------------------------------------------------------------- + @DataProvider(name = "UmmalQuraVsISODates") + Object[][] data_of_ummalqura() { + return new Object[][]{ + + //{1318, 01, 01, 1900, 04, 30}, + //{1318, 01, 02, 1900, 05, 01}, + + //{1318, 12, 29, 1901, 04, 18}, + //{1319, 01, 01, 1901, 04, 19}, + + //{1433, 12, 29, 2012, 11, 14}, + //{1434, 01, 01, 2012, 11, 15}, + + {1434, 02, 18, 2012, 12, 31}, + {1434, 02, 19, 2013, 01, 01}, + + //{1502, 12, 30, 2079, 10, 25}, + // not in Umm alQura data {1503, 01, 01, 2079, 10, 26}, + + // not in Umm alQura data {1503, 06, 28, 2080, 04, 18}, + // not in Umm alQura data ~/ws/Downloads + }; + } + + @Test(dataProvider="UmmalQuraVsISODates") + public void Test_UmmAlQuraDatesVsISO(int h_year, int h_month, int h_day, int iso_year, int iso_month, int iso_day) { + HijrahDate hd = HijrahDate.of(h_year, h_month, h_day); + LocalDate ld = LocalDate.of(iso_year, iso_month, iso_day); + assertEquals(hd.toEpochDay(), ld.toEpochDay(), "Umm alQura date and ISO date should have same epochDay"); + } + + + @Test + public void Test_UmmAlQuraChronoRange() { + HijrahChronology chrono = HijrahChronology.INSTANCE; + ValueRange year = chrono.range(YEAR); + assertEquals(year.getMinimum(), 1432, "Minimum year"); + assertEquals(year.getLargestMinimum(), 1432, "Largest minimum year"); + assertEquals(year.getMaximum(), 1435, "Largest year"); + assertEquals(year.getSmallestMaximum(), 1435, "Smallest Maximum year"); + + ValueRange month = chrono.range(MONTH_OF_YEAR); + assertEquals(month.getMinimum(), 1, "Minimum month"); + assertEquals(month.getLargestMinimum(), 1, "Largest minimum month"); + assertEquals(month.getMaximum(), 12, "Largest month"); + assertEquals(month.getSmallestMaximum(), 12, "Smallest Maximum month"); + + ValueRange day = chrono.range(DAY_OF_MONTH); + assertEquals(day.getMinimum(), 1, "Minimum day"); + assertEquals(day.getLargestMinimum(), 1, "Largest minimum day"); + assertEquals(day.getMaximum(), 30, "Largest day"); + assertEquals(day.getSmallestMaximum(), 29, "Smallest Maximum day"); + } + + //----------------------------------------------------------------------- + // regular data factory for dates and the corresponding range values + //----------------------------------------------------------------------- + @DataProvider(name = "dates") + Object[][] data_of_calendars() { + return new Object[][]{ + {HijrahDate.of(1434, 5, 1), 1432, 1435, 1, 12, 1, 29, 30}, + {HijrahDate.of(1434, 6, 1), 1432, 1435, 1, 12, 1, 30, 30}, + }; + } + + @Test(dataProvider="dates") + public void Test_UmmAlQuraRanges(HijrahDate date, + int minYear, int maxYear, + int minMonth, int maxMonth, + int minDay, int maxDay, int maxChronoDay) { + // Check the chronology ranges + HijrahChronology chrono = date.getChronology(); + ValueRange yearRange = chrono.range(YEAR); + assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah chronology"); + assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum year for Hijrah chronology"); + assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah chronology"); + assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest Maximum year for Hijrah chronology"); + + ValueRange monthRange = chrono.range(MONTH_OF_YEAR); + assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for Hijrah chronology"); + assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for Hijrah chronology"); + + ValueRange daysRange = chrono.range(DAY_OF_MONTH); + assertEquals(daysRange.getMinimum(), minDay, "Minimum day for chronology"); + assertEquals(daysRange.getMaximum(), maxChronoDay, "Maximum day for Hijrah chronology"); + + // Check the date ranges + yearRange = date.range(YEAR); + assertEquals(yearRange.getMinimum(), minYear, "Minimum year for Hijrah date"); + assertEquals(yearRange.getLargestMinimum(), minYear, "Largest minimum year for Hijrah date"); + assertEquals(yearRange.getMaximum(), maxYear, "Maximum year for Hijrah date"); + assertEquals(yearRange.getSmallestMaximum(), maxYear, "Smallest maximum year for Hijrah date"); + + monthRange = date.range(MONTH_OF_YEAR); + assertEquals(monthRange.getMinimum(), minMonth, "Minimum month for HijrahDate"); + assertEquals(monthRange.getMaximum(), maxMonth, "Maximum month for HijrahDate"); + + daysRange = date.range(DAY_OF_MONTH); + assertEquals(daysRange.getMinimum(), minDay, "Minimum day for HijrahDate"); + assertEquals(daysRange.getMaximum(), maxDay, "Maximum day for HijrahDate"); + + } + + @Test + public void test_hijrahDateLimits() { + HijrahChronology chrono = HijrahChronology.INSTANCE; + ValueRange yearRange = chrono.range(YEAR); + ValueRange monthRange = chrono.range(MONTH_OF_YEAR); + ValueRange dayRange = chrono.range(DAY_OF_MONTH); + + HijrahDate xx = chrono.date(1434, 1, 1); + HijrahDate minDate = chrono.date((int)yearRange.getLargestMinimum(), + (int)monthRange.getMinimum(), (int)dayRange.getMinimum()); + try { + HijrahDate before = minDate.minus(1, ChronoUnit.DAYS); + fail("Exception did not occur, minDate: " + minDate + ".minus(1, DAYS) = " + before); + + } catch (DateTimeException ex) { + // ignore, this exception was expected + } + + HijrahDate maxDate = chrono.date((int)yearRange.getSmallestMaximum(), + (int)monthRange.getMaximum(), 1); + int monthLen = maxDate.lengthOfMonth(); + maxDate = maxDate.with(DAY_OF_MONTH, monthLen); + try { + HijrahDate after = maxDate.plus(1, ChronoUnit.DAYS); + fail("Exception did not occur, maxDate: " + maxDate + ".plus(1, DAYS) = " + after); + } catch (DateTimeException ex) { + // ignore, this exception was expected + } + } + + @DataProvider(name="badDates") + Object[][] data_badDates() { + return new Object[][] { + {1317, 12, 29}, + {1317, 12, 30}, + + {1320, 1, 29 + 1}, + {1320, 2, 30 + 1}, + {1320, 3, 29 + 1}, + {1320, 4, 29 + 1}, + {1320, 5, 30 + 1}, + {1320, 6, 29 + 1}, + {1320, 7, 30 + 1}, + {1320, 8, 30 + 1}, + {1320, 9, 29 + 1}, + {1320, 10, 30 + 1}, + {1320, 11, 30 + 1}, + {1320, 12, 30 + 1}, + }; + } + + @Test(dataProvider="badDates", expectedExceptions=DateTimeException.class) + public void test_badDates(int year, int month, int dom) { + HijrahChronology.INSTANCE.date(year, month, dom); + } + + void printRange(ValueRange range, Object obj, ChronoField field) { + System.err.printf(" range: min: %d, max: %d; of: %s, field: %s%n", range.getMinimum(), range.getMaximum(), obj.toString(), field.toString()); + } +} diff --git a/jdk/test/java/time/test/java/time/format/AbstractTestPrinterParser.java b/jdk/test/java/time/test/java/time/format/AbstractTestPrinterParser.java index c1b0ad2a18e..e11a24dd0c7 100644 --- a/jdk/test/java/time/test/java/time/format/AbstractTestPrinterParser.java +++ b/jdk/test/java/time/test/java/time/format/AbstractTestPrinterParser.java @@ -59,16 +59,18 @@ */ package test.java.time.format; -import java.time.format.*; - -import java.util.Locale; - import java.time.DateTimeException; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatSymbols; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.SignStyle; +import java.time.format.TextStyle; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; +import java.util.Locale; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -86,7 +88,7 @@ public class AbstractTestPrinterParser { protected DateTimeFormatSymbols symbols; - @BeforeMethod(groups={"tck"}) + @BeforeMethod public void setUp() { buf = new StringBuilder(); builder = new DateTimeFormatterBuilder(); @@ -123,6 +125,10 @@ public class AbstractTestPrinterParser { return builder.appendLiteral(s).toFormatter(locale).withSymbols(symbols); } + protected DateTimeFormatter getFormatter(TemporalField field) { + return builder.appendText(field).toFormatter(locale).withSymbols(symbols); + } + protected DateTimeFormatter getFormatter(TemporalField field, TextStyle style) { return builder.appendText(field, style).toFormatter(locale).withSymbols(symbols); } @@ -135,6 +141,10 @@ public class AbstractTestPrinterParser { return builder.appendOffset(pattern, noOffsetText).toFormatter(locale).withSymbols(symbols); } + protected DateTimeFormatter getPatternFormatter(String pattern) { + return builder.appendPattern(pattern).toFormatter(locale).withSymbols(symbols); + } + protected static final TemporalAccessor EMPTY_DTA = new TemporalAccessor() { public boolean isSupported(TemporalField field) { return true; diff --git a/jdk/test/java/time/test/java/time/format/MockIOExceptionAppendable.java b/jdk/test/java/time/test/java/time/format/MockIOExceptionAppendable.java index 8cdedccdf8f..f3608b501f8 100644 --- a/jdk/test/java/time/test/java/time/format/MockIOExceptionAppendable.java +++ b/jdk/test/java/time/test/java/time/format/MockIOExceptionAppendable.java @@ -59,8 +59,6 @@ */ package test.java.time.format; -import java.time.format.*; - import java.io.IOException; /** diff --git a/jdk/test/java/time/test/java/time/format/TestCharLiteralParser.java b/jdk/test/java/time/test/java/time/format/TestCharLiteralParser.java index ff73696c3e5..92cd6f885d9 100644 --- a/jdk/test/java/time/test/java/time/format/TestCharLiteralParser.java +++ b/jdk/test/java/time/test/java/time/format/TestCharLiteralParser.java @@ -65,8 +65,8 @@ import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; import java.text.ParsePosition; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQuery; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -74,7 +74,7 @@ import org.testng.annotations.Test; /** * Test CharLiteralPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestCharLiteralParser extends AbstractTestPrinterParser { @DataProvider(name="success") @@ -111,8 +111,8 @@ public class TestCharLiteralParser extends AbstractTestPrinterParser { } else { assertEquals(ppos.getIndex(), expectedPos); assertEquals(parsed.isSupported(YEAR), false); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } diff --git a/jdk/test/java/time/test/java/time/format/TestCharLiteralPrinter.java b/jdk/test/java/time/test/java/time/format/TestCharLiteralPrinter.java index 780c04db8cb..6aaf6a5b97d 100644 --- a/jdk/test/java/time/test/java/time/format/TestCharLiteralPrinter.java +++ b/jdk/test/java/time/test/java/time/format/TestCharLiteralPrinter.java @@ -59,8 +59,6 @@ */ package test.java.time.format; -import java.time.format.*; - import static org.testng.Assert.assertEquals; import org.testng.annotations.Test; @@ -68,7 +66,7 @@ import org.testng.annotations.Test; /** * Test CharLiteralPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestCharLiteralPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/test/java/time/format/TestDateTimeFormatSymbols.java b/jdk/test/java/time/test/java/time/format/TestDateTimeFormatSymbols.java index fe2d408a6f9..cb3932a3932 100644 --- a/jdk/test/java/time/test/java/time/format/TestDateTimeFormatSymbols.java +++ b/jdk/test/java/time/test/java/time/format/TestDateTimeFormatSymbols.java @@ -59,10 +59,9 @@ */ package test.java.time.format; -import java.time.format.*; - import static org.testng.Assert.assertSame; +import java.time.format.DateTimeFormatSymbols; import java.util.Locale; import org.testng.annotations.Test; @@ -73,7 +72,7 @@ import org.testng.annotations.Test; @Test public class TestDateTimeFormatSymbols { - @Test(groups={"implementation"}) + @Test public void test_of_Locale_cached() { DateTimeFormatSymbols loc1 = DateTimeFormatSymbols.of(Locale.CANADA); DateTimeFormatSymbols loc2 = DateTimeFormatSymbols.of(Locale.CANADA); @@ -81,7 +80,7 @@ public class TestDateTimeFormatSymbols { } //----------------------------------------------------------------------- - @Test(groups={"implementation"}) + @Test public void test_ofDefaultLocale_cached() { DateTimeFormatSymbols loc1 = DateTimeFormatSymbols.ofDefaultLocale(); DateTimeFormatSymbols loc2 = DateTimeFormatSymbols.ofDefaultLocale(); diff --git a/jdk/test/java/time/test/java/time/format/TestDateTimeFormatter.java b/jdk/test/java/time/test/java/time/format/TestDateTimeFormatter.java index 61b0806f958..a96dfb6b455 100644 --- a/jdk/test/java/time/test/java/time/format/TestDateTimeFormatter.java +++ b/jdk/test/java/time/test/java/time/format/TestDateTimeFormatter.java @@ -59,14 +59,15 @@ */ package test.java.time.format; -import java.time.format.*; - import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static org.testng.Assert.assertSame; +import java.time.format.DateTimeFormatSymbols; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.SignStyle; import java.util.Locale; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** @@ -74,14 +75,8 @@ import org.testng.annotations.Test; */ @Test public class TestDateTimeFormatter { - // TODO these tests are not tck, as they refer to a non-public class - // rewrite whole test case to use BASIC_FORMATTER or similar - @BeforeMethod(groups={"tck"}) - public void setUp() { - } - - @Test(groups={"implementation"}) + @Test public void test_withLocale_same() throws Exception { DateTimeFormatter base = new DateTimeFormatterBuilder().appendLiteral("ONE") diff --git a/jdk/test/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java b/jdk/test/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java index ec0d16e8fd4..432c0381f06 100644 --- a/jdk/test/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java +++ b/jdk/test/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java @@ -645,17 +645,23 @@ public class TestDateTimeFormatterBuilder { {"GGGG", "Text(Era)"}, {"GGGGG", "Text(Era,NARROW)"}, - {"y", "Value(Year)"}, - {"yy", "ReducedValue(Year,2,2000)"}, - {"yyy", "Value(Year,3,19,NORMAL)"}, - {"yyyy", "Value(Year,4,19,EXCEEDS_PAD)"}, - {"yyyyy", "Value(Year,5,19,EXCEEDS_PAD)"}, + {"u", "Value(Year)"}, + {"uu", "ReducedValue(Year,2,2000)"}, + {"uuu", "Value(Year,3,19,NORMAL)"}, + {"uuuu", "Value(Year,4,19,EXCEEDS_PAD)"}, + {"uuuuu", "Value(Year,5,19,EXCEEDS_PAD)"}, -// {"Y", "Value(WeekBasedYear)"}, -// {"YY", "ReducedValue(WeekBasedYear,2,2000)"}, -// {"YYY", "Value(WeekBasedYear,3,19,NORMAL)"}, -// {"YYYY", "Value(WeekBasedYear,4,19,EXCEEDS_PAD)"}, -// {"YYYYY", "Value(WeekBasedYear,5,19,EXCEEDS_PAD)"}, + {"y", "Value(YearOfEra)"}, + {"yy", "ReducedValue(YearOfEra,2,2000)"}, + {"yyy", "Value(YearOfEra,3,19,NORMAL)"}, + {"yyyy", "Value(YearOfEra,4,19,EXCEEDS_PAD)"}, + {"yyyyy", "Value(YearOfEra,5,19,EXCEEDS_PAD)"}, + + {"Y", "Localized(WeekBasedYear)"}, + {"YY", "Localized(ReducedValue(WeekBasedYear,2,2000))"}, + {"YYY", "Localized(WeekBasedYear,3,19,NORMAL)"}, + {"YYYY", "Localized(WeekBasedYear,4,19,EXCEEDS_PAD)"}, + {"YYYYY", "Localized(WeekBasedYear,5,19,EXCEEDS_PAD)"}, {"M", "Value(MonthOfYear)"}, {"MM", "Value(MonthOfYear,2)"}, @@ -663,17 +669,20 @@ public class TestDateTimeFormatterBuilder { {"MMMM", "Text(MonthOfYear)"}, {"MMMMM", "Text(MonthOfYear,NARROW)"}, + {"L", "Value(MonthOfYear)"}, + {"LL", "Value(MonthOfYear,2)"}, + {"LLL", "Text(MonthOfYear,SHORT_STANDALONE)"}, + {"LLLL", "Text(MonthOfYear,FULL_STANDALONE)"}, + {"LLLLL", "Text(MonthOfYear,NARROW_STANDALONE)"}, + {"D", "Value(DayOfYear)"}, {"DD", "Value(DayOfYear,2)"}, {"DDD", "Value(DayOfYear,3)"}, {"d", "Value(DayOfMonth)"}, {"dd", "Value(DayOfMonth,2)"}, - {"ddd", "Value(DayOfMonth,3)"}, - {"F", "Value(AlignedWeekOfMonth)"}, - {"FF", "Value(AlignedWeekOfMonth,2)"}, - {"FFF", "Value(AlignedWeekOfMonth,3)"}, + {"F", "Value(AlignedDayOfWeekInMonth)"}, {"Q", "Value(QuarterOfYear)"}, {"QQ", "Value(QuarterOfYear,2)"}, @@ -681,41 +690,48 @@ public class TestDateTimeFormatterBuilder { {"QQQQ", "Text(QuarterOfYear)"}, {"QQQQQ", "Text(QuarterOfYear,NARROW)"}, - {"E", "Value(DayOfWeek)"}, - {"EE", "Value(DayOfWeek,2)"}, + {"q", "Value(QuarterOfYear)"}, + {"qq", "Value(QuarterOfYear,2)"}, + {"qqq", "Text(QuarterOfYear,SHORT_STANDALONE)"}, + {"qqqq", "Text(QuarterOfYear,FULL_STANDALONE)"}, + {"qqqqq", "Text(QuarterOfYear,NARROW_STANDALONE)"}, + + {"E", "Text(DayOfWeek,SHORT)"}, + {"EE", "Text(DayOfWeek,SHORT)"}, {"EEE", "Text(DayOfWeek,SHORT)"}, {"EEEE", "Text(DayOfWeek)"}, {"EEEEE", "Text(DayOfWeek,NARROW)"}, + {"e", "Localized(DayOfWeek,1)"}, + {"ee", "Localized(DayOfWeek,2)"}, + {"eee", "Text(DayOfWeek,SHORT)"}, + {"eeee", "Text(DayOfWeek)"}, + {"eeeee", "Text(DayOfWeek,NARROW)"}, + + {"c", "Localized(DayOfWeek,1)"}, + {"ccc", "Text(DayOfWeek,SHORT_STANDALONE)"}, + {"cccc", "Text(DayOfWeek,FULL_STANDALONE)"}, + {"ccccc", "Text(DayOfWeek,NARROW_STANDALONE)"}, + {"a", "Text(AmPmOfDay,SHORT)"}, - {"aa", "Text(AmPmOfDay,SHORT)"}, - {"aaa", "Text(AmPmOfDay,SHORT)"}, - {"aaaa", "Text(AmPmOfDay)"}, - {"aaaaa", "Text(AmPmOfDay,NARROW)"}, {"H", "Value(HourOfDay)"}, {"HH", "Value(HourOfDay,2)"}, - {"HHH", "Value(HourOfDay,3)"}, {"K", "Value(HourOfAmPm)"}, {"KK", "Value(HourOfAmPm,2)"}, - {"KKK", "Value(HourOfAmPm,3)"}, {"k", "Value(ClockHourOfDay)"}, {"kk", "Value(ClockHourOfDay,2)"}, - {"kkk", "Value(ClockHourOfDay,3)"}, {"h", "Value(ClockHourOfAmPm)"}, {"hh", "Value(ClockHourOfAmPm,2)"}, - {"hhh", "Value(ClockHourOfAmPm,3)"}, {"m", "Value(MinuteOfHour)"}, {"mm", "Value(MinuteOfHour,2)"}, - {"mmm", "Value(MinuteOfHour,3)"}, {"s", "Value(SecondOfMinute)"}, {"ss", "Value(SecondOfMinute,2)"}, - {"sss", "Value(SecondOfMinute,3)"}, {"S", "Fraction(NanoOfSecond,1,1)"}, {"SS", "Fraction(NanoOfSecond,2,2)"}, @@ -760,22 +776,20 @@ public class TestDateTimeFormatterBuilder { {"ppH", "Pad(Value(HourOfDay),2)"}, {"pppDD", "Pad(Value(DayOfYear,2),3)"}, - {"yyyy[-MM[-dd", "Value(Year,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"}, - {"yyyy[-MM[-dd]]", "Value(Year,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"}, - {"yyyy[-MM[]-dd]", "Value(Year,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)'-'Value(DayOfMonth,2)]"}, + {"yyyy[-MM[-dd", "Value(YearOfEra,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"}, + {"yyyy[-MM[-dd]]", "Value(YearOfEra,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)['-'Value(DayOfMonth,2)]]"}, + {"yyyy[-MM[]-dd]", "Value(YearOfEra,4,19,EXCEEDS_PAD)['-'Value(MonthOfYear,2)'-'Value(DayOfMonth,2)]"}, - {"yyyy-MM-dd'T'HH:mm:ss.SSS", "Value(Year,4,19,EXCEEDS_PAD)'-'Value(MonthOfYear,2)'-'Value(DayOfMonth,2)" + + {"yyyy-MM-dd'T'HH:mm:ss.SSS", "Value(YearOfEra,4,19,EXCEEDS_PAD)'-'Value(MonthOfYear,2)'-'Value(DayOfMonth,2)" + "'T'Value(HourOfDay,2)':'Value(MinuteOfHour,2)':'Value(SecondOfMinute,2)'.'Fraction(NanoOfSecond,3,3)"}, - {"e", "WeekBased(e1)"}, - {"w", "WeekBased(w1)"}, - {"W", "WeekBased(W1)"}, - {"WW", "WeekBased(W2)"}, - + {"w", "Localized(WeekOfWeekBasedYear,1)"}, + {"ww", "Localized(WeekOfWeekBasedYear,2)"}, + {"W", "Localized(WeekOfMonth,1)"}, }; } - @Test(dataProvider="validPatterns", groups={"implementation"}) + @Test(dataProvider="validPatterns") public void test_appendPattern_valid(String input, String expected) throws Exception { builder.appendPattern(input); DateTimeFormatter f = builder.toFormatter(); @@ -798,12 +812,34 @@ public class TestDateTimeFormatterBuilder { {"yyyy]MM"}, {"yyyy[MM]]"}, - {"MMMMMM"}, - {"QQQQQQ"}, - {"EEEEEE"}, + {"aa"}, + {"aaa"}, + {"aaaa"}, + {"aaaaa"}, {"aaaaaa"}, - {"ZZZZ"}, + {"MMMMMM"}, + {"LLLLLL"}, + {"QQQQQQ"}, + {"qqqqqq"}, + {"EEEEEE"}, + {"eeeeee"}, + {"cc"}, + {"cccccc"}, + {"ddd"}, + {"DDDD"}, + {"FF"}, + {"FFF"}, + {"hhh"}, + {"HHH"}, + {"kkk"}, + {"KKK"}, + {"mmm"}, + {"sss"}, + {"OO"}, + {"OOO"}, + {"OOOOO"}, {"XXXXXX"}, + {"ZZZZZZ"}, {"zzzzz"}, {"V"}, {"VVV"}, @@ -823,9 +859,8 @@ public class TestDateTimeFormatterBuilder { {"fa"}, {"fM"}, - {"ww"}, - {"ee"}, - {"WWW"}, + {"www"}, + {"WW"}, }; } @@ -844,9 +879,9 @@ public class TestDateTimeFormatterBuilder { return new Object[][] { {"Q", date(2012, 2, 10), "1"}, {"QQ", date(2012, 2, 10), "01"}, -// {"QQQ", date(2012, 2, 10), "Q1"}, // TODO: data for quarters? -// {"QQQQ", date(2012, 2, 10), "Q1"}, -// {"QQQQQ", date(2012, 2, 10), "Q1"}, + {"QQQ", date(2012, 2, 10), "Q1"}, + {"QQQQ", date(2012, 2, 10), "1st quarter"}, + {"QQQQQ", date(2012, 2, 10), "1"}, }; } diff --git a/jdk/test/java/time/test/java/time/format/TestDateTimeTextProvider.java b/jdk/test/java/time/test/java/time/format/TestDateTimeTextProvider.java index 1d34a2d05f1..056dfa22dcd 100644 --- a/jdk/test/java/time/test/java/time/format/TestDateTimeTextProvider.java +++ b/jdk/test/java/time/test/java/time/format/TestDateTimeTextProvider.java @@ -59,17 +59,16 @@ */ package test.java.time.format; -import java.time.format.*; - import static java.time.temporal.ChronoField.AMPM_OF_DAY; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static org.testng.Assert.assertEquals; -import java.util.Locale; - import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.TextStyle; import java.time.temporal.TemporalField; +import java.util.Locale; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -77,7 +76,7 @@ import org.testng.annotations.Test; /** * Test SimpleDateTimeTextProvider. */ -@Test(groups={"implementation"}) +@Test public class TestDateTimeTextProvider extends AbstractTestPrinterParser { Locale enUS = new Locale("en", "US"); diff --git a/jdk/test/java/time/test/java/time/format/TestFractionPrinterParser.java b/jdk/test/java/time/test/java/time/format/TestFractionPrinterParser.java index 2925c9f7988..ae940540f6c 100644 --- a/jdk/test/java/time/test/java/time/format/TestFractionPrinterParser.java +++ b/jdk/test/java/time/test/java/time/format/TestFractionPrinterParser.java @@ -78,7 +78,7 @@ import test.java.time.temporal.MockFieldValue; /** * Test FractionPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestFractionPrinterParser extends AbstractTestPrinterParser { private DateTimeFormatter getFormatter(TemporalField field, int minWidth, int maxWidth, boolean decimalPoint) { diff --git a/jdk/test/java/time/test/java/time/format/TestNonIsoFormatter.java b/jdk/test/java/time/test/java/time/format/TestNonIsoFormatter.java index 43a603cceae..24852eff096 100644 --- a/jdk/test/java/time/test/java/time/format/TestNonIsoFormatter.java +++ b/jdk/test/java/time/test/java/time/format/TestNonIsoFormatter.java @@ -22,16 +22,29 @@ */ package test.java.time.format; -import java.time.*; -import java.time.chrono.*; -import java.time.format.*; -import java.time.temporal.*; +import static org.testng.Assert.assertEquals; + +import java.time.LocalDate; +import java.time.chrono.ChronoLocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.chrono.MinguoChronology; +import java.time.chrono.ThaiBuddhistChronology; +import java.time.format.DateTimeFormatSymbols; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.DateTimeParseException; +import java.time.format.FormatStyle; +import java.time.format.TextStyle; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQuery; import java.util.Locale; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; /** * Test DateTimeFormatter with non-ISO chronology. @@ -39,8 +52,9 @@ import static org.testng.Assert.assertEquals; * Strings in test data are all dependent on CLDR data which may change * in future CLDR releases. */ -@Test(groups={"implementation"}) +@Test public class TestNonIsoFormatter { + private static final Chronology ISO8601 = IsoChronology.INSTANCE; private static final Chronology JAPANESE = JapaneseChronology.INSTANCE; private static final Chronology HIJRAH = HijrahChronology.INSTANCE; private static final Chronology MINGUO = MinguoChronology.INSTANCE; @@ -50,7 +64,8 @@ public class TestNonIsoFormatter { private static final Locale ARABIC = new Locale("ar"); private static final Locale thTH = new Locale("th", "TH"); - private static final Locale thTHTH = new Locale("th", "TH", "TH"); + private static final Locale thTHTH = Locale.forLanguageTag("th-TH-u-nu-thai"); + private static final Locale jaJPJP = Locale.forLanguageTag("ja-JP-u-ca-japanese"); @BeforeMethod public void setUp() { @@ -59,19 +74,22 @@ public class TestNonIsoFormatter { @DataProvider(name="format_data") Object[][] formatData() { return new Object[][] { - // Chronology, Locale, ChronoLocalDate, expected string - { JAPANESE, Locale.JAPANESE, JAPANESE.date(IsoDate), - "\u5e73\u621025\u5e742\u670811\u65e5\u6708\u66dc\u65e5" }, // Japanese Heisei 25-02-11 (Mon) - { HIJRAH, ARABIC, HIJRAH.date(IsoDate), - "\u0627\u0644\u0627\u062b\u0646\u064a\u0646\u060c 30 \u0631\u0628\u064a\u0639 " - + "\u0627\u0644\u0623\u0648\u0644 1434" }, // Hijrah AH 1434-03-30 (Mon) - { MINGUO, Locale.TAIWAN, MINGUO.date(IsoDate), + // Chronology, Format Locale, Numbering Locale, ChronoLocalDate, expected string + { JAPANESE, Locale.JAPANESE, Locale.JAPANESE, JAPANESE.date(IsoDate), + "\u5e73\u621025\u5e742\u670811\u65e5" }, // Japanese Heisei 25-02-11 + { HIJRAH, ARABIC, ARABIC, HIJRAH.date(IsoDate), + "\u0627\u0644\u0627\u062b\u0646\u064a\u0646\u060c 1 \u0631\u0628\u064a\u0639 " + + "\u0627\u0644\u0622\u062e\u0631 1434" }, // Hijrah AH 1434-04-01 (Mon) + { MINGUO, Locale.TAIWAN, Locale.TAIWAN, MINGUO.date(IsoDate), "\u6c11\u570b102\u5e742\u670811\u65e5\u661f\u671f\u4e00" }, // Minguo ROC 102-02-11 (Mon) - { BUDDHIST, thTH, BUDDHIST.date(IsoDate), + { BUDDHIST, thTH, thTH, BUDDHIST.date(IsoDate), "\u0e27\u0e31\u0e19\u0e08\u0e31\u0e19\u0e17\u0e23\u0e4c\u0e17\u0e35\u0e48" + " 11 \u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c" + " \u0e1e.\u0e28. 2556" }, // ThaiBuddhist BE 2556-02-11 - // { BUDDHIST, thTHTH, BUDDHIST.date(IsoDate), "" }, // doesn't work + { BUDDHIST, thTH, thTHTH, BUDDHIST.date(IsoDate), + "\u0e27\u0e31\u0e19\u0e08\u0e31\u0e19\u0e17\u0e23\u0e4c\u0e17\u0e35\u0e48 \u0e51\u0e51 " + + "\u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c \u0e1e.\u0e28. " + + "\u0e52\u0e55\u0e55\u0e56" }, // ThaiBuddhist BE 2556-02-11 (with Thai digits) }; } @@ -79,23 +97,49 @@ public class TestNonIsoFormatter { Object[][] invalidText() { return new Object[][] { // TODO: currently fixed Chronology and Locale. - { "\u662d\u548c64\u5e741\u67089\u65e5\u6708\u66dc\u65e5" }, // S64.01.09 (Mon) + // line commented out, as S64.01.09 seems like a reasonable thing to parse + // (era "S" ended on S64.01.07, but a little leniency is a good thing +// { "\u662d\u548c64\u5e741\u67089\u65e5\u6708\u66dc\u65e5" }, // S64.01.09 (Mon) { "\u662d\u548c65\u5e741\u67081\u65e5\u6708\u66dc\u65e5" }, // S65.01.01 (Mon) }; } + @DataProvider(name="chrono_names") + Object[][] chronoNamesData() { + return new Object[][] { + // Chronology, Locale, Chronology Name + { ISO8601, Locale.ENGLISH, "ISO" }, // No data in CLDR; Use Id. + { BUDDHIST, Locale.ENGLISH, "Buddhist Calendar" }, + { HIJRAH, Locale.ENGLISH, "Hijrah-umalqura" }, // No data in CLDR; Use Id. + { JAPANESE, Locale.ENGLISH, "Japanese Calendar" }, + { MINGUO, Locale.ENGLISH, "Minguo Calendar" }, + + { ISO8601, Locale.JAPANESE, "ISO" }, // No data in CLDR; Use Id. + { JAPANESE, Locale.JAPANESE, "\u548c\u66a6" }, + { BUDDHIST, Locale.JAPANESE, "\u30bf\u30a4\u4ecf\u6559\u66a6" }, + + { ISO8601, thTH, "ISO" }, // No data in CLDR; Use Id. + { JAPANESE, thTH, "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e0d\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e19" }, + { BUDDHIST, thTH, "\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e1e\u0e38\u0e17\u0e18" }, + }; + } + @Test(dataProvider="format_data") - public void test_formatLocalizedDate(Chronology chrono, Locale locale, ChronoLocalDate date, String expected) { + public void test_formatLocalizedDate(Chronology chrono, Locale formatLocale, Locale numberingLocale, + ChronoLocalDate date, String expected) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) - .withChronology(chrono).withLocale(locale); + .withChronology(chrono).withLocale(formatLocale) + .withSymbols(DateTimeFormatSymbols.of(numberingLocale)); String text = dtf.format(date); assertEquals(text, expected); } @Test(dataProvider="format_data") - public void test_parseLocalizedText(Chronology chrono, Locale locale, ChronoLocalDate expected, String text) { + public void test_parseLocalizedText(Chronology chrono, Locale formatLocale, Locale numberingLocale, + ChronoLocalDate expected, String text) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) - .withChronology(chrono).withLocale(locale); + .withChronology(chrono).withLocale(formatLocale) + .withSymbols(DateTimeFormatSymbols.of(numberingLocale)); TemporalAccessor temporal = dtf.parse(text); ChronoLocalDate date = chrono.date(temporal); assertEquals(date, expected); @@ -105,6 +149,17 @@ public class TestNonIsoFormatter { public void test_parseInvalidText(String text) { DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) .withChronology(JAPANESE).withLocale(Locale.JAPANESE); - TemporalAccessor temporal = dtf.parse(text); + dtf.parse(text); + } + + @Test(dataProvider="chrono_names") + public void test_chronoNames(Chronology chrono, Locale locale, String expected) { + DateTimeFormatter dtf = new DateTimeFormatterBuilder().appendChronologyText(TextStyle.SHORT) + .toFormatter(locale); + String text = dtf.format(chrono.dateNow()); + assertEquals(text, expected); + TemporalAccessor ta = dtf.parse(text); + Chronology cal = ta.query(TemporalQuery.chronology()); + assertEquals(cal, chrono); } } diff --git a/jdk/test/java/time/test/java/time/format/TestNumberParser.java b/jdk/test/java/time/test/java/time/format/TestNumberParser.java index 5dca693e80f..a6fc4a2ee47 100644 --- a/jdk/test/java/time/test/java/time/format/TestNumberParser.java +++ b/jdk/test/java/time/test/java/time/format/TestNumberParser.java @@ -70,9 +70,9 @@ import static org.testng.Assert.fail; import java.text.ParsePosition; import java.time.format.DateTimeFormatter; import java.time.format.SignStyle; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQuery; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -80,7 +80,7 @@ import org.testng.annotations.Test; /** * Test NumberPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestNumberParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- @@ -178,8 +178,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { assertTrue(subsequentWidth >= 0); assertEquals(ppos.getIndex(), expectedPos + subsequentWidth); assertEquals(parsed.getLong(DAY_OF_MONTH), expectedValue); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } @@ -198,8 +198,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { assertTrue(subsequentWidth >= 0); assertEquals(ppos.getIndex(), expectedPos + subsequentWidth); assertEquals(parsed.getLong(DAY_OF_WEEK), expectedValue); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } @@ -313,8 +313,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { } else { assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } @@ -423,8 +423,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { } else { assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } @@ -514,8 +514,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { } else { assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } @@ -552,8 +552,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(MONTH_OF_YEAR), (long) parseMonth); assertEquals(parsed.getLong(DAY_OF_MONTH), (long) parsedDay); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } diff --git a/jdk/test/java/time/test/java/time/format/TestPadPrinterDecorator.java b/jdk/test/java/time/test/java/time/format/TestPadPrinterDecorator.java index c8dcbf39c53..adb7677556a 100644 --- a/jdk/test/java/time/test/java/time/format/TestPadPrinterDecorator.java +++ b/jdk/test/java/time/test/java/time/format/TestPadPrinterDecorator.java @@ -69,7 +69,7 @@ import org.testng.annotations.Test; /** * Test PadPrinterDecorator. */ -@Test(groups={"implementation"}) +@Test public class TestPadPrinterDecorator extends AbstractTestPrinterParser { //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/test/java/time/format/TestReducedParser.java b/jdk/test/java/time/test/java/time/format/TestReducedParser.java index c1a41bbef95..b8ae45f8542 100644 --- a/jdk/test/java/time/test/java/time/format/TestReducedParser.java +++ b/jdk/test/java/time/test/java/time/format/TestReducedParser.java @@ -75,7 +75,7 @@ import org.testng.annotations.Test; /** * Test ReducedPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestReducedParser extends AbstractTestPrinterParser { private DateTimeFormatter getFormatter0(TemporalField field, int width, int baseValue) { diff --git a/jdk/test/java/time/test/java/time/format/TestReducedPrinter.java b/jdk/test/java/time/test/java/time/format/TestReducedPrinter.java index 76060691910..b213b80fece 100644 --- a/jdk/test/java/time/test/java/time/format/TestReducedPrinter.java +++ b/jdk/test/java/time/test/java/time/format/TestReducedPrinter.java @@ -59,24 +59,23 @@ */ package test.java.time.format; -import java.time.format.*; - import static java.time.temporal.ChronoField.YEAR; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; import java.time.DateTimeException; import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalField; -import test.java.time.temporal.MockFieldValue; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import test.java.time.temporal.MockFieldValue; /** * Test ReducedPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestReducedPrinter extends AbstractTestPrinterParser { private DateTimeFormatter getFormatter0(TemporalField field, int width, int baseValue) { diff --git a/jdk/test/java/time/test/java/time/format/TestSettingsParser.java b/jdk/test/java/time/test/java/time/format/TestSettingsParser.java index ed3b0a58716..ce7b2d7f187 100644 --- a/jdk/test/java/time/test/java/time/format/TestSettingsParser.java +++ b/jdk/test/java/time/test/java/time/format/TestSettingsParser.java @@ -68,7 +68,7 @@ import org.testng.annotations.Test; /** * Test SettingsParser. */ -@Test(groups={"implementation"}) +@Test public class TestSettingsParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/test/java/time/format/TestStringLiteralParser.java b/jdk/test/java/time/test/java/time/format/TestStringLiteralParser.java index a2096521bff..8b624417820 100644 --- a/jdk/test/java/time/test/java/time/format/TestStringLiteralParser.java +++ b/jdk/test/java/time/test/java/time/format/TestStringLiteralParser.java @@ -65,8 +65,8 @@ import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; import java.text.ParsePosition; -import java.time.temporal.Queries; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQuery; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -74,7 +74,7 @@ import org.testng.annotations.Test; /** * Test StringLiteralPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestStringLiteralParser extends AbstractTestPrinterParser { @DataProvider(name="success") @@ -114,8 +114,8 @@ public class TestStringLiteralParser extends AbstractTestPrinterParser { } else { assertEquals(ppos.getIndex(), expectedPos); assertEquals(parsed.isSupported(YEAR), false); - assertEquals(parsed.query(Queries.chronology()), null); - assertEquals(parsed.query(Queries.zoneId()), null); + assertEquals(parsed.query(TemporalQuery.chronology()), null); + assertEquals(parsed.query(TemporalQuery.zoneId()), null); } } diff --git a/jdk/test/java/time/test/java/time/format/TestStringLiteralPrinter.java b/jdk/test/java/time/test/java/time/format/TestStringLiteralPrinter.java index 62d6a4efc0c..6733af164a4 100644 --- a/jdk/test/java/time/test/java/time/format/TestStringLiteralPrinter.java +++ b/jdk/test/java/time/test/java/time/format/TestStringLiteralPrinter.java @@ -59,8 +59,6 @@ */ package test.java.time.format; -import java.time.format.*; - import static org.testng.Assert.assertEquals; import org.testng.annotations.Test; @@ -68,7 +66,7 @@ import org.testng.annotations.Test; /** * Test StringLiteralPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestStringLiteralPrinter extends AbstractTestPrinterParser { //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/test/java/time/format/TestTextParser.java b/jdk/test/java/time/test/java/time/format/TestTextParser.java index 9e9c3f73973..07bd2146212 100644 --- a/jdk/test/java/time/test/java/time/format/TestTextParser.java +++ b/jdk/test/java/time/test/java/time/format/TestTextParser.java @@ -62,10 +62,13 @@ package test.java.time.format; import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.text.ParsePosition; +import java.time.DayOfWeek; +import java.time.format.DateTimeFormatter; import java.time.format.TextStyle; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; @@ -77,8 +80,10 @@ import org.testng.annotations.Test; /** * Test TextPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestTextParser extends AbstractTestPrinterParser { + static final Locale RUSSIAN = new Locale("ru"); + static final Locale FINNISH = new Locale("fi"); //----------------------------------------------------------------------- @DataProvider(name="error") @@ -165,6 +170,21 @@ public class TestTextParser extends AbstractTestPrinterParser { {MONTH_OF_YEAR, TextStyle.SHORT, 1, "Jan"}, {MONTH_OF_YEAR, TextStyle.SHORT, 12, "Dec"}, + + {QUARTER_OF_YEAR, TextStyle.FULL, 1, "1st quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 2, "2nd quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 3, "3rd quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 4, "4th quarter"}, + + {QUARTER_OF_YEAR, TextStyle.SHORT, 1, "Q1"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 2, "Q2"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 3, "Q3"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 4, "Q4"}, + + {QUARTER_OF_YEAR, TextStyle.NARROW, 1, "1"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 2, "2"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 3, "3"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 4, "4"}, }; } @@ -183,6 +203,46 @@ public class TestTextParser extends AbstractTestPrinterParser { }; } + // Test data is dependent on localized resources. + @DataProvider(name="parseStandaloneText") + Object[][] providerStandaloneText() { + // Locale, TemporalField, TextStyle, expected value, input text + return new Object[][] { + {RUSSIAN, MONTH_OF_YEAR, TextStyle.FULL_STANDALONE, 1, "\u042f\u043d\u0432\u0430\u0440\u044c"}, + {RUSSIAN, MONTH_OF_YEAR, TextStyle.FULL_STANDALONE, 12, "\u0414\u0435\u043a\u0430\u0431\u0440\u044c"}, + {RUSSIAN, MONTH_OF_YEAR, TextStyle.SHORT_STANDALONE, 1, "\u042f\u043d\u0432."}, + {RUSSIAN, MONTH_OF_YEAR, TextStyle.SHORT_STANDALONE, 12, "\u0414\u0435\u043a."}, + {FINNISH, DAY_OF_WEEK, TextStyle.FULL_STANDALONE, 2, "tiistai"}, + {FINNISH, DAY_OF_WEEK, TextStyle.SHORT_STANDALONE, 2, "ti"}, + }; + } + + @DataProvider(name="parseDayOfWeekText") + Object[][] providerDayOfWeekData() { + return new Object[][] { + // Locale, pattern, input text, expected DayOfWeek + {Locale.US, "e", "1", DayOfWeek.SUNDAY}, + {Locale.US, "ee", "01", DayOfWeek.SUNDAY}, + {Locale.US, "c", "1", DayOfWeek.SUNDAY}, + + {Locale.UK, "e", "1", DayOfWeek.MONDAY}, + {Locale.UK, "ee", "01", DayOfWeek.MONDAY}, + {Locale.UK, "c", "1", DayOfWeek.MONDAY}, + }; + } + + // Test data is dependent on localized resources. + @DataProvider(name="parseLenientText") + Object[][] providerLenientText() { + // Locale, TemporalField, expected value, input text + return new Object[][] { + {RUSSIAN, MONTH_OF_YEAR, 1, "\u044f\u043d\u0432\u0430\u0440\u044f"}, // full format + {RUSSIAN, MONTH_OF_YEAR, 1, "\u042f\u043d\u0432\u0430\u0440\u044c"}, // full standalone + {RUSSIAN, MONTH_OF_YEAR, 1, "\u044f\u043d\u0432"}, // short format + {RUSSIAN, MONTH_OF_YEAR, 1, "\u042f\u043d\u0432."}, // short standalone + }; + } + @Test(dataProvider="parseText") public void test_parseText(TemporalField field, TextStyle style, int value, String input) throws Exception { ParsePosition pos = new ParsePosition(0); @@ -197,12 +257,32 @@ public class TestTextParser extends AbstractTestPrinterParser { assertEquals(pos.getIndex(), input.length()); } + @Test(dataProvider="parseStandaloneText") + public void test_parseStandaloneText(Locale locale, TemporalField field, TextStyle style, int expectedValue, String input) { + DateTimeFormatter formatter = getFormatter(field, style).withLocale(locale); + ParsePosition pos = new ParsePosition(0); + assertEquals(formatter.parseUnresolved(input, pos).getLong(field), (long) expectedValue); + assertEquals(pos.getIndex(), input.length()); + } + + @Test(dataProvider="parseDayOfWeekText") + public void test_parseDayOfWeekText(Locale locale, String pattern, String input, DayOfWeek expected) { + DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); + ParsePosition pos = new ParsePosition(0); + assertEquals(DayOfWeek.from(formatter.parse(input, pos)), expected); + assertEquals(pos.getIndex(), input.length()); + } + //----------------------------------------------------------------------- @Test(dataProvider="parseText") public void test_parse_strict_caseSensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception { + if (input.equals(input.toUpperCase(Locale.ROOT))) { + // Skip if the given input is all upper case (e.g., "Q1") + return; + } setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); - getFormatter(field, style).parseUnresolved(input.toUpperCase(), pos); + getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos); assertEquals(pos.getErrorIndex(), 0); } @@ -210,16 +290,20 @@ public class TestTextParser extends AbstractTestPrinterParser { public void test_parse_strict_caseInsensitive_parseUpper(TemporalField field, TextStyle style, int value, String input) throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input.toUpperCase(), pos).getLong(field), (long) value); + assertEquals(getFormatter(field, style).parseUnresolved(input.toUpperCase(Locale.ROOT), pos).getLong(field), (long) value); assertEquals(pos.getIndex(), input.length()); } //----------------------------------------------------------------------- @Test(dataProvider="parseText") public void test_parse_strict_caseSensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception { + if (input.equals(input.toLowerCase(Locale.ROOT))) { + // Skip if the given input is all lower case (e.g., "1st quarter") + return; + } setCaseSensitive(true); ParsePosition pos = new ParsePosition(0); - getFormatter(field, style).parseUnresolved(input.toLowerCase(), pos); + getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos); assertEquals(pos.getErrorIndex(), 0); } @@ -227,7 +311,7 @@ public class TestTextParser extends AbstractTestPrinterParser { public void test_parse_strict_caseInsensitive_parseLower(TemporalField field, TextStyle style, int value, String input) throws Exception { setCaseSensitive(false); ParsePosition pos = new ParsePosition(0); - assertEquals(getFormatter(field, style).parseUnresolved(input.toLowerCase(), pos).getLong(field), (long) value); + assertEquals(getFormatter(field, style).parseUnresolved(input.toLowerCase(Locale.ROOT), pos).getLong(field), (long) value); assertEquals(pos.getIndex(), input.length()); } @@ -340,4 +424,13 @@ public class TestTextParser extends AbstractTestPrinterParser { assertEquals(pos.getIndex(), 1); } + @Test(dataProvider="parseLenientText") + public void test_parseLenientText(Locale locale, TemporalField field, int expectedValue, String input) { + setStrict(false); + ParsePosition pos = new ParsePosition(0); + DateTimeFormatter formatter = getFormatter(field).withLocale(locale); + assertEquals(formatter.parseUnresolved(input, pos).getLong(field), (long) expectedValue); + assertEquals(pos.getIndex(), input.length()); + } + } diff --git a/jdk/test/java/time/test/java/time/format/TestTextPrinter.java b/jdk/test/java/time/test/java/time/format/TestTextPrinter.java index 43f2df31bef..662288c1733 100644 --- a/jdk/test/java/time/test/java/time/format/TestTextPrinter.java +++ b/jdk/test/java/time/test/java/time/format/TestTextPrinter.java @@ -59,30 +59,33 @@ */ package test.java.time.format; -import java.time.format.*; - import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; -import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.ERA; +import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.IsoFields.QUARTER_OF_YEAR; import static org.testng.Assert.assertEquals; -import java.util.Locale; - import java.time.DateTimeException; +import java.time.DayOfWeek; import java.time.LocalDate; -import java.time.temporal.TemporalField; import java.time.chrono.JapaneseChronology; -import test.java.time.temporal.MockFieldValue; +import java.time.format.DateTimeFormatter; +import java.time.format.TextStyle; +import java.time.temporal.TemporalField; +import java.util.Locale; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import test.java.time.temporal.MockFieldValue; /** * Test TextPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestTextPrinter extends AbstractTestPrinterParser { + static final Locale RUSSIAN = new Locale("ru"); + static final Locale FINNISH = new Locale("fi"); //----------------------------------------------------------------------- @Test(expectedExceptions=DateTimeException.class) @@ -166,15 +169,57 @@ public class TestTextPrinter extends AbstractTestPrinterParser { {MONTH_OF_YEAR, TextStyle.SHORT, 11, "Nov"}, {MONTH_OF_YEAR, TextStyle.SHORT, 12, "Dec"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 1, "J"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 2, "F"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 3, "M"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 4, "A"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 5, "M"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 6, "J"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 7, "J"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 8, "A"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 9, "S"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 10, "O"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 11, "N"}, + {MONTH_OF_YEAR, TextStyle.NARROW, 12, "D"}, + {ERA, TextStyle.FULL, 0, "Before Christ"}, {ERA, TextStyle.FULL, 1, "Anno Domini"}, {ERA, TextStyle.SHORT, 0, "BC"}, {ERA, TextStyle.SHORT, 1, "AD"}, {ERA, TextStyle.NARROW, 0, "B"}, {ERA, TextStyle.NARROW, 1, "A"}, + + {QUARTER_OF_YEAR, TextStyle.FULL, 1, "1st quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 2, "2nd quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 3, "3rd quarter"}, + {QUARTER_OF_YEAR, TextStyle.FULL, 4, "4th quarter"}, + + {QUARTER_OF_YEAR, TextStyle.SHORT, 1, "Q1"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 2, "Q2"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 3, "Q3"}, + {QUARTER_OF_YEAR, TextStyle.SHORT, 4, "Q4"}, + + {QUARTER_OF_YEAR, TextStyle.NARROW, 1, "1"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 2, "2"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 3, "3"}, + {QUARTER_OF_YEAR, TextStyle.NARROW, 4, "4"}, }; } + @DataProvider(name="print_DayOfWeekData") + Object[][] providerDayOfWeekData() { + return new Object[][] { + // Locale, pattern, expected text, input DayOfWeek + {Locale.US, "e", "1", DayOfWeek.SUNDAY}, + {Locale.US, "ee", "01", DayOfWeek.SUNDAY}, + {Locale.US, "c", "1", DayOfWeek.SUNDAY}, + + {Locale.UK, "e", "1", DayOfWeek.MONDAY}, + {Locale.UK, "ee", "01", DayOfWeek.MONDAY}, + {Locale.UK, "c", "1", DayOfWeek.MONDAY}, + }; + } + @DataProvider(name="print_JapaneseChronology") Object[][] provider_japaneseEra() { return new Object[][] { @@ -184,12 +229,32 @@ public class TestTextPrinter extends AbstractTestPrinterParser { }; }; + // Test data is dependent on localized resources. + @DataProvider(name="print_standalone") + Object[][] provider_StandaloneNames() { + return new Object[][] { + // standalone names for 2013-01-01 (Tue) + // Locale, TemporalField, TextStyle, expected text + {RUSSIAN, MONTH_OF_YEAR, TextStyle.FULL_STANDALONE, "\u042f\u043d\u0432\u0430\u0440\u044c"}, + {RUSSIAN, MONTH_OF_YEAR, TextStyle.SHORT_STANDALONE, "\u042f\u043d\u0432."}, + {FINNISH, DAY_OF_WEEK, TextStyle.FULL_STANDALONE, "tiistai"}, + {FINNISH, DAY_OF_WEEK, TextStyle.SHORT_STANDALONE, "ti"}, + }; + } + @Test(dataProvider="print") public void test_format(TemporalField field, TextStyle style, int value, String expected) throws Exception { getFormatter(field, style).formatTo(new MockFieldValue(field, value), buf); assertEquals(buf.toString(), expected); } + @Test(dataProvider="print_DayOfWeekData") + public void test_formatDayOfWeek(Locale locale, String pattern, String expected, DayOfWeek dayOfWeek) { + DateTimeFormatter formatter = getPatternFormatter(pattern).withLocale(locale); + String text = formatter.format(dayOfWeek); + assertEquals(text, expected); + } + @Test(dataProvider="print_JapaneseChronology") public void test_formatJapaneseEra(TemporalField field, TextStyle style, int value, String expected) throws Exception { LocalDate ld = LocalDate.of(2013, 1, 31); @@ -197,6 +262,12 @@ public class TestTextPrinter extends AbstractTestPrinterParser { assertEquals(buf.toString(), expected); } + @Test(dataProvider="print_standalone") + public void test_standaloneNames(Locale locale, TemporalField field, TextStyle style, String expected) { + getFormatter(field, style).withLocale(locale).formatTo(LocalDate.of(2013, 1, 1), buf); + assertEquals(buf.toString(), expected); + } + //----------------------------------------------------------------------- public void test_print_french_long() throws Exception { getFormatter(MONTH_OF_YEAR, TextStyle.FULL).withLocale(Locale.FRENCH).formatTo(LocalDate.of(2012, 1, 1), buf); diff --git a/jdk/test/java/time/test/java/time/format/TestZoneOffsetParser.java b/jdk/test/java/time/test/java/time/format/TestZoneOffsetParser.java index 2c9065b93a4..68e84a27dc4 100644 --- a/jdk/test/java/time/test/java/time/format/TestZoneOffsetParser.java +++ b/jdk/test/java/time/test/java/time/format/TestZoneOffsetParser.java @@ -73,7 +73,7 @@ import org.testng.annotations.Test; /** * Test ZoneOffsetPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestZoneOffsetParser extends AbstractTestPrinterParser { //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/test/java/time/format/TestZoneOffsetPrinter.java b/jdk/test/java/time/test/java/time/format/TestZoneOffsetPrinter.java index c84ad05a479..4e1b7a402c7 100644 --- a/jdk/test/java/time/test/java/time/format/TestZoneOffsetPrinter.java +++ b/jdk/test/java/time/test/java/time/format/TestZoneOffsetPrinter.java @@ -70,7 +70,7 @@ import org.testng.annotations.Test; /** * Test ZoneOffsetPrinterParser. */ -@Test(groups={"implementation"}) +@Test public class TestZoneOffsetPrinter extends AbstractTestPrinterParser { private static final ZoneOffset OFFSET_0130 = ZoneOffset.of("+01:30"); diff --git a/jdk/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java b/jdk/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java index a7d63e8c47b..0175c223826 100644 --- a/jdk/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java +++ b/jdk/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java @@ -23,7 +23,18 @@ package test.java.time.format; +import static org.testng.Assert.assertEquals; + import java.text.DateFormatSymbols; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatSymbols; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.TextStyle; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalQuery; +import java.time.zone.ZoneRulesProvider; import java.util.Arrays; import java.util.Date; import java.util.HashSet; @@ -32,24 +43,13 @@ import java.util.Random; import java.util.Set; import java.util.TimeZone; -import java.time.ZonedDateTime; -import java.time.ZoneId; -import java.time.temporal.ChronoField; -import java.time.temporal.Queries; -import java.time.format.DateTimeFormatSymbols; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeFormatterBuilder; -import java.time.format.TextStyle; -import java.time.zone.ZoneRulesProvider; - import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; /** * Test ZoneTextPrinterParser */ -@Test(groups={"implementation"}) +@Test public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { protected static DateTimeFormatter getFormatter(Locale locale, TextStyle style) { @@ -70,26 +70,23 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { zdt = zdt.withDayOfYear(r.nextInt(365) + 1) .with(ChronoField.SECOND_OF_DAY, r.nextInt(86400)); for (String zid : zids) { - if (zid.equals("ROC") || - zid.startsWith("UTC") || - zid.startsWith("GMT") || zid.startsWith("Etc/GMT")) { - // UTC, GMT are treated as zone offset + if (zid.equals("ROC") || zid.startsWith("Etc/GMT")) { continue; // TBD: match jdk behavior? } zdt = zdt.withZoneSameLocal(ZoneId.of(zid)); TimeZone tz = TimeZone.getTimeZone(zid); boolean isDST = tz.inDaylightTime(new Date(zdt.toInstant().toEpochMilli())); for (Locale locale : locales) { - printText(locale, zdt, TextStyle.FULL, - tz.getDisplayName(isDST, TimeZone.LONG, locale)); - printText(locale, zdt, TextStyle.SHORT, - tz.getDisplayName(isDST, TimeZone.SHORT, locale)); + printText(locale, zdt, TextStyle.FULL, tz, + tz.getDisplayName(isDST, TimeZone.LONG, locale)); + printText(locale, zdt, TextStyle.SHORT, tz, + tz.getDisplayName(isDST, TimeZone.SHORT, locale)); } } } } - private void printText(Locale locale, ZonedDateTime zdt, TextStyle style, String expected) { + private void printText(Locale locale, ZonedDateTime zdt, TextStyle style, TimeZone zone, String expected) { String result = getFormatter(locale, style).format(zdt); if (!result.equals(expected)) { if (result.equals("FooLocation")) { // from rules provider test if same vm @@ -97,8 +94,8 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { } System.out.println("----------------"); System.out.printf("tdz[%s]%n", zdt.toString()); - System.out.printf("[%-4s, %5s] :[%s]%n", locale.toString(), style.toString(),result); - System.out.printf("%4s, %5s :[%s]%n", "", "", expected); + System.out.printf("[%-5s, %5s] :[%s]%n", locale.toString(), style.toString(),result); + System.out.printf(" %5s, %5s :[%s] %s%n", "", "", expected, zone); } assertEquals(result, expected); } @@ -153,7 +150,7 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { .toFormatter(locale) .withSymbols(DateTimeFormatSymbols.of(locale)); - String ret = fmt.parse(text, Queries.zone()).getId(); + String ret = fmt.parse(text, TemporalQuery.zone()).getId(); System.out.printf("[%-5s %s] %24s -> %s(%s)%n", locale.toString(), @@ -189,7 +186,7 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { if (ci) { text = text.toUpperCase(); } - String ret = fmt.parse(text, Queries.zone()).getId(); + String ret = fmt.parse(text, TemporalQuery.zone()).getId(); // TBD: need an excluding list // assertEquals(...); if (ret.equals(expected) || diff --git a/jdk/test/java/time/test/java/time/format/ZoneName.java b/jdk/test/java/time/test/java/time/format/ZoneName.java index 4ae5b43f30b..2c494462a7a 100644 --- a/jdk/test/java/time/test/java/time/format/ZoneName.java +++ b/jdk/test/java/time/test/java/time/format/ZoneName.java @@ -24,11 +24,8 @@ package test.java.time.format; import java.util.HashMap; -import java.util.HashSet; import java.util.Locale; import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; class ZoneName { diff --git a/jdk/test/java/time/test/java/time/temporal/MockFieldValue.java b/jdk/test/java/time/test/java/time/temporal/MockFieldValue.java index cceb4c89958..0cd79d7f1e9 100644 --- a/jdk/test/java/time/test/java/time/temporal/MockFieldValue.java +++ b/jdk/test/java/time/test/java/time/temporal/MockFieldValue.java @@ -59,10 +59,11 @@ */ package test.java.time.temporal; -import java.time.temporal.*; - -import java.time.DateTimeException; +import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalField; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.time.temporal.ValueRange; /** * Mock simple date-time with one field-value. @@ -88,7 +89,7 @@ public final class MockFieldValue implements TemporalAccessor { if (isSupported(field)) { return field.range(); } - throw new DateTimeException("Unsupported field: " + field.getName()); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field.getName()); } return field.rangeRefinedBy(this); } @@ -98,7 +99,7 @@ public final class MockFieldValue implements TemporalAccessor { if (this.field.equals(field)) { return value; } - throw new DateTimeException("Unsupported field: " + field); + throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } } diff --git a/jdk/test/java/time/test/java/time/temporal/TestChronoField.java b/jdk/test/java/time/test/java/time/temporal/TestChronoField.java new file mode 100644 index 00000000000..41d464c0a72 --- /dev/null +++ b/jdk/test/java/time/test/java/time/temporal/TestChronoField.java @@ -0,0 +1,159 @@ +/* + * 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. 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. + */ + +/* + * Copyright (c) 2013, Stephen Colebourne & Michael Nascimento Santos + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * * Neither the name of JSR-310 nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package test.java.time.temporal; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +import java.time.temporal.ChronoField; +import java.time.temporal.IsoFields; +import java.time.temporal.TemporalField; +import java.time.temporal.WeekFields; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +@Test +public class TestChronoField { + Map fieldMap; + + + @BeforeClass + public void initClass() { + fieldMap = new HashMap<>(); + fieldMap.put(ChronoField.ERA, "era"); + fieldMap.put(ChronoField.YEAR, "year"); + fieldMap.put(ChronoField.MONTH_OF_YEAR, "month"); + fieldMap.put(ChronoField.DAY_OF_MONTH, "day"); + fieldMap.put(ChronoField.AMPM_OF_DAY, "dayperiod"); + fieldMap.put(ChronoField.ALIGNED_WEEK_OF_YEAR, "week"); + fieldMap.put(ChronoField.DAY_OF_WEEK, "weekday"); + fieldMap.put(ChronoField.HOUR_OF_DAY, "hour"); + fieldMap.put(ChronoField.MINUTE_OF_HOUR, "minute"); + fieldMap.put(ChronoField.SECOND_OF_MINUTE, "second"); + fieldMap.put(ChronoField.OFFSET_SECONDS, "zone"); + } + + @DataProvider(name = "localeList") + Locale[] data_localeList() { + return new Locale[] { + Locale.US, + Locale.GERMAN, + Locale.JAPAN, + Locale.ROOT, + }; + } + //----------------------------------------------------------------------- + @DataProvider(name = "localeDisplayNames") + Object[][] data_localeDisplayNames() { + return new Object[][] { + {ChronoField.ERA}, + {ChronoField.YEAR}, + {ChronoField.MONTH_OF_YEAR}, + {ChronoField.DAY_OF_WEEK}, + // {ChronoField.ALIGNED_WEEK_OF_YEAR}, + {ChronoField.DAY_OF_MONTH}, + {ChronoField.AMPM_OF_DAY}, + {ChronoField.HOUR_OF_DAY}, + {ChronoField.MINUTE_OF_HOUR}, + {ChronoField.SECOND_OF_MINUTE}, + }; + } + + @Test + public void test_IsoFields_week_based_year() { + Locale locale = Locale.US; + String name = IsoFields.WEEK_OF_WEEK_BASED_YEAR.getDisplayName(locale); + assertEquals(name, "Week"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_nullIsoFields_week_based_year() { + String name = IsoFields.WEEK_OF_WEEK_BASED_YEAR.getDisplayName((Locale)null); + } + + @Test + public void test_WeekFields_week_based_year() { + Locale locale = Locale.US; + TemporalField weekOfYearField = WeekFields.SUNDAY_START.weekOfYear(); + String name = weekOfYearField.getDisplayName(locale); + assertEquals(name, "Week"); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_nullWeekFields_week_based_year() { + TemporalField weekOfYearField = WeekFields.SUNDAY_START.weekOfYear(); + String name = weekOfYearField.getDisplayName((Locale)null); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_nullLocaleChronoFieldDisplayName() { + ChronoField.YEAR.getDisplayName((Locale)null); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_nullLocaleTemporalFieldDisplayName() { + // Test the default method in TemporalField using the + // IsoFields.DAY_OF_QUARTER which does not override getDisplayName + IsoFields.DAY_OF_QUARTER.getDisplayName((Locale)null); + } +} diff --git a/jdk/test/java/time/test/java/time/temporal/TestChronoUnit.java b/jdk/test/java/time/test/java/time/temporal/TestChronoUnit.java index 0f84d39591c..eeecea1761d 100644 --- a/jdk/test/java/time/test/java/time/temporal/TestChronoUnit.java +++ b/jdk/test/java/time/test/java/time/temporal/TestChronoUnit.java @@ -121,7 +121,11 @@ public class TestChronoUnit { @Test(dataProvider = "yearsBetween") public void test_yearsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { - assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + if (expected >= 0) { + assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + } else { + assertEquals(YEARS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + } } @Test(dataProvider = "yearsBetween") @@ -132,7 +136,11 @@ public class TestChronoUnit { @Test(dataProvider = "yearsBetween") public void test_yearsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 - assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + if (expected >= 0) { + assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + } else { + assertEquals(YEARS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + } } //----------------------------------------------------------------------- @@ -186,7 +194,11 @@ public class TestChronoUnit { @Test(dataProvider = "monthsBetween") public void test_monthsBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { - assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + if (expected >= 0) { + assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + } else { + assertEquals(MONTHS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + } } @Test(dataProvider = "monthsBetween") @@ -197,7 +209,11 @@ public class TestChronoUnit { @Test(dataProvider = "monthsBetween") public void test_monthsBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 - assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + if (expected >= 0) { + assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + } else { + assertEquals(MONTHS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + } } //----------------------------------------------------------------------- @@ -288,7 +304,11 @@ public class TestChronoUnit { @Test(dataProvider = "daysBetween") public void test_daysBetween_LocalDateTimeLaterTime(LocalDate start, LocalDate end, long expected) { - assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + if (expected >= 0) { + assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 31)), expected); + } else { + assertEquals(DAYS.between(start.atTime(12, 30), end.atTime(12, 29)), expected); + } } @Test(dataProvider = "daysBetween") @@ -299,7 +319,11 @@ public class TestChronoUnit { @Test(dataProvider = "daysBetween") public void test_daysBetween_ZonedDateLaterOffset(LocalDate start, LocalDate end, long expected) { // +01:00 is later than +02:00 - assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + if (expected >= 0) { + assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(2)), end.atStartOfDay(ZoneOffset.ofHours(1))), expected); + } else { + assertEquals(DAYS.between(start.atStartOfDay(ZoneOffset.ofHours(1)), end.atStartOfDay(ZoneOffset.ofHours(2))), expected); + } } //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java b/jdk/test/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java index 941e08e3be7..ffa9fc3c342 100644 --- a/jdk/test/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java +++ b/jdk/test/java/time/test/java/time/temporal/TestDateTimeBuilderCombinations.java @@ -67,8 +67,8 @@ import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static java.time.temporal.ChronoField.DAY_OF_WEEK; import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.EPOCH_DAY; -import static java.time.temporal.ChronoField.EPOCH_MONTH; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; +import static java.time.temporal.ChronoField.PROLEPTIC_MONTH; import static java.time.temporal.ChronoField.YEAR; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; @@ -92,7 +92,7 @@ public class TestDateTimeBuilderCombinations { Object[][] data_combine() { return new Object[][] { {YEAR, 2012, MONTH_OF_YEAR, 6, DAY_OF_MONTH, 3, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, - {EPOCH_MONTH, (2012 - 1970) * 12 + 6 - 1, DAY_OF_MONTH, 3, null, null, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, + {PROLEPTIC_MONTH, 2012 * 12 + 6 - 1, DAY_OF_MONTH, 3, null, null, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 6, DAY_OF_WEEK, 3, null, null, LocalDate.class, LocalDate.of(2012, 2, 8)}, {YEAR, 2012, DAY_OF_YEAR, 155, null, null, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, // {ERA, 1, YEAR_OF_ERA, 2012, DAY_OF_YEAR, 155, null, null, LocalDate.class, LocalDate.of(2012, 6, 3)}, @@ -176,9 +176,9 @@ public class TestDateTimeBuilderCombinations { {ALIGNED_DAY_OF_WEEK_IN_YEAR, 4, ALIGNED_DAY_OF_WEEK_IN_YEAR, 4L}, {ALIGNED_WEEK_OF_MONTH, 4, ALIGNED_WEEK_OF_MONTH, 4}, {ALIGNED_DAY_OF_WEEK_IN_MONTH, 3, ALIGNED_DAY_OF_WEEK_IN_MONTH, 3}, - {EPOCH_MONTH, 15, EPOCH_MONTH, null}, - {EPOCH_MONTH, 15, YEAR, 1971}, - {EPOCH_MONTH, 15, MONTH_OF_YEAR, 4}, + {PROLEPTIC_MONTH, 27, PROLEPTIC_MONTH, null}, + {PROLEPTIC_MONTH, 27, YEAR, 2}, + {PROLEPTIC_MONTH, 27, MONTH_OF_YEAR, 4}, }; } diff --git a/jdk/test/java/time/test/java/time/temporal/TestDateTimeValueRange.java b/jdk/test/java/time/test/java/time/temporal/TestDateTimeValueRange.java index d7397d41e64..67a40839257 100644 --- a/jdk/test/java/time/test/java/time/temporal/TestDateTimeValueRange.java +++ b/jdk/test/java/time/test/java/time/temporal/TestDateTimeValueRange.java @@ -65,7 +65,8 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; - +import java.time.DateTimeException; +import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; import org.testng.annotations.DataProvider; @@ -230,6 +231,42 @@ public class TestDateTimeValueRange extends AbstractTest { assertEquals(test.isValidIntValue(32), false); } + //----------------------------------------------------------------------- + // checkValidValue + //----------------------------------------------------------------------- + @Test(dataProvider="valid") + public void test_of_checkValidValue(long sMin, long lMin, long sMax, long lMax) { + ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); + assertEquals(test.checkValidIntValue(sMin, null), sMin); + assertEquals(test.checkValidIntValue(lMin, null), lMin); + assertEquals(test.checkValidIntValue(sMax, null), sMax); + assertEquals(test.checkValidIntValue(lMax, null), lMax); + } + + @Test(dataProvider="valid", expectedExceptions = DateTimeException.class) + public void test_of_checkValidValueMinException(long sMin, long lMin, long sMax, long lMax) { + ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); + test.checkValidIntValue(sMin-1, null); + } + + @Test(dataProvider="valid", expectedExceptions = DateTimeException.class) + public void test_of_checkValidValueMaxException(long sMin, long lMin, long sMax, long lMax) { + ValueRange test = ValueRange.of(sMin, lMin, sMax, lMax); + test.checkValidIntValue(lMax+1, null); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_checkValidValueUnsupported_long_long() { + ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); + test.checkValidIntValue(0, (ChronoField)null); + } + + @Test(expectedExceptions = DateTimeException.class) + public void test_checkValidValueInvalid_long_long() { + ValueRange test = ValueRange.of(1, 28, Integer.MAX_VALUE + 1L); + test.checkValidIntValue(Integer.MAX_VALUE + 2L, (ChronoField)null); + } + //----------------------------------------------------------------------- // equals() / hashCode() //----------------------------------------------------------------------- diff --git a/jdk/test/java/time/test/java/time/zone/TestFixedZoneRules.java b/jdk/test/java/time/test/java/time/zone/TestFixedZoneRules.java index 67b6e0a2c40..d479134c26e 100644 --- a/jdk/test/java/time/test/java/time/zone/TestFixedZoneRules.java +++ b/jdk/test/java/time/test/java/time/zone/TestFixedZoneRules.java @@ -83,7 +83,7 @@ public class TestFixedZoneRules { } //----------------------------------------------------------------------- - @Test(groups="implementation") + @Test public void test_data_nullInput() { ZoneRules test = make(OFFSET_PONE); assertEquals(test.getOffset((Instant) null), OFFSET_PONE); diff --git a/jdk/test/java/time/test/java/util/TestFormatter.java b/jdk/test/java/time/test/java/util/TestFormatter.java index 69c55f22131..f9e91874577 100644 --- a/jdk/test/java/time/test/java/util/TestFormatter.java +++ b/jdk/test/java/time/test/java/util/TestFormatter.java @@ -35,7 +35,7 @@ import static org.testng.Assert.assertEquals; /* @test * @summary Unit test for j.u.Formatter threeten date/time support */ -@Test(groups={"implementation"}) +@Test public class TestFormatter { // time diff --git a/jdk/test/java/util/Calendar/Bug8007038.java b/jdk/test/java/util/Calendar/Bug8007038.java index e4f1a66082b..e197e1266d7 100644 --- a/jdk/test/java/util/Calendar/Bug8007038.java +++ b/jdk/test/java/util/Calendar/Bug8007038.java @@ -97,7 +97,7 @@ public class Bug8007038 { } private static void checkValueRange(String calType, int field, int value, int style, Locale l, boolean isNonNull) { - String ret = CalendarDataUtility.retrieveFieldValueName(calType, field, value, style, l); + String ret = CalendarDataUtility.retrieveJavaTimeFieldValueName(calType, field, value, style, l); System.out.print("retrieveFieldValueName("+calType+", "+field+", "+value+", "+style+", "+l+")"); if ((ret != null) == isNonNull) { System.out.println(" returned "+ret); diff --git a/jdk/test/java/util/Calendar/CldrFormatNamesTest.java b/jdk/test/java/util/Calendar/CldrFormatNamesTest.java index e45444d1b84..85360726991 100644 --- a/jdk/test/java/util/Calendar/CldrFormatNamesTest.java +++ b/jdk/test/java/util/Calendar/CldrFormatNamesTest.java @@ -48,13 +48,13 @@ public class CldrFormatNamesTest { { Locale.JAPAN, "field.zone", "\u30bf\u30a4\u30e0\u30be\u30fc\u30f3", - "cldr.japanese.DatePatterns", new String[] { + "java.time.japanese.DatePatterns", new String[] { "Gy\u5e74M\u6708d\u65e5EEEE", "Gy\u5e74M\u6708d\u65e5", "Gy\u5e74M\u6708d\u65e5", "Gyy/MM/dd", }, - "cldr.roc.DatePatterns", new String[] { + "java.time.roc.DatePatterns", new String[] { "Gy\u5e74M\u6708d\u65e5EEEE", "Gy\u5e74M\u6708d\u65e5", "Gy/MM/dd", @@ -65,7 +65,7 @@ public class CldrFormatNamesTest { { Locale.PRC, "field.zone", "\u533a\u57df", - "cldr.islamic.DatePatterns", new String[] { + "java.time.islamic.DatePatterns", new String[] { "Gy\u5e74M\u6708d\u65e5EEEE", "Gy\u5e74M\u6708d\u65e5", "Gy\u5e74M\u6708d\u65e5", @@ -76,7 +76,7 @@ public class CldrFormatNamesTest { { Locale.GERMANY, "field.dayperiod", "Tagesh\u00e4lfte", - "cldr.islamic.DatePatterns", new String[] { + "java.time.islamic.DatePatterns", new String[] { "EEEE d. MMMM y G", "d. MMMM y G", "d. MMM y G", @@ -119,7 +119,7 @@ public class CldrFormatNamesTest { for (Object[] data : CLDR_DATA) { Locale locale = (Locale) data[0]; ResourceBundle rb = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale).getFormatData(); + .getLocaleResources(locale).getJavaTimeFormatData(); for (int i = 1; i < data.length; ) { String key = (String) data[i++]; Object expected = data[i++]; @@ -167,7 +167,7 @@ public class CldrFormatNamesTest { int field, int style, String fieldName) { for (int i = 0; i < expected.length; i++) { String expt = expected[i]; - String name = CalendarDataUtility.retrieveFieldValueName(calType, field, i, style, locale); + String name = CalendarDataUtility.retrieveJavaTimeFieldValueName(calType, field, i, style, locale); if (!expt.equals(name)) { errors++; System.err.printf("error: wrong %s %s name in %s: value=%d, got='%s', expected='%s'%n", diff --git a/jdk/test/java/util/Calendar/JavatimeTest.java b/jdk/test/java/util/Calendar/JavatimeTest.java index d7b211705f4..9f61229e1dc 100644 --- a/jdk/test/java/util/Calendar/JavatimeTest.java +++ b/jdk/test/java/util/Calendar/JavatimeTest.java @@ -108,17 +108,20 @@ public class JavatimeTest { // TBD: tzdt intergration if (zidStr.startsWith("SystemV") || zidStr.contains("Riyadh8") || - zidStr.equals("US/Pacific-New")) { + zidStr.equals("US/Pacific-New") || + zidStr.equals("EST") || + zidStr.equals("HST") || + zidStr.equals("MST")) { continue; } - ZoneId zid = ZoneId.of(zidStr, ZoneId.OLD_IDS_POST_2005); + ZoneId zid = ZoneId.of(zidStr, ZoneId.OLD_SHORT_IDS); if (!zid.equals(TimeZone.getTimeZone(zid).toZoneId())) { throw new RuntimeException("FAILED: zid -> tz -> zid :" + zidStr); } TimeZone tz = TimeZone.getTimeZone(zidStr); // no round-trip for alias and "GMT" if (!tz.equals(TimeZone.getTimeZone(tz.toZoneId())) && - !ZoneId.OLD_IDS_POST_2005.containsKey(zidStr) && + !ZoneId.OLD_SHORT_IDS.containsKey(zidStr) && !zidStr.startsWith("GMT")) { throw new RuntimeException("FAILED: tz -> zid -> tz :" + zidStr); } diff --git a/jdk/test/sun/text/resources/LocaleData b/jdk/test/sun/text/resources/LocaleData index 51145049ec9..87b9d44cb27 100644 --- a/jdk/test/sun/text/resources/LocaleData +++ b/jdk/test/sun/text/resources/LocaleData @@ -7661,1139 +7661,5 @@ FormatData/zh/DayNarrows/6=\u516d # bug 7195759 CurrencyNames//ZMW=ZMW -# rfe 8004489, 8006509 -FormatData//calendarname.buddhist=Buddhist Calendar -FormatData//calendarname.gregorian=Gregorian Calendar -FormatData//calendarname.gregory=Gregorian Calendar -FormatData//calendarname.islamic-civil=Islamic-Civil Calendar -FormatData//calendarname.islamic=Islamic Calendar -FormatData//calendarname.islamicc=Islamic-Civil Calendar -FormatData//calendarname.japanese=Japanese Calendar -FormatData//calendarname.roc=Minguo Calendar -FormatData//field.dayperiod=Dayperiod -FormatData//field.era=Era -FormatData//field.hour=Hour -FormatData//field.minute=Minute -FormatData//field.month=Month -FormatData//field.second=Second -FormatData//field.week=Week -FormatData//field.weekday=Day of the Week -FormatData//field.year=Year -FormatData//field.zone=Zone -FormatData//islamic.Eras/0= -FormatData//islamic.Eras/1=AH -FormatData//islamic.MonthNames/0=Muharram -FormatData//islamic.MonthNames/1=Safar -FormatData//islamic.MonthNames/2=Rabi\u02bb I -FormatData//islamic.MonthNames/3=Rabi\u02bb II -FormatData//islamic.MonthNames/4=Jumada I -FormatData//islamic.MonthNames/5=Jumada II -FormatData//islamic.MonthNames/6=Rajab -FormatData//islamic.MonthNames/7=Sha\u02bbban -FormatData//islamic.MonthNames/8=Ramadan -FormatData//islamic.MonthNames/9=Shawwal -FormatData//islamic.MonthNames/10=Dhu\u02bbl-Qi\u02bbdah -FormatData//islamic.MonthNames/11=Dhu\u02bbl-Hijjah -FormatData//islamic.MonthNames/12= -FormatData//islamic.MonthAbbreviations/0=Muh. -FormatData//islamic.MonthAbbreviations/1=Saf. -FormatData//islamic.MonthAbbreviations/2=Rab. I -FormatData//islamic.MonthAbbreviations/3=Rab. II -FormatData//islamic.MonthAbbreviations/4=Jum. I -FormatData//islamic.MonthAbbreviations/5=Jum. II -FormatData//islamic.MonthAbbreviations/6=Raj. -FormatData//islamic.MonthAbbreviations/7=Sha. -FormatData//islamic.MonthAbbreviations/8=Ram. -FormatData//islamic.MonthAbbreviations/9=Shaw. -FormatData//islamic.MonthAbbreviations/10=Dhu\u02bbl-Q. -FormatData//islamic.MonthAbbreviations/11=Dhu\u02bbl-H. -FormatData//islamic.MonthAbbreviations/12= -FormatData//islamic.DatePatterns/0=EEEE, MMMM d, y GGGG -FormatData//islamic.DatePatterns/1=MMMM d, y GGGG -FormatData//islamic.DatePatterns/2=MMM d, y GGGG -FormatData//islamic.DatePatterns/3=M/d/yy GGGG -FormatData//roc.Eras/0=Before R.O.C. -FormatData//roc.Eras/1=R.O.C. -FormatData//roc.DatePatterns/0=EEEE, GGGG y MMMM dd -FormatData//roc.DatePatterns/1=GGGG y MMMM d -FormatData//roc.DatePatterns/2=GGGG y MMM d -FormatData//roc.DatePatterns/3=G yyy-MM-dd -FormatData/ar/calendarname.buddhist=\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0628\u0648\u0630\u064a -FormatData/ar/calendarname.gregorian=\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a -FormatData/ar/calendarname.gregory=\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0645\u064a\u0644\u0627\u062f\u064a -FormatData/ar/calendarname.islamic-civil=\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a -FormatData/ar/calendarname.islamic=\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u0647\u062c\u0631\u064a -FormatData/ar/calendarname.islamicc=\u062a\u0642\u0648\u064a\u0645 \u0627\u0633\u0644\u0627\u0645\u064a \u0645\u062f\u0646\u064a -FormatData/ar/calendarname.japanese=\u0627\u0644\u062a\u0642\u0648\u064a\u0645 \u0627\u0644\u064a\u0627\u0628\u0627\u0646\u064a -FormatData/ar/calendarname.roc=\u062a\u0642\u0648\u064a\u0645 \u0645\u064a\u0646\u062c\u0648 -FormatData/ar/field.dayperiod=\u0635/\u0645 -FormatData/ar/field.era=\u0627\u0644\u0639\u0635\u0631 -FormatData/ar/field.hour=\u0627\u0644\u0633\u0627\u0639\u0627\u062a -FormatData/ar/field.minute=\u0627\u0644\u062f\u0642\u0627\u0626\u0642 -FormatData/ar/field.month=\u0627\u0644\u0634\u0647\u0631 -FormatData/ar/field.second=\u0627\u0644\u062b\u0648\u0627\u0646\u064a -FormatData/ar/field.week=\u0627\u0644\u0623\u0633\u0628\u0648\u0639 -FormatData/ar/field.weekday=\u0627\u0644\u064a\u0648\u0645 -FormatData/ar/field.year=\u0627\u0644\u0633\u0646\u0629 -FormatData/ar/field.zone=\u0627\u0644\u062a\u0648\u0642\u064a\u062a -FormatData/ar/islamic.MonthNames/0=\u0645\u062d\u0631\u0645 -FormatData/ar/islamic.MonthNames/1=\u0635\u0641\u0631 -FormatData/ar/islamic.MonthNames/2=\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644 -FormatData/ar/islamic.MonthNames/3=\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631 -FormatData/ar/islamic.MonthNames/4=\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649 -FormatData/ar/islamic.MonthNames/5=\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629 -FormatData/ar/islamic.MonthNames/6=\u0631\u062c\u0628 -FormatData/ar/islamic.MonthNames/7=\u0634\u0639\u0628\u0627\u0646 -FormatData/ar/islamic.MonthNames/8=\u0631\u0645\u0636\u0627\u0646 -FormatData/ar/islamic.MonthNames/9=\u0634\u0648\u0627\u0644 -FormatData/ar/islamic.MonthNames/10=\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629 -FormatData/ar/islamic.MonthNames/11=\u0630\u0648 \u0627\u0644\u062d\u062c\u0629 -FormatData/ar/islamic.MonthNames/12= -FormatData/ar/islamic.MonthAbbreviations/0=\u0645\u062d\u0631\u0645 -FormatData/ar/islamic.MonthAbbreviations/1=\u0635\u0641\u0631 -FormatData/ar/islamic.MonthAbbreviations/2=\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644 -FormatData/ar/islamic.MonthAbbreviations/3=\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631 -FormatData/ar/islamic.MonthAbbreviations/4=\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649 -FormatData/ar/islamic.MonthAbbreviations/5=\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629 -FormatData/ar/islamic.MonthAbbreviations/6=\u0631\u062c\u0628 -FormatData/ar/islamic.MonthAbbreviations/7=\u0634\u0639\u0628\u0627\u0646 -FormatData/ar/islamic.MonthAbbreviations/8=\u0631\u0645\u0636\u0627\u0646 -FormatData/ar/islamic.MonthAbbreviations/9=\u0634\u0648\u0627\u0644 -FormatData/ar/islamic.MonthAbbreviations/10=\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629 -FormatData/ar/islamic.MonthAbbreviations/11=\u0630\u0648 \u0627\u0644\u062d\u062c\u0629 -FormatData/ar/islamic.MonthAbbreviations/12= -FormatData/ar/islamic.Eras/0= -FormatData/ar/islamic.Eras/1=\u0647\u0640 -FormatData//islamic.DatePatterns/0=EEEE, MMMM d, y GGGG -FormatData//islamic.DatePatterns/1=MMMM d, y GGGG -FormatData//islamic.DatePatterns/2=MMM d, y GGGG -FormatData//islamic.DatePatterns/3=M/d/yy GGGG -FormatData/ar/roc.DatePatterns/0=EEEE\u060c d MMMM\u060c y GGGG -FormatData/ar/roc.DatePatterns/1=d MMMM\u060c y GGGG -FormatData/ar/roc.DatePatterns/2=dd\u200f/MM\u200f/y GGGG -FormatData/ar/roc.DatePatterns/3=d\u200f/M\u200f/y GGGG -FormatData/be/calendarname.buddhist=\u0431\u0443\u0434\u044b\u0441\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.gregorian=\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.gregory=\u0433\u0440\u044d\u0433\u0430\u0440\u044b\u044f\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.islamic-civil=\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.islamic=\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.islamicc=\u043c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u043a\u0456 \u0441\u0432\u0435\u0446\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/calendarname.japanese=\u044f\u043f\u043e\u043d\u0441\u043a\u0456 \u043a\u0430\u043b\u044f\u043d\u0434\u0430\u0440 -FormatData/be/field.era=\u044d\u0440\u0430 -FormatData/be/field.hour=\u0433\u0430\u0434\u0437\u0456\u043d\u0430 -FormatData/be/field.minute=\u0445\u0432\u0456\u043b\u0456\u043d\u0430 -FormatData/be/field.month=\u043c\u0435\u0441\u044f\u0446 -FormatData/be/field.second=\u0441\u0435\u043a\u0443\u043d\u0434\u0430 -FormatData/be/field.week=\u0442\u044b\u0434\u0437\u0435\u043d\u044c -FormatData/be/field.weekday=\u0434\u0437\u0435\u043d\u044c \u0442\u044b\u0434\u043d\u044f -FormatData/be/field.year=\u0433\u043e\u0434 -FormatData/bg/calendarname.buddhist=\u0411\u0443\u0434\u0438\u0441\u0442\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.gregorian=\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.gregory=\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.islamic-civil=\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.islamic=\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.islamicc=\u0418\u0441\u043b\u044f\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u0435\u043d \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.japanese=\u042f\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/bg/calendarname.roc=\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u0442\u0430\u0439 -FormatData/bg/field.dayperiod=\u0434\u0435\u043d -FormatData/bg/field.era=\u0435\u0440\u0430 -FormatData/bg/field.hour=\u0447\u0430\u0441 -FormatData/bg/field.minute=\u043c\u0438\u043d\u0443\u0442\u0430 -FormatData/bg/field.month=\u043c\u0435\u0441\u0435\u0446 -FormatData/bg/field.second=\u0441\u0435\u043a\u0443\u043d\u0434\u0430 -FormatData/bg/field.week=\u0441\u0435\u0434\u043c\u0438\u0446\u0430 -FormatData/bg/field.weekday=\u0414\u0435\u043d \u043e\u0442 \u0441\u0435\u0434\u043c\u0438\u0446\u0430\u0442\u0430 -FormatData/bg/field.year=\u0433\u043e\u0434\u0438\u043d\u0430 -FormatData/bg/field.zone=\u0437\u043e\u043d\u0430 -FormatData/bg/islamic.MonthNames/0=\u043c\u0443\u0445\u0430\u0440\u0430\u043c -FormatData/bg/islamic.MonthNames/1=\u0441\u0430\u0444\u0430\u0440 -FormatData/bg/islamic.MonthNames/2=\u0440\u0430\u0431\u0438-1 -FormatData/bg/islamic.MonthNames/3=\u0440\u0430\u0431\u0438-2 -FormatData/bg/islamic.MonthNames/4=\u0434\u0436\u0443\u043c\u0430\u0434\u0430-1 -FormatData/bg/islamic.MonthNames/5=\u0434\u0436\u0443\u043c\u0430\u0434\u0430-2 -FormatData/bg/islamic.MonthNames/6=\u0440\u0430\u0434\u0436\u0430\u0431 -FormatData/bg/islamic.MonthNames/7=\u0448\u0430\u0431\u0430\u043d -FormatData/bg/islamic.MonthNames/8=\u0440\u0430\u043c\u0430\u0437\u0430\u043d -FormatData/bg/islamic.MonthNames/9=\u0428\u0430\u0432\u0430\u043b -FormatData/bg/islamic.MonthNames/10=\u0414\u0445\u0443\u043b-\u041a\u0430\u0430\u0434\u0430 -FormatData/bg/islamic.MonthNames/11=\u0414\u0445\u0443\u043b-\u0445\u0438\u0434\u0436\u0430 -FormatData/bg/islamic.MonthNames/12= -FormatData/ca/calendarname.buddhist=calendari budista -FormatData/ca/calendarname.gregorian=calendari gregori\u00e0 -FormatData/ca/calendarname.gregory=calendari gregori\u00e0 -FormatData/ca/calendarname.islamic-civil=calendari civil isl\u00e0mic -FormatData/ca/calendarname.islamic=calendari musulm\u00e0 -FormatData/ca/calendarname.islamicc=calendari civil isl\u00e0mic -FormatData/ca/calendarname.japanese=calendari japon\u00e8s -FormatData/ca/calendarname.roc=calendari de la Rep\u00fablica de Xina -FormatData/ca/field.dayperiod=a.m./p.m. -FormatData/ca/field.era=era -FormatData/ca/field.hour=hora -FormatData/ca/field.minute=minut -FormatData/ca/field.month=mes -FormatData/ca/field.second=segon -FormatData/ca/field.week=setmana -FormatData/ca/field.weekday=dia de la setmana -FormatData/ca/field.year=any -FormatData/ca/field.zone=zona -FormatData/cs/calendarname.buddhist=Buddhistick\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.gregorian=Gregori\u00e1nsk\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.gregory=Gregori\u00e1nsk\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.islamic-civil=Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.islamic=Muslimsk\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.islamicc=Muslimsk\u00fd ob\u010dansk\u00fd kalend\u00e1\u0159 -FormatData/cs/calendarname.japanese=Japonsk\u00fd kalend\u00e1\u0159 -FormatData/cs/field.dayperiod=AM/PM -FormatData/cs/field.hour=Hodina -FormatData/cs/field.minute=Minuta -FormatData/cs/field.month=M\u011bs\u00edc -FormatData/cs/field.second=Sekunda -FormatData/cs/field.week=T\u00fdden -FormatData/cs/field.weekday=Den v t\u00fddnu -FormatData/cs/field.year=Rok -FormatData/cs/field.zone=\u010casov\u00e9 p\u00e1smo -FormatData/da/calendarname.buddhist=buddhistisk kalender -FormatData/da/calendarname.gregorian=gregoriansk kalender -FormatData/da/calendarname.gregory=gregoriansk kalender -FormatData/da/calendarname.islamic-civil=verdslig islamisk kalender -FormatData/da/calendarname.islamic=islamisk kalender -FormatData/da/calendarname.islamicc=verdslig islamisk kalender -FormatData/da/calendarname.japanese=japansk kalender -FormatData/da/calendarname.roc=kalender for Republikken Kina -FormatData/da/field.dayperiod=dagtid -FormatData/da/field.era=\u00e6ra -FormatData/da/field.hour=time -FormatData/da/field.minute=minut -FormatData/da/field.month=m\u00e5ned -FormatData/da/field.second=sekund -FormatData/da/field.week=uge -FormatData/da/field.weekday=ugedag -FormatData/da/field.year=\u00e5r -FormatData/da/field.zone=tidszone -FormatData/da/roc.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/da/roc.DatePatterns/1=d. MMMM y GGGG -FormatData/da/roc.DatePatterns/2=d. MMM y GGGG -FormatData/da/roc.DatePatterns/3=d/M/y G -FormatData/da/islamic.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/da/islamic.DatePatterns/1=d. MMMM y GGGG -FormatData/da/islamic.DatePatterns/2=d. MMM y GGGG -FormatData/da/islamic.DatePatterns/3=d/M/y GGGG -FormatData/de/calendarname.buddhist=Buddhistischer Kalender -FormatData/de/calendarname.gregorian=Gregorianischer Kalender -FormatData/de/calendarname.gregory=Gregorianischer Kalender -FormatData/de/calendarname.islamic-civil=B\u00fcrgerlicher islamischer Kalender -FormatData/de/calendarname.islamic=Islamischer Kalender -FormatData/de/calendarname.islamicc=B\u00fcrgerlicher islamischer Kalender -FormatData/de/calendarname.japanese=Japanischer Kalender -FormatData/de/calendarname.roc=Kalender der Republik China -FormatData/de/field.dayperiod=Tagesh\u00e4lfte -FormatData/de/field.era=Epoche -FormatData/de/field.hour=Stunde -FormatData/de/field.minute=Minute -FormatData/de/field.month=Monat -FormatData/de/field.second=Sekunde -FormatData/de/field.week=Woche -FormatData/de/field.weekday=Wochentag -FormatData/de/field.year=Jahr -FormatData/de/field.zone=Zone -FormatData/de/roc.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/de/roc.DatePatterns/1=d. MMMM y GGGG -FormatData/de/roc.DatePatterns/2=d. MMM y GGGG -FormatData/de/roc.DatePatterns/3=d.M.y G -FormatData/de/islamic.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/de/islamic.DatePatterns/1=d. MMMM y GGGG -FormatData/de/islamic.DatePatterns/2=d. MMM y GGGG -FormatData/de/islamic.DatePatterns/3=d.M.y GGGG -FormatData/el/calendarname.buddhist=\u0392\u03bf\u03c5\u03b4\u03b9\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.gregorian=\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.gregory=\u0393\u03c1\u03b7\u03b3\u03bf\u03c1\u03b9\u03b1\u03bd\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.islamic-civil=\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.islamic=\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.islamicc=\u0399\u03c3\u03bb\u03b1\u03bc\u03b9\u03ba\u03cc \u03b1\u03c3\u03c4\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.japanese=\u0399\u03b1\u03c0\u03c9\u03bd\u03b9\u03ba\u03cc \u03b7\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf -FormatData/el/calendarname.roc=\u0397\u03bc\u03b5\u03c1\u03bf\u03bb\u03cc\u03b3\u03b9\u03bf \u03c4\u03b7\u03c2 \u0394\u03b7\u03bc\u03bf\u03ba\u03c1\u03b1\u03c4\u03af\u03b1\u03c2 \u03c4\u03b7\u03c2 \u039a\u03af\u03bd\u03b1\u03c2 -FormatData/el/field.dayperiod=\u03c0.\u03bc./\u03bc.\u03bc. -FormatData/el/field.era=\u03a0\u03b5\u03c1\u03af\u03bf\u03b4\u03bf\u03c2 -FormatData/el/field.hour=\u038f\u03c1\u03b1 -FormatData/el/field.minute=\u039b\u03b5\u03c0\u03c4\u03cc -FormatData/el/field.month=\u039c\u03ae\u03bd\u03b1\u03c2 -FormatData/el/field.second=\u0394\u03b5\u03c5\u03c4\u03b5\u03c1\u03cc\u03bb\u03b5\u03c0\u03c4\u03bf -FormatData/el/field.week=\u0395\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1 -FormatData/el/field.weekday=\u0397\u03bc\u03ad\u03c1\u03b1 \u03b5\u03b2\u03b4\u03bf\u03bc\u03ac\u03b4\u03b1\u03c2 -FormatData/el/field.year=\u0388\u03c4\u03bf\u03c2 -FormatData/el/field.zone=\u0396\u03ce\u03bd\u03b7 -FormatData/el/roc.DatePatterns/0=EEEE, d MMMM, y GGGG -FormatData/el/roc.DatePatterns/1=d MMMM, y GGGG -FormatData/el/roc.DatePatterns/2=d MMM, y GGGG -FormatData/el/roc.DatePatterns/3=d/M/y GGGG -FormatData/es/calendarname.buddhist=calendario budista -FormatData/es/calendarname.gregorian=calendario gregoriano -FormatData/es/calendarname.gregory=calendario gregoriano -FormatData/es/calendarname.islamic-civil=calendario civil isl\u00e1mico -FormatData/es/calendarname.islamic=calendario isl\u00e1mico -FormatData/es/calendarname.islamicc=calendario civil isl\u00e1mico -FormatData/es/calendarname.japanese=calendario japon\u00e9s -FormatData/es/calendarname.roc=calendario de la Rep\u00fablica de China -FormatData/es/field.dayperiod=periodo del d\u00eda -FormatData/es/field.era=era -FormatData/es/field.hour=hora -FormatData/es/field.minute=minuto -FormatData/es/field.month=mes -FormatData/es/field.second=segundo -FormatData/es/field.week=semana -FormatData/es/field.weekday=d\u00eda de la semana -FormatData/es/field.year=a\u00f1o -FormatData/es/field.zone=zona -FormatData/es/roc.DatePatterns/0=EEEE, d 'de' MMMM 'de' y GGGG -FormatData/es/roc.DatePatterns/1=d 'de' MMMM 'de' y GGGG -FormatData/es/roc.DatePatterns/2=dd/MM/y GGGG -FormatData/es/roc.DatePatterns/3=dd/MM/y G -FormatData/es/islamic.DatePatterns/0=EEEE, d 'de' MMMM 'de' y GGGG -FormatData/es/islamic.DatePatterns/1=d 'de' MMMM 'de' y GGGG -FormatData/es/islamic.DatePatterns/2=dd/MM/y GGGG -FormatData/es/islamic.DatePatterns/3=dd/MM/y GGGG -FormatData/et/calendarname.buddhist=budistlik kalender -FormatData/et/calendarname.gregorian=Gregoriuse kalender -FormatData/et/calendarname.gregory=Gregoriuse kalender -FormatData/et/calendarname.islamic-civil=islami ilmalik kalender -FormatData/et/calendarname.islamic=islamikalender -FormatData/et/calendarname.islamicc=islami ilmalik kalender -FormatData/et/calendarname.japanese=Jaapani kalender -FormatData/et/calendarname.roc=Hiina Vabariigi kalender -FormatData/et/field.dayperiod=enne/p\u00e4rast l\u00f5unat -FormatData/et/field.era=ajastu -FormatData/et/field.hour=tund -FormatData/et/field.minute=minut -FormatData/et/field.month=kuu -FormatData/et/field.second=sekund -FormatData/et/field.week=n\u00e4dal -FormatData/et/field.weekday=n\u00e4dalap\u00e4ev -FormatData/et/field.year=aasta -FormatData/et/field.zone=v\u00f6\u00f6nd -FormatData/fi/calendarname.buddhist=buddhalainen kalenteri -FormatData/fi/calendarname.gregorian=gregoriaaninen kalenteri -FormatData/fi/calendarname.gregory=gregoriaaninen kalenteri -FormatData/fi/calendarname.islamic-civil=islamilainen siviilikalenteri -FormatData/fi/calendarname.islamic=islamilainen kalenteri -FormatData/fi/calendarname.islamicc=islamilainen siviilikalenteri -FormatData/fi/calendarname.japanese=japanilainen kalenteri -FormatData/fi/calendarname.roc=Kiinan tasavallan kalenteri -FormatData/fi/field.dayperiod=vuorokaudenaika -FormatData/fi/field.era=aikakausi -FormatData/fi/field.hour=tunti -FormatData/fi/field.minute=minuutti -FormatData/fi/field.month=kuukausi -FormatData/fi/field.second=sekunti -FormatData/fi/field.week=viikko -FormatData/fi/field.weekday=viikonp\u00e4iv\u00e4 -FormatData/fi/field.year=vuosi -FormatData/fi/field.zone=aikavy\u00f6hyke -FormatData/fi/islamic.MonthNames/0=muharram -FormatData/fi/islamic.MonthNames/1=safar -FormatData/fi/islamic.MonthNames/2=rabi\u2019 al-awwal -FormatData/fi/islamic.MonthNames/3=rabi\u2019 al-akhir -FormatData/fi/islamic.MonthNames/4=d\u017eumada-l-ula -FormatData/fi/islamic.MonthNames/5=d\u017eumada-l-akhira -FormatData/fi/islamic.MonthNames/6=rad\u017eab -FormatData/fi/islamic.MonthNames/7=\u0161a\u2019ban -FormatData/fi/islamic.MonthNames/8=ramadan -FormatData/fi/islamic.MonthNames/9=\u0161awwal -FormatData/fi/islamic.MonthNames/10=dhu-l-qa\u2019da -FormatData/fi/islamic.MonthNames/11=dhu-l-hidd\u017ea -FormatData/fi/islamic.MonthNames/12= -FormatData/fi/roc.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/fi/roc.DatePatterns/1=d. MMMM y GGGG -FormatData/fi/roc.DatePatterns/2=d.M.y GGGG -FormatData/fi/roc.DatePatterns/3=d.M.y GGGG -FormatData/fi/islamic.DatePatterns/0=EEEE d. MMMM y GGGG -FormatData/fi/islamic.DatePatterns/1=d. MMMM y GGGG -FormatData/fi/islamic.DatePatterns/2=d.M.y GGGG -FormatData/fi/islamic.DatePatterns/3=d.M.y GGGG -FormatData/fr/calendarname.buddhist=Calendrier bouddhiste -FormatData/fr/calendarname.gregorian=Calendrier gr\u00e9gorien -FormatData/fr/calendarname.gregory=Calendrier gr\u00e9gorien -FormatData/fr/calendarname.islamic-civil=Calendrier civil musulman -FormatData/fr/calendarname.islamic=Calendrier musulman -FormatData/fr/calendarname.islamicc=Calendrier civil musulman -FormatData/fr/calendarname.japanese=Calendrier japonais -FormatData/fr/calendarname.roc=Calendrier r\u00e9publicain chinois -FormatData/fr/field.dayperiod=cadran -FormatData/fr/field.era=\u00e8re -FormatData/fr/field.hour=heure -FormatData/fr/field.minute=minute -FormatData/fr/field.month=mois -FormatData/fr/field.second=seconde -FormatData/fr/field.week=semaine -FormatData/fr/field.weekday=jour de la semaine -FormatData/fr/field.year=ann\u00e9e -FormatData/fr/field.zone=fuseau horaire -FormatData/fr/islamic.MonthNames/0=Mouharram -FormatData/fr/islamic.MonthNames/1=Safar -FormatData/fr/islamic.MonthNames/2=Rabi\u02bb-oul-Aououal -FormatData/fr/islamic.MonthNames/3=Rabi\u02bb-out-Tani -FormatData/fr/islamic.MonthNames/4=Djoumada-l-Oula -FormatData/fr/islamic.MonthNames/5=Djoumada-t-Tania -FormatData/fr/islamic.MonthNames/6=Radjab -FormatData/fr/islamic.MonthNames/7=Cha\u02bbban -FormatData/fr/islamic.MonthNames/8=Ramadan -FormatData/fr/islamic.MonthNames/9=Chaououal -FormatData/fr/islamic.MonthNames/10=Dou-l-Qa\u02bbda -FormatData/fr/islamic.MonthNames/11=Dou-l-Hidjja -FormatData/fr/islamic.MonthNames/12= -FormatData/fr/islamic.MonthAbbreviations/0=Mouh. -FormatData/fr/islamic.MonthAbbreviations/1=Saf. -FormatData/fr/islamic.MonthAbbreviations/2=Rabi\u02bb-oul-A. -FormatData/fr/islamic.MonthAbbreviations/3=Rabi\u02bb-out-T. -FormatData/fr/islamic.MonthAbbreviations/4=Djoum.-l-O. -FormatData/fr/islamic.MonthAbbreviations/5=Djoum.-t-T. -FormatData/fr/islamic.MonthAbbreviations/6=Radj. -FormatData/fr/islamic.MonthAbbreviations/7=Cha. -FormatData/fr/islamic.MonthAbbreviations/8=Ram. -FormatData/fr/islamic.MonthAbbreviations/9=Chaou. -FormatData/fr/islamic.MonthAbbreviations/10=Dou-l-Q. -FormatData/fr/islamic.MonthAbbreviations/11=Dou-l-H. -FormatData/fr/islamic.MonthAbbreviations/12= -FormatData/fr/islamic.Eras/0= -FormatData/fr/islamic.Eras/1=AH -FormatData/fr/roc.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/fr/roc.DatePatterns/1=d MMMM y GGGG -FormatData/fr/roc.DatePatterns/2=d MMM, y GGGG -FormatData/fr/roc.DatePatterns/3=d/M/y G -FormatData/fr/islamic.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/fr/islamic.DatePatterns/1=d MMMM y GGGG -FormatData/fr/islamic.DatePatterns/2=d MMM, y GGGG -FormatData/fr/islamic.DatePatterns/3=d/M/y GGGG -FormatData/hi_IN/calendarname.buddhist=\u092c\u094c\u0926\u094d\u0927 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.gregorian=\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.gregory=\u0917\u094d\u0930\u0947\u0917\u0930\u0940 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.islamic-civil=\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.islamic=\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.islamicc=\u0907\u0938\u094d\u0932\u093e\u092e\u0940 \u0928\u093e\u0917\u0930\u093f\u0915 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.japanese=\u091c\u093e\u092a\u093e\u0928\u0940 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/calendarname.roc=\u091a\u0940\u0928\u0940 \u0917\u0923\u0924\u0902\u0924\u094d\u0930 \u092a\u0902\u091a\u093e\u0902\u0917 -FormatData/hi_IN/field.dayperiod=\u0938\u092e\u092f \u0905\u0935\u0927\u093f -FormatData/hi_IN/field.era=\u092f\u0941\u0917 -FormatData/hi_IN/field.hour=\u0918\u0902\u091f\u093e -FormatData/hi_IN/field.minute=\u092e\u093f\u0928\u091f -FormatData/hi_IN/field.month=\u092e\u093e\u0938 -FormatData/hi_IN/field.second=\u0938\u0947\u0915\u0947\u0902\u0921 -FormatData/hi_IN/field.week=\u0938\u092a\u094d\u0924\u093e\u0939 -FormatData/hi_IN/field.weekday=\u0938\u092a\u094d\u0924\u093e\u0939 \u0915\u093e \u0926\u093f\u0928 -FormatData/hi_IN/field.year=\u0935\u0930\u094d\u0937 -FormatData/hi_IN/field.zone=\u0915\u094d\u0937\u0947\u0924\u094d\u0930 -FormatData/hr/calendarname.buddhist=budisti\u010dki kalendar -FormatData/hr/calendarname.gregorian=gregorijanski kalendar -FormatData/hr/calendarname.gregory=gregorijanski kalendar -FormatData/hr/calendarname.islamic-civil=islamski civilni kalendar -FormatData/hr/calendarname.islamic=islamski kalendar -FormatData/hr/calendarname.islamicc=islamski civilni kalendar -FormatData/hr/calendarname.japanese=japanski kalendar -FormatData/hr/calendarname.roc=kalendar Republike Kine -FormatData/hr/field.dayperiod=dio dana -FormatData/hr/field.era=era -FormatData/hr/field.hour=sat -FormatData/hr/field.minute=minuta -FormatData/hr/field.month=mjesec -FormatData/hr/field.second=sekunda -FormatData/hr/field.week=tjedan -FormatData/hr/field.weekday=dan u tjednu -FormatData/hr/field.year=godina -FormatData/hr/field.zone=zona -FormatData/hr/roc.DatePatterns/0=EEEE, d. MMMM y. GGGG -FormatData/hr/roc.DatePatterns/1=d. MMMM y. GGGG -FormatData/hr/roc.DatePatterns/2=d. M. y. GGGG -FormatData/hr/roc.DatePatterns/3=d.M.y. GGGG -FormatData/hu/calendarname.buddhist=buddhista napt\u00e1r -FormatData/hu/calendarname.gregorian=Gergely-napt\u00e1r -FormatData/hu/calendarname.gregory=Gergely-napt\u00e1r -FormatData/hu/calendarname.islamic-civil=iszl\u00e1m civil napt\u00e1r -FormatData/hu/calendarname.islamic=iszl\u00e1m napt\u00e1r -FormatData/hu/calendarname.islamicc=iszl\u00e1m civil napt\u00e1r -FormatData/hu/calendarname.japanese=jap\u00e1n napt\u00e1r -FormatData/hu/calendarname.roc=K\u00ednai k\u00f6zt\u00e1rsas\u00e1gi napt\u00e1r -FormatData/hu/field.dayperiod=napszak -FormatData/hu/field.era=\u00e9ra -FormatData/hu/field.hour=\u00f3ra -FormatData/hu/field.minute=perc -FormatData/hu/field.month=h\u00f3nap -FormatData/hu/field.second=m\u00e1sodperc -FormatData/hu/field.week=h\u00e9t -FormatData/hu/field.weekday=h\u00e9t napja -FormatData/hu/field.year=\u00e9v -FormatData/hu/field.zone=z\u00f3na -FormatData/hu/islamic.MonthNames/0=Moharrem -FormatData/hu/islamic.MonthNames/1=Safar -FormatData/hu/islamic.MonthNames/2=R\u00e9bi el avvel -FormatData/hu/islamic.MonthNames/3=R\u00e9bi el accher -FormatData/hu/islamic.MonthNames/4=Dsem\u00e1di el avvel -FormatData/hu/islamic.MonthNames/5=Dsem\u00e1di el accher -FormatData/hu/islamic.MonthNames/6=Redseb -FormatData/hu/islamic.MonthNames/7=Sab\u00e1n -FormatData/hu/islamic.MonthNames/8=Ramad\u00e1n -FormatData/hu/islamic.MonthNames/9=Sevv\u00e1l -FormatData/hu/islamic.MonthNames/10=Ds\u00fcl kade -FormatData/hu/islamic.MonthNames/11=Ds\u00fcl hedse -FormatData/hu/islamic.MonthNames/12= -FormatData/hu/islamic.Eras/0= -FormatData/hu/islamic.Eras/1=MF -FormatData/is/calendarname.buddhist=B\u00fadd\u00edskt dagatal -FormatData/is/calendarname.gregorian=Gregor\u00edskt dagatal -FormatData/is/calendarname.gregory=Gregor\u00edskt dagatal -FormatData/is/calendarname.islamic-civil=\u00cdslamskt borgaradagatal -FormatData/is/calendarname.islamic=\u00cdslamskt dagatal -FormatData/is/calendarname.islamicc=\u00cdslamskt borgaradagatal -FormatData/is/calendarname.japanese=Japanskt dagatal -FormatData/it/calendarname.buddhist=calendario buddista -FormatData/it/calendarname.gregorian=calendario gregoriano -FormatData/it/calendarname.gregory=calendario gregoriano -FormatData/it/calendarname.islamic-civil=calendario civile islamico -FormatData/it/calendarname.islamic=calendario islamico -FormatData/it/calendarname.islamicc=calendario civile islamico -FormatData/it/calendarname.japanese=calendario giapponese -FormatData/it/field.dayperiod=periodo del giorno -FormatData/it/field.era=era -FormatData/it/field.hour=ora -FormatData/it/field.minute=minuto -FormatData/it/field.month=mese -FormatData/it/field.second=secondo -FormatData/it/field.week=settimana -FormatData/it/field.weekday=giorno della settimana -FormatData/it/field.year=anno -FormatData/it/field.zone=zona -FormatData/it/roc.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/it/roc.DatePatterns/1=dd MMMM y GGGG -FormatData/it/roc.DatePatterns/2=dd/MMM/y GGGG -FormatData/it/roc.DatePatterns/3=dd/MM/y GGGG -FormatData/it/islamic.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/it/islamic.DatePatterns/1=dd MMMM y GGGG -FormatData/it/islamic.DatePatterns/2=dd/MMM/y GGGG -FormatData/it/islamic.DatePatterns/3=dd/MM/y GGGG -FormatData/iw/calendarname.buddhist=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d1\u05d5\u05d3\u05d4\u05d9\u05e1\u05d8\u05d9 -FormatData/iw/calendarname.gregorian=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9 -FormatData/iw/calendarname.gregory=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d2\u05e8\u05d2\u05d5\u05e8\u05d9\u05d0\u05e0\u05d9 -FormatData/iw/calendarname.islamic-civil=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9 -FormatData/iw/calendarname.islamic=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9 -FormatData/iw/calendarname.islamicc=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05de\u05d5\u05e1\u05dc\u05de\u05d9-\u05d0\u05d6\u05e8\u05d7\u05d9 -FormatData/iw/calendarname.japanese=\u05dc\u05d5\u05d7 \u05e9\u05e0\u05d4 \u05d9\u05e4\u05e0\u05d9 -FormatData/iw/field.dayperiod=\u05dc\u05e4\u05d4\u05f4\u05e6/\u05d0\u05d7\u05d4\u05f4\u05e6 -FormatData/iw/field.era=\u05ea\u05e7\u05d5\u05e4\u05d4 -FormatData/iw/field.hour=\u05e9\u05e2\u05d4 -FormatData/iw/field.minute=\u05d3\u05e7\u05d4 -FormatData/iw/field.month=\u05d7\u05d5\u05d3\u05e9 -FormatData/iw/field.second=\u05e9\u05e0\u05d9\u05d9\u05d4 -FormatData/iw/field.week=\u05e9\u05d1\u05d5\u05e2 -FormatData/iw/field.weekday=\u05d9\u05d5\u05dd \u05d1\u05e9\u05d1\u05d5\u05e2 -FormatData/iw/field.year=\u05e9\u05e0\u05d4 -FormatData/iw/field.zone=\u05d0\u05d6\u05d5\u05e8 -FormatData/iw/islamic.MonthNames/0=\u05de\u05d5\u05d7\u05e8\u05dd -FormatData/iw/islamic.MonthNames/1=\u05e1\u05e4\u05e8 -FormatData/iw/islamic.MonthNames/2=\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc -FormatData/iw/islamic.MonthNames/3=\u05e8\u05d1\u05d9\u05e2 \u05d0\u05dc-\u05ea\u05e0\u05d9 -FormatData/iw/islamic.MonthNames/4=\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05d0\u05d5\u05d5\u05d0\u05dc -FormatData/iw/islamic.MonthNames/5=\u05d2\u05f3\u05d5\u05de\u05d3\u05d4 \u05d0\u05dc-\u05ea\u05e0\u05d9 -FormatData/iw/islamic.MonthNames/6=\u05e8\u05d2\u05f3\u05d0\u05d1 -FormatData/iw/islamic.MonthNames/7=\u05e9\u05e2\u05d1\u05d0\u05df -FormatData/iw/islamic.MonthNames/8=\u05e8\u05d0\u05de\u05d3\u05df -FormatData/iw/islamic.MonthNames/9=\u05e9\u05d5\u05d5\u05d0\u05dc -FormatData/iw/islamic.MonthNames/10=\u05d6\u05d5 \u05d0\u05dc-QI'DAH -FormatData/iw/islamic.MonthNames/11=\u05d6\u05d5 \u05d0\u05dc-\u05d7\u05d9\u05d2\u05f3\u05d4 -FormatData/iw/islamic.MonthNames/12= -FormatData/iw/islamic.Eras/0= -FormatData/iw/islamic.Eras/1=\u05e9\u05e0\u05ea \u05d4\u05d9\u05d2\u05f3\u05e8\u05d4 -FormatData/ja/calendarname.buddhist=\u30bf\u30a4\u4ecf\u6559\u66a6 -FormatData/ja/calendarname.gregorian=\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6] -FormatData/ja/calendarname.gregory=\u897f\u66a6[\u30b0\u30ec\u30b4\u30ea\u30aa\u66a6] -FormatData/ja/calendarname.islamic-civil=\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6 -FormatData/ja/calendarname.islamic=\u30a4\u30b9\u30e9\u30e0\u66a6 -FormatData/ja/calendarname.islamicc=\u592a\u967d\u30a4\u30b9\u30e9\u30e0\u66a6 -FormatData/ja/calendarname.japanese=\u548c\u66a6 -FormatData/ja/calendarname.roc=\u4e2d\u83ef\u6c11\u56fd\u66a6 -FormatData/ja/field.dayperiod=\u5348\u524d/\u5348\u5f8c -FormatData/ja/field.era=\u6642\u4ee3 -FormatData/ja/field.hour=\u6642 -FormatData/ja/field.minute=\u5206 -FormatData/ja/field.month=\u6708 -FormatData/ja/field.second=\u79d2 -FormatData/ja/field.week=\u9031 -FormatData/ja/field.weekday=\u66dc\u65e5 -FormatData/ja/field.year=\u5e74 -FormatData/ja/field.zone=\u30bf\u30a4\u30e0\u30be\u30fc\u30f3 -FormatData/ja/roc.DatePatterns/0=GGGGy\u5e74M\u6708d\u65e5EEEE -FormatData/ja/roc.DatePatterns/1=GGGGy\u5e74M\u6708d\u65e5 -FormatData/ja/roc.DatePatterns/2=GGGGy/MM/dd -FormatData/ja/roc.DatePatterns/3=GGGGy/MM/dd -FormatData/ko/calendarname.buddhist=\ubd88\uad50\ub825 -FormatData/ko/calendarname.gregorian=\ud0dc\uc591\ub825 -FormatData/ko/calendarname.gregory=\ud0dc\uc591\ub825 -FormatData/ko/calendarname.islamic-civil=\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825 -FormatData/ko/calendarname.islamic=\uc774\uc2ac\ub78c\ub825 -FormatData/ko/calendarname.islamicc=\uc774\uc2ac\ub78c \uc0c1\uc6a9\ub825 -FormatData/ko/calendarname.japanese=\uc77c\ubcf8\ub825 -FormatData/ko/calendarname.roc=\ub300\ub9cc\ub825 -FormatData/ko/field.dayperiod=\uc624\uc804/\uc624\ud6c4 -FormatData/ko/field.era=\uc5f0\ud638 -FormatData/ko/field.hour=\uc2dc -FormatData/ko/field.minute=\ubd84 -FormatData/ko/field.month=\uc6d4 -FormatData/ko/field.second=\ucd08 -FormatData/ko/field.week=\uc8fc -FormatData/ko/field.weekday=\uc694\uc77c -FormatData/ko/field.year=\ub144 -FormatData/ko/field.zone=\uc2dc\uac04\ub300 -FormatData/ko/roc.DatePatterns/0=GGGG y\ub144 M\uc6d4 d\uc77c EEEE -FormatData/ko/roc.DatePatterns/1=GGGG y\ub144 M\uc6d4 d\uc77c -FormatData/ko/roc.DatePatterns/2=GGGG y. M. d -FormatData/ko/roc.DatePatterns/3=GGGG y. M. d -FormatData/lt/calendarname.buddhist=Budist\u0173 kalendorius -FormatData/lt/calendarname.gregorian=Grigaliaus kalendorius -FormatData/lt/calendarname.gregory=Grigaliaus kalendorius -FormatData/lt/calendarname.islamic-civil=Pilietinis islamo kalendorius -FormatData/lt/calendarname.islamic=Islamo kalendorius -FormatData/lt/calendarname.islamicc=Pilietinis islamo kalendorius -FormatData/lt/calendarname.japanese=Japon\u0173 kalendorius -FormatData/lt/calendarname.roc=Kinijos Respublikos kalendorius -FormatData/lt/field.dayperiod=dienos metas -FormatData/lt/field.era=era -FormatData/lt/field.hour=valanda -FormatData/lt/field.minute=minut\u0117 -FormatData/lt/field.month=m\u0117nuo -FormatData/lt/field.second=sekund\u0117 -FormatData/lt/field.week=savait\u0117 -FormatData/lt/field.weekday=savait\u0117s diena -FormatData/lt/field.year=metai -FormatData/lt/field.zone=laiko juosta -FormatData/lv/calendarname.buddhist=budistu kalend\u0101rs -FormatData/lv/calendarname.gregorian=Gregora kalend\u0101rs -FormatData/lv/calendarname.gregory=Gregora kalend\u0101rs -FormatData/lv/calendarname.islamic-civil=isl\u0101ma pilso\u0146u kalend\u0101rs -FormatData/lv/calendarname.islamic=isl\u0101ma kalend\u0101rs -FormatData/lv/calendarname.islamicc=isl\u0101ma pilso\u0146u kalend\u0101rs -FormatData/lv/calendarname.japanese=jap\u0101\u0146u kalend\u0101rs -FormatData/lv/calendarname.roc=\u0136\u012bnas Republikas kalend\u0101rs -FormatData/lv/field.dayperiod=Dayperiod -FormatData/lv/field.era=\u0113ra -FormatData/lv/field.hour=Stundas -FormatData/lv/field.minute=Min\u016btes -FormatData/lv/field.month=M\u0113nesis -FormatData/lv/field.second=Sekundes -FormatData/lv/field.week=Ned\u0113\u013ca -FormatData/lv/field.weekday=Ned\u0113\u013cas diena -FormatData/lv/field.year=Gads -FormatData/lv/field.zone=Josla -FormatData/lv/islamic.MonthNames/0=muharams -FormatData/lv/islamic.MonthNames/1=safars -FormatData/lv/islamic.MonthNames/2=1. rab\u012b -FormatData/lv/islamic.MonthNames/3=2. rab\u012b -FormatData/lv/islamic.MonthNames/4=1. d\u017eum\u0101d\u0101 -FormatData/lv/islamic.MonthNames/5=2. d\u017eum\u0101d\u0101 -FormatData/lv/islamic.MonthNames/6=rad\u017eabs -FormatData/lv/islamic.MonthNames/7=\u0161abans -FormatData/lv/islamic.MonthNames/8=ramad\u0101ns -FormatData/lv/islamic.MonthNames/9=\u0161auvals -FormatData/lv/islamic.MonthNames/10=du al-kid\u0101 -FormatData/lv/islamic.MonthNames/11=du al-hid\u017e\u0101 -FormatData/lv/islamic.MonthNames/12= -FormatData/mk/calendarname.buddhist=\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.gregorian=\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.gregory=\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.islamic-civil=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.islamic=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.islamicc=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0433\u0440\u0430\u0453\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.japanese=\u0408\u0430\u043f\u043e\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/mk/calendarname.roc=\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u043d\u0430 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0430 \u041a\u0438\u043d\u0430 -FormatData/mk/field.dayperiod=\u043f\u0440\u0435\u0442\u043f\u043b\u0430\u0434\u043d\u0435/\u043f\u043e\u043f\u043b\u0430\u0434\u043d\u0435 -FormatData/mk/field.era=\u0415\u0440\u0430 -FormatData/mk/field.hour=\u0427\u0430\u0441 -FormatData/mk/field.minute=\u041c\u0438\u043d\u0443\u0442\u0430 -FormatData/mk/field.month=\u041c\u0435\u0441\u0435\u0446 -FormatData/mk/field.second=\u0421\u0435\u043a\u0443\u043d\u0434\u0430 -FormatData/mk/field.week=\u041d\u0435\u0434\u0435\u043b\u0430 -FormatData/mk/field.weekday=\u0414\u0435\u043d \u0432\u043e \u043d\u0435\u0434\u0435\u043b\u0430\u0442\u0430 -FormatData/mk/field.year=\u0433\u043e\u0434\u0438\u043d\u0430 -FormatData/mk/field.zone=\u0437\u043e\u043d\u0430 -FormatData/ms/calendarname.buddhist=Kalendar Buddha -FormatData/ms/calendarname.gregorian=Kalendar Gregory -FormatData/ms/calendarname.gregory=Kalendar Gregory -FormatData/ms/calendarname.islamic-civil=Kalendar Sivil Islam -FormatData/ms/calendarname.islamic=Kalendar Islam -FormatData/ms/calendarname.islamicc=Kalendar Sivil Islam -FormatData/ms/calendarname.japanese=Kalendar Jepun -FormatData/ms/calendarname.roc=Kalendar Minguo -FormatData/ms/field.dayperiod=PG/PTG -FormatData/ms/field.hour=Jam -FormatData/ms/field.minute=Minit -FormatData/ms/field.month=Bulan -FormatData/ms/field.second=Kedua -FormatData/ms/field.week=Minggu -FormatData/ms/field.weekday=Hari dalam Minggu -FormatData/ms/field.year=Tahun -FormatData/ms/field.zone=Zon Waktu -FormatData/ms/roc.DatePatterns/0=EEEE, d MMMM y GGGG -FormatData/ms/roc.DatePatterns/1=d MMMM y GGGG -FormatData/ms/roc.DatePatterns/2=dd/MM/y GGGG -FormatData/ms/roc.DatePatterns/3=d/MM/y GGGG -FormatData/ms/islamic.DatePatterns/0=EEEE, d MMMM y GGGG -FormatData/ms/islamic.DatePatterns/1=d MMMM y GGGG -FormatData/ms/islamic.DatePatterns/2=dd/MM/y GGGG -FormatData/ms/islamic.DatePatterns/3=d/MM/y GGGG -FormatData/mt/calendarname.buddhist=Kalendarju Buddist -FormatData/mt/calendarname.gregorian=Kalendarju Gregorjan -FormatData/mt/calendarname.gregory=Kalendarju Gregorjan -FormatData/mt/calendarname.islamic-civil=Kalendarju Islamiku-\u010aivili -FormatData/mt/calendarname.islamic=Kalendarju Islamiku -FormatData/mt/calendarname.islamicc=Kalendarju Islamiku-\u010aivili -FormatData/mt/calendarname.japanese=Kalendarju \u0120appuni\u017c -FormatData/mt/field.era=Epoka -FormatData/mt/field.hour=Sieg\u0127a -FormatData/mt/field.minute=Minuta -FormatData/mt/field.month=Xahar -FormatData/mt/field.second=Sekonda -FormatData/mt/field.week=\u0120img\u0127a -FormatData/mt/field.weekday=Jum tal-\u0120img\u0127a -FormatData/mt/field.year=Sena -FormatData/mt/field.zone=\u017bona -FormatData/nl/calendarname.buddhist=Boeddhistische kalender -FormatData/nl/calendarname.gregorian=Gregoriaanse kalender -FormatData/nl/calendarname.gregory=Gregoriaanse kalender -FormatData/nl/calendarname.islamic-civil=Islamitische kalender (cyclisch) -FormatData/nl/calendarname.islamic=Islamitische kalender -FormatData/nl/calendarname.islamicc=Islamitische kalender (cyclisch) -FormatData/nl/calendarname.japanese=Japanse kalender -FormatData/nl/calendarname.roc=Kalender van de Chinese Republiek -FormatData/nl/field.dayperiod=AM/PM -FormatData/nl/field.era=Tijdperk -FormatData/nl/field.hour=Uur -FormatData/nl/field.minute=Minuut -FormatData/nl/field.month=Maand -FormatData/nl/field.second=Seconde -FormatData/nl/field.weekday=Dag van de week -FormatData/nl/field.year=Jaar -FormatData/nl/field.zone=Zone -FormatData/nl/islamic.MonthNames/0=Moeharram -FormatData/nl/islamic.MonthNames/1=Safar -FormatData/nl/islamic.MonthNames/2=Rabi\u02bba al awal -FormatData/nl/islamic.MonthNames/3=Rabi\u02bba al thani -FormatData/nl/islamic.MonthNames/4=Joemad\u02bbal awal -FormatData/nl/islamic.MonthNames/5=Joemad\u02bbal thani -FormatData/nl/islamic.MonthNames/6=Rajab -FormatData/nl/islamic.MonthNames/7=Sja\u02bbaban -FormatData/nl/islamic.MonthNames/8=Ramadan -FormatData/nl/islamic.MonthNames/9=Sjawal -FormatData/nl/islamic.MonthNames/10=Doe al ka\u02bbaba -FormatData/nl/islamic.MonthNames/11=Doe al hizja -FormatData/nl/islamic.MonthNames/12= -FormatData/nl/islamic.MonthAbbreviations/0=Moeh. -FormatData/nl/islamic.MonthAbbreviations/1=Saf. -FormatData/nl/islamic.MonthAbbreviations/2=Rab. I -FormatData/nl/islamic.MonthAbbreviations/3=Rab. II -FormatData/nl/islamic.MonthAbbreviations/4=Joem. I -FormatData/nl/islamic.MonthAbbreviations/5=Joem. II -FormatData/nl/islamic.MonthAbbreviations/6=Raj. -FormatData/nl/islamic.MonthAbbreviations/7=Sja. -FormatData/nl/islamic.MonthAbbreviations/8=Ram. -FormatData/nl/islamic.MonthAbbreviations/9=Sjaw. -FormatData/nl/islamic.MonthAbbreviations/10=Doe al k. -FormatData/nl/islamic.MonthAbbreviations/11=Doe al h. -FormatData/nl/islamic.MonthAbbreviations/12= -FormatData/nl/islamic.Eras/0= -FormatData/nl/islamic.Eras/1=Sa\u02bbna Hizjria -FormatData/nl/roc.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/nl/roc.DatePatterns/1=d MMMM y GGGG -FormatData/nl/roc.DatePatterns/2=d MMM y GGGG -FormatData/nl/roc.DatePatterns/3=dd-MM-yy G -FormatData/nl/islamic.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/nl/islamic.DatePatterns/1=d MMMM y GGGG -FormatData/nl/islamic.DatePatterns/2=d MMM y GGGG -FormatData/nl/islamic.DatePatterns/3=dd-MM-yy GGGG -FormatData/pl/calendarname.buddhist=kalendarz buddyjski -FormatData/pl/calendarname.gregorian=kalendarz gregoria\u0144ski -FormatData/pl/calendarname.gregory=kalendarz gregoria\u0144ski -FormatData/pl/calendarname.islamic-civil=kalendarz islamski (metoda obliczeniowa) -FormatData/pl/calendarname.islamic=kalendarz islamski (metoda wzrokowa) -FormatData/pl/calendarname.islamicc=kalendarz islamski (metoda obliczeniowa) -FormatData/pl/calendarname.japanese=kalendarz japo\u0144ski -FormatData/pl/calendarname.roc=kalendarz Republiki Chi\u0144skiej -FormatData/pl/field.era=Era -FormatData/pl/field.hour=Godzina -FormatData/pl/field.minute=Minuta -FormatData/pl/field.month=Miesi\u0105c -FormatData/pl/field.second=Sekunda -FormatData/pl/field.week=Tydzie\u0144 -FormatData/pl/field.weekday=Dzie\u0144 tygodnia -FormatData/pl/field.year=Rok -FormatData/pl/field.zone=Strefa -FormatData/pl/roc.DatePatterns/0=EEEE, d MMMM, y GGGG -FormatData/pl/roc.DatePatterns/1=d MMMM, y GGGG -FormatData/pl/roc.DatePatterns/2=d MMM y GGGG -FormatData/pl/roc.DatePatterns/3=dd.MM.yyyy GGGG -FormatData/pl/islamic.DatePatterns/0=EEEE, d MMMM, y GGGG -FormatData/pl/islamic.DatePatterns/1=d MMMM, y GGGG -FormatData/pl/islamic.DatePatterns/2=d MMM y GGGG -FormatData/pl/islamic.DatePatterns/3=dd.MM.yyyy GGGG -FormatData/pt/calendarname.buddhist=Calend\u00e1rio Budista -FormatData/pt/calendarname.gregorian=Calend\u00e1rio Gregoriano -FormatData/pt/calendarname.gregory=Calend\u00e1rio Gregoriano -FormatData/pt/calendarname.islamic-civil=Calend\u00e1rio Civil Isl\u00e2mico -FormatData/pt/calendarname.islamic=Calend\u00e1rio Isl\u00e2mico -FormatData/pt/calendarname.islamicc=Calend\u00e1rio Civil Isl\u00e2mico -FormatData/pt/calendarname.japanese=Calend\u00e1rio Japon\u00eas -FormatData/pt/calendarname.roc=Calend\u00e1rio da Rep\u00fablica da China -FormatData/pt/field.dayperiod=Per\u00edodo do dia -FormatData/pt/field.era=Era -FormatData/pt/field.hour=Hora -FormatData/pt/field.minute=Minuto -FormatData/pt/field.month=M\u00eas -FormatData/pt/field.second=Segundo -FormatData/pt/field.week=Semana -FormatData/pt/field.weekday=Dia da semana -FormatData/pt/field.year=Ano -FormatData/pt/field.zone=Fuso -FormatData/pt/roc.DatePatterns/0=EEEE, d 'de' MMMM 'de' y GGGG -FormatData/pt/roc.DatePatterns/1=d 'de' MMMM 'de' y GGGG -FormatData/pt/roc.DatePatterns/2=dd/MM/yyyy GGGG -FormatData/pt/roc.DatePatterns/3=d/M/yyyy -FormatData/pt/islamic.DatePatterns/0=EEEE, d 'de' MMMM 'de' y GGGG -FormatData/pt/islamic.DatePatterns/1=d 'de' MMMM 'de' y GGGG -FormatData/pt/islamic.DatePatterns/2=dd/MM/yyyy GGGG -FormatData/pt/islamic.DatePatterns/3=d/M/yyyy -FormatData/ro/calendarname.buddhist=calendar budist -FormatData/ro/calendarname.gregorian=calendar gregorian -FormatData/ro/calendarname.gregory=calendar gregorian -FormatData/ro/calendarname.islamic-civil=calendar islamic civil -FormatData/ro/calendarname.islamic=calendar islamic -FormatData/ro/calendarname.islamicc=calendar islamic civil -FormatData/ro/calendarname.japanese=calendar japonez -FormatData/ro/calendarname.roc=calendar al Republicii Chineze -FormatData/ro/field.dayperiod=perioada zilei -FormatData/ro/field.era=er\u0103 -FormatData/ro/field.hour=or\u0103 -FormatData/ro/field.minute=minut -FormatData/ro/field.month=lun\u0103 -FormatData/ro/field.second=secund\u0103 -FormatData/ro/field.week=s\u0103pt\u0103m\u00e2n\u0103 -FormatData/ro/field.weekday=zi a s\u0103pt\u0103m\u00e2nii -FormatData/ro/field.year=an -FormatData/ro/field.zone=zon\u0103 -FormatData/ru/calendarname.buddhist=\u0411\u0443\u0434\u0434\u0438\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.gregorian=\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.gregory=\u0413\u0440\u0438\u0433\u043e\u0440\u0438\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.islamic-civil=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.islamic=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.islamicc=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438\u0439 \u0433\u0440\u0430\u0436\u0434\u0430\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.japanese=\u042f\u043f\u043e\u043d\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/calendarname.roc=\u041a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u044c -FormatData/ru/field.era=\u042d\u0440\u0430 -FormatData/ru/field.hour=\u0427\u0430\u0441 -FormatData/ru/field.minute=\u041c\u0438\u043d\u0443\u0442\u0430 -FormatData/ru/field.month=\u041c\u0435\u0441\u044f\u0446 -FormatData/ru/field.second=\u0421\u0435\u043a\u0443\u043d\u0434\u0430 -FormatData/ru/field.week=\u041d\u0435\u0434\u0435\u043b\u044f -FormatData/ru/field.weekday=\u0414\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438 -FormatData/ru/field.year=\u0413\u043e\u0434 -FormatData/ru/field.zone=\u0427\u0430\u0441\u043e\u0432\u043e\u0439 \u043f\u043e\u044f\u0441 -FormatData/ru/islamic.MonthNames/0=\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c -FormatData/ru/islamic.MonthNames/1=\u0421\u0430\u0444\u0430\u0440 -FormatData/ru/islamic.MonthNames/2=\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c -FormatData/ru/islamic.MonthNames/3=\u0420\u0430\u0431\u0438-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440 -FormatData/ru/islamic.MonthNames/4=\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0432\u0432\u0430\u043b\u044c -FormatData/ru/islamic.MonthNames/5=\u0414\u0436\u0443\u043c\u0430\u0434-\u0443\u043b\u044c-\u0430\u0445\u0438\u0440 -FormatData/ru/islamic.MonthNames/6=\u0420\u0430\u0434\u0436\u0430\u0431 -FormatData/ru/islamic.MonthNames/7=\u0428\u0430\u0430\u0431\u0430\u043d -FormatData/ru/islamic.MonthNames/8=\u0420\u0430\u043c\u0430\u0434\u0430\u043d -FormatData/ru/islamic.MonthNames/9=\u0428\u0430\u0432\u0432\u0430\u043b\u044c -FormatData/ru/islamic.MonthNames/10=\u0417\u0443\u043b\u044c-\u041a\u0430\u0430\u0434\u0430 -FormatData/ru/islamic.MonthNames/11=\u0417\u0443\u043b\u044c-\u0425\u0438\u0434\u0436\u0436\u0430 -FormatData/ru/islamic.MonthNames/12= -FormatData/ru/roc.DatePatterns/0=EEEE, d MMMM y\u00a0'\u0433'. GGGG -FormatData/ru/roc.DatePatterns/1=d MMMM y\u00a0'\u0433'. GGGG -FormatData/ru/roc.DatePatterns/2=dd.MM.yyyy GGGG -FormatData/ru/roc.DatePatterns/3=dd.MM.yy GGGG -FormatData/ru/islamic.DatePatterns/0=EEEE, d MMMM y\u00a0'\u0433'. GGGG -FormatData/ru/islamic.DatePatterns/1=d MMMM y\u00a0'\u0433'. GGGG -FormatData/ru/islamic.DatePatterns/2=dd.MM.yyyy GGGG -FormatData/ru/islamic.DatePatterns/3=dd.MM.yy GGGG -FormatData/sk/calendarname.buddhist=Buddhistick\u00fd kalend\u00e1r -FormatData/sk/calendarname.gregorian=Gregori\u00e1nsky kalend\u00e1r -FormatData/sk/calendarname.gregory=Gregori\u00e1nsky kalend\u00e1r -FormatData/sk/calendarname.islamic-civil=Islamsk\u00fd ob\u010diansky kalend\u00e1r -FormatData/sk/calendarname.islamic=Islamsk\u00fd kalend\u00e1r -FormatData/sk/calendarname.islamicc=Islamsk\u00fd ob\u010diansky kalend\u00e1r -FormatData/sk/calendarname.japanese=Japonsk\u00fd kalend\u00e1r -FormatData/sk/field.dayperiod=\u010cas\u0165 d\u0148a -FormatData/sk/field.era=\u00c9ra -FormatData/sk/field.hour=Hodina -FormatData/sk/field.minute=Min\u00fata -FormatData/sk/field.month=Mesiac -FormatData/sk/field.second=Sekunda -FormatData/sk/field.week=T\u00fd\u017ede\u0148 -FormatData/sk/field.weekday=De\u0148 v t\u00fd\u017edni -FormatData/sk/field.year=Rok -FormatData/sk/field.zone=P\u00e1smo -FormatData/sl/calendarname.buddhist=budisti\u010dni koledar -FormatData/sl/calendarname.gregorian=gregorijanski koledar -FormatData/sl/calendarname.gregory=gregorijanski koledar -FormatData/sl/calendarname.islamic-civil=islamski civilni koledar -FormatData/sl/calendarname.islamic=islamski koledar -FormatData/sl/calendarname.islamicc=islamski civilni koledar -FormatData/sl/calendarname.japanese=japonski koledar -FormatData/sl/calendarname.roc=kitajski dr\u017eavni koledar -FormatData/sl/field.dayperiod=\u010cas dneva -FormatData/sl/field.era=Doba -FormatData/sl/field.hour=Ura -FormatData/sl/field.minute=Minuta -FormatData/sl/field.month=Mesec -FormatData/sl/field.second=Sekunda -FormatData/sl/field.week=Teden -FormatData/sl/field.weekday=Dan v tednu -FormatData/sl/field.year=Leto -FormatData/sl/field.zone=Obmo\u010dje -FormatData/sr/calendarname.buddhist=\u0411\u0443\u0434\u0438\u0441\u0442\u0438\u0447\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.gregorian=\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.gregory=\u0413\u0440\u0435\u0433\u043e\u0440\u0438\u0458\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.islamic-civil=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.islamic=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.islamicc=\u0418\u0441\u043b\u0430\u043c\u0441\u043a\u0438 \u0446\u0438\u0432\u0438\u043b\u043d\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.japanese=\u0408\u0430\u043f\u0430\u043d\u0441\u043a\u0438 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/sr/calendarname.roc=\u041a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 \u0420\u0435\u043f\u0443\u0431\u043b\u0438\u043a\u0435 \u041a\u0438\u043d\u0435 -FormatData/sr/field.dayperiod=\u043f\u0440\u0435 \u043f\u043e\u0434\u043d\u0435/\u043f\u043e\u043f\u043e\u0434\u043d\u0435 -FormatData/sr/field.era=\u0435\u0440\u0430 -FormatData/sr/field.hour=\u0447\u0430\u0441 -FormatData/sr/field.minute=\u043c\u0438\u043d\u0443\u0442 -FormatData/sr/field.month=\u043c\u0435\u0441\u0435\u0446 -FormatData/sr/field.second=\u0441\u0435\u043a\u0443\u043d\u0434 -FormatData/sr/field.week=\u043d\u0435\u0434\u0435\u0459\u0430 -FormatData/sr/field.weekday=\u0434\u0430\u043d \u0443 \u043d\u0435\u0434\u0435\u0459\u0438 -FormatData/sr/field.year=\u0433\u043e\u0434\u0438\u043d\u0430 -FormatData/sr/field.zone=\u0437\u043e\u043d\u0430 -FormatData/sr/islamic.MonthNames/0=\u041c\u0443\u0440\u0430\u0445\u0430\u043c -FormatData/sr/islamic.MonthNames/1=\u0421\u0430\u0444\u0430\u0440 -FormatData/sr/islamic.MonthNames/2=\u0420\u0430\u0431\u0438\u02bb I -FormatData/sr/islamic.MonthNames/3=\u0420\u0430\u0431\u0438\u02bb II -FormatData/sr/islamic.MonthNames/4=\u0408\u0443\u043c\u0430\u0434\u0430 I -FormatData/sr/islamic.MonthNames/5=\u0408\u0443\u043c\u0430\u0434\u0430 II -FormatData/sr/islamic.MonthNames/6=\u0420\u0430\u0452\u0430\u0431 -FormatData/sr/islamic.MonthNames/7=\u0428\u0430\u02bb\u0431\u0430\u043d -FormatData/sr/islamic.MonthNames/8=\u0420\u0430\u043c\u0430\u0434\u0430\u043d -FormatData/sr/islamic.MonthNames/9=\u0428\u0430\u0432\u0430\u043b -FormatData/sr/islamic.MonthNames/10=\u0414\u0443\u02bb\u043b-\u041a\u0438\u02bb\u0434\u0430 -FormatData/sr/islamic.MonthNames/11=\u0414\u0443\u02bb\u043b-\u0445\u0438\u0452\u0430 -FormatData/sr/islamic.MonthNames/12= -FormatData/sr/islamic.Eras/0= -FormatData/sr/islamic.Eras/1=\u0410\u0425 -FormatData/sv/calendarname.buddhist=buddistisk kalender -FormatData/sv/calendarname.gregorian=gregoriansk kalender -FormatData/sv/calendarname.gregory=gregoriansk kalender -FormatData/sv/calendarname.islamic-civil=islamisk civil kalender -FormatData/sv/calendarname.islamic=islamisk kalender -FormatData/sv/calendarname.islamicc=islamisk civil kalender -FormatData/sv/calendarname.japanese=japansk kalender -FormatData/sv/calendarname.roc=kinesiska republikens kalender -FormatData/sv/field.dayperiod=fm/em -FormatData/sv/field.era=era -FormatData/sv/field.hour=timme -FormatData/sv/field.minute=minut -FormatData/sv/field.month=m\u00e5nad -FormatData/sv/field.second=sekund -FormatData/sv/field.week=vecka -FormatData/sv/field.weekday=veckodag -FormatData/sv/field.year=\u00e5r -FormatData/sv/field.zone=tidszon -FormatData/sv/roc.Eras/0=f\u00f6re R.K. -FormatData/sv/roc.Eras/1=R.K. -FormatData/sv/roc.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/sv/roc.DatePatterns/1=d MMMM y GGGG -FormatData/sv/roc.DatePatterns/2=d MMM y GGGG -FormatData/sv/roc.DatePatterns/3=GGGG y-MM-dd -FormatData/sv/islamic.DatePatterns/0=EEEE d MMMM y GGGG -FormatData/sv/islamic.DatePatterns/1=d MMMM y GGGG -FormatData/sv/islamic.DatePatterns/2=d MMM y GGGG -FormatData/sv/islamic.DatePatterns/3=GGGG y-MM-dd -FormatData/th/calendarname.buddhist=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e1e\u0e38\u0e17\u0e18 -FormatData/th/calendarname.gregorian=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19 -FormatData/th/calendarname.gregory=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e40\u0e01\u0e23\u0e01\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e19 -FormatData/th/calendarname.islamic-civil=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25 -FormatData/th/calendarname.islamic=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21 -FormatData/th/calendarname.islamicc=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e2d\u0e34\u0e2a\u0e25\u0e32\u0e21\u0e0b\u0e35\u0e27\u0e34\u0e25 -FormatData/th/calendarname.japanese=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e0d\u0e35\u0e48\u0e1b\u0e38\u0e48\u0e19 -FormatData/th/calendarname.roc=\u0e1b\u0e0f\u0e34\u0e17\u0e34\u0e19\u0e44\u0e15\u0e49\u0e2b\u0e27\u0e31\u0e19 -FormatData/th/field.dayperiod=\u0e0a\u0e48\u0e27\u0e07\u0e27\u0e31\u0e19 -FormatData/th/field.era=\u0e2a\u0e21\u0e31\u0e22 -FormatData/th/field.hour=\u0e0a\u0e31\u0e48\u0e27\u0e42\u0e21\u0e07 -FormatData/th/field.minute=\u0e19\u0e32\u0e17\u0e35 -FormatData/th/field.month=\u0e40\u0e14\u0e37\u0e2d\u0e19 -FormatData/th/field.second=\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35 -FormatData/th/field.week=\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c -FormatData/th/field.weekday=\u0e27\u0e31\u0e19\u0e43\u0e19\u0e2a\u0e31\u0e1b\u0e14\u0e32\u0e2b\u0e4c -FormatData/th/field.year=\u0e1b\u0e35 -FormatData/th/field.zone=\u0e40\u0e02\u0e15 -FormatData/th/islamic.MonthNames/0=\u0e21\u0e38\u0e2e\u0e30\u0e23\u0e4c\u0e23\u0e2d\u0e21 -FormatData/th/islamic.MonthNames/1=\u0e0b\u0e2d\u0e1f\u0e32\u0e23\u0e4c -FormatData/th/islamic.MonthNames/2=\u0e23\u0e2d\u0e1a\u0e35 I -FormatData/th/islamic.MonthNames/3=\u0e23\u0e2d\u0e1a\u0e35 II -FormatData/th/islamic.MonthNames/4=\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 I -FormatData/th/islamic.MonthNames/5=\u0e08\u0e38\u0e21\u0e32\u0e14\u0e32 II -FormatData/th/islamic.MonthNames/6=\u0e23\u0e2d\u0e08\u0e31\u0e1a -FormatData/th/islamic.MonthNames/7=\u0e0a\u0e30\u0e2d\u0e30\u0e1a\u0e32\u0e19 -FormatData/th/islamic.MonthNames/8=\u0e23\u0e2d\u0e21\u0e30\u0e14\u0e2d\u0e19 -FormatData/th/islamic.MonthNames/9=\u0e40\u0e0a\u0e32\u0e27\u0e31\u0e25 -FormatData/th/islamic.MonthNames/10=\u0e14\u0e2e\u0e38\u0e38\u0e2d\u0e31\u0e25\u0e01\u0e34\u0e14\u0e30\u0e2b\u0e4c -FormatData/th/islamic.MonthNames/11=\u0e14\u0e2e\u0e38\u0e2d\u0e31\u0e25\u0e2e\u0e34\u0e08\u0e08\u0e30\u0e2b\u0e4c -FormatData/th/islamic.MonthNames/12= -FormatData/th/islamic.long.Eras/0= -FormatData/th/islamic.long.Eras/1=\u0e2e\u0e34\u0e08\u0e40\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e28\u0e31\u0e01\u0e23\u0e32\u0e0a -FormatData/th/islamic.Eras/0= -FormatData/th/islamic.Eras/1=\u0e2e.\u0e28. -FormatData/th/roc.DatePatterns/0=EEEE\u0e17\u0e35\u0e48 d MMMM \u0e1b\u0e35GGGG\u0e17\u0e35\u0e48 y -FormatData/th/roc.DatePatterns/1=d MMMM \u0e1b\u0e35GGGG y -FormatData/th/roc.DatePatterns/2=d MMM GGGG y -FormatData/th/roc.DatePatterns/3=d/M/yy -FormatData/tr/calendarname.buddhist=Budist Takvimi -FormatData/tr/calendarname.gregorian=Miladi Takvim -FormatData/tr/calendarname.gregory=Miladi Takvim -FormatData/tr/calendarname.islamic-civil=Arap Takvimi -FormatData/tr/calendarname.islamic=Hicri Takvim -FormatData/tr/calendarname.islamicc=Arap Takvimi -FormatData/tr/calendarname.japanese=Japon Takvimi -FormatData/tr/calendarname.roc=\u00c7in Cumhuriyeti Takvimi -FormatData/tr/field.dayperiod=AM/PM -FormatData/tr/field.era=Miladi D\u00f6nem -FormatData/tr/field.hour=Saat -FormatData/tr/field.minute=Dakika -FormatData/tr/field.month=Ay -FormatData/tr/field.second=Saniye -FormatData/tr/field.week=Hafta -FormatData/tr/field.weekday=Haftan\u0131n G\u00fcn\u00fc -FormatData/tr/field.year=Y\u0131l -FormatData/tr/field.zone=Saat Dilimi -FormatData/tr/islamic.MonthNames/0=Muharrem -FormatData/tr/islamic.MonthNames/1=Safer -FormatData/tr/islamic.MonthNames/2=Rebi\u00fclevvel -FormatData/tr/islamic.MonthNames/3=Rebi\u00fclahir -FormatData/tr/islamic.MonthNames/4=Cemaziyelevvel -FormatData/tr/islamic.MonthNames/5=Cemaziyelahir -FormatData/tr/islamic.MonthNames/6=Recep -FormatData/tr/islamic.MonthNames/7=\u015eaban -FormatData/tr/islamic.MonthNames/8=Ramazan -FormatData/tr/islamic.MonthNames/9=\u015eevval -FormatData/tr/islamic.MonthNames/10=Zilkade -FormatData/tr/islamic.MonthNames/11=Zilhicce -FormatData/tr/islamic.MonthNames/12= -FormatData/tr/roc.DatePatterns/0=dd MMMM y GGGG EEEE -FormatData/tr/roc.DatePatterns/1=dd MMMM y GGGG -FormatData/tr/roc.DatePatterns/2=dd MMM y GGGG -FormatData/tr/roc.DatePatterns/3=dd.MM.yyyy GGGG -FormatData/tr/islamic.DatePatterns/0=dd MMMM y GGGG EEEE -FormatData/tr/islamic.DatePatterns/1=dd MMMM y GGGG -FormatData/tr/islamic.DatePatterns/2=dd MMM y GGGG -FormatData/tr/islamic.DatePatterns/3=dd.MM.yyyy GGGG -FormatData/uk/calendarname.buddhist=\u0411\u0443\u0434\u0434\u0456\u0439\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.gregorian=\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.gregory=\u0413\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.islamic-civil=\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.islamic=\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.islamicc=\u041c\u0443\u0441\u0443\u043b\u044c\u043c\u0430\u043d\u0441\u044c\u043a\u0438\u0439 \u0441\u0432\u0456\u0442\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.japanese=\u042f\u043f\u043e\u043d\u0441\u044c\u043a\u0438\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440 -FormatData/uk/calendarname.roc=\u041a\u0438\u0442\u0430\u0439\u0441\u044c\u043a\u0438\u0439 \u0433\u0440\u0438\u0433\u043e\u0440\u0456\u0430\u043d\u0441\u044c\u043a\u0438\u0439 -FormatData/uk/field.dayperiod=\u0427\u0430\u0441\u0442\u0438\u043d\u0430 \u0434\u043e\u0431\u0438 -FormatData/uk/field.era=\u0415\u0440\u0430 -FormatData/uk/field.hour=\u0413\u043e\u0434\u0438\u043d\u0430 -FormatData/uk/field.minute=\u0425\u0432\u0438\u043b\u0438\u043d\u0430 -FormatData/uk/field.month=\u041c\u0456\u0441\u044f\u0446\u044c -FormatData/uk/field.second=\u0421\u0435\u043a\u0443\u043d\u0434\u0430 -FormatData/uk/field.week=\u0422\u0438\u0436\u0434\u0435\u043d\u044c -FormatData/uk/field.weekday=\u0414\u0435\u043d\u044c \u0442\u0438\u0436\u043d\u044f -FormatData/uk/field.year=\u0420\u0456\u043a -FormatData/uk/field.zone=\u0417\u043e\u043d\u0430 -FormatData/uk/islamic.MonthNames/0=\u041c\u0443\u0445\u0430\u0440\u0440\u0430\u043c -FormatData/uk/islamic.MonthNames/1=\u0421\u0430\u0444\u0430\u0440 -FormatData/uk/islamic.MonthNames/2=\u0420\u0430\u0431\u0456 I -FormatData/uk/islamic.MonthNames/3=\u0420\u0430\u0431\u0456 II -FormatData/uk/islamic.MonthNames/4=\u0414\u0436\u0443\u043c\u0430\u0434\u0430 I -FormatData/uk/islamic.MonthNames/5=\u0414\u0436\u0443\u043c\u0430\u0434\u0430 II -FormatData/uk/islamic.MonthNames/6=\u0420\u0430\u0434\u0436\u0430\u0431 -FormatData/uk/islamic.MonthNames/7=\u0428\u0430\u0430\u0431\u0430\u043d -FormatData/uk/islamic.MonthNames/8=\u0420\u0430\u043c\u0430\u0434\u0430\u043d -FormatData/uk/islamic.MonthNames/9=\u0414\u0430\u0432\u0432\u0430\u043b -FormatData/uk/islamic.MonthNames/10=\u0417\u0443-\u043b\u044c-\u043a\u0430\u0430\u0434\u0430 -FormatData/uk/islamic.MonthNames/11=\u0417\u0443-\u043b\u044c-\u0445\u0456\u0434\u0436\u0430 -FormatData/uk/islamic.MonthNames/12= -FormatData/vi/calendarname.buddhist=L\u1ecbch Ph\u1eadt Gi\u00e1o -FormatData/vi/calendarname.gregorian=L\u1ecbch Gregory -FormatData/vi/calendarname.gregory=L\u1ecbch Gregory -FormatData/vi/calendarname.islamic-civil=L\u1ecbch Islamic-Civil -FormatData/vi/calendarname.islamic=L\u1ecbch Islamic -FormatData/vi/calendarname.islamicc=L\u1ecbch Islamic-Civil -FormatData/vi/calendarname.japanese=L\u1ecbch Nh\u1eadt B\u1ea3n -FormatData/vi/calendarname.roc=L\u1ecbch Trung Hoa D\u00e2n Qu\u1ed1c -FormatData/vi/field.dayperiod=SA/CH -FormatData/vi/field.era=Th\u1eddi \u0111\u1ea1i -FormatData/vi/field.hour=Gi\u1edd -FormatData/vi/field.minute=Ph\u00fat -FormatData/vi/field.month=Th\u00e1ng -FormatData/vi/field.second=Gi\u00e2y -FormatData/vi/field.week=Tu\u1ea7n -FormatData/vi/field.weekday=Ng\u00e0y trong tu\u1ea7n -FormatData/vi/field.year=N\u0103m -FormatData/vi/field.zone=M\u00fai gi\u1edd -FormatData/vi/roc.DatePatterns/0=EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG -FormatData/vi/roc.DatePatterns/1='Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG -FormatData/vi/roc.DatePatterns/2=dd-MM-y GGGG -FormatData/vi/roc.DatePatterns/3=dd/MM/y GGGG -FormatData/vi/islamic.DatePatterns/0=EEEE, 'ng\u00e0y' dd MMMM 'n\u0103m' y GGGG -FormatData/vi/islamic.DatePatterns/1='Ng\u00e0y' dd 'th\u00e1ng' M 'n\u0103m' y GGGG -FormatData/vi/islamic.DatePatterns/2=dd-MM-y GGGG -FormatData/vi/islamic.DatePatterns/3=dd/MM/y GGGG -FormatData/zh/calendarname.buddhist=\u4f5b\u6559\u65e5\u5386 -FormatData/zh/calendarname.gregorian=\u516c\u5386 -FormatData/zh/calendarname.gregory=\u516c\u5386 -FormatData/zh/calendarname.islamic-civil=\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386 -FormatData/zh/calendarname.islamic=\u4f0a\u65af\u5170\u65e5\u5386 -FormatData/zh/calendarname.islamicc=\u4f0a\u65af\u5170\u5e0c\u5409\u6765\u5386 -FormatData/zh/calendarname.japanese=\u65e5\u672c\u65e5\u5386 -FormatData/zh/calendarname.roc=\u6c11\u56fd\u65e5\u5386 -FormatData/zh/field.dayperiod=\u4e0a\u5348/\u4e0b\u5348 -FormatData/zh/field.era=\u65f6\u671f -FormatData/zh/field.hour=\u5c0f\u65f6 -FormatData/zh/field.minute=\u5206\u949f -FormatData/zh/field.month=\u6708 -FormatData/zh/field.second=\u79d2\u949f -FormatData/zh/field.week=\u5468 -FormatData/zh/field.weekday=\u5468\u5929 -FormatData/zh/field.year=\u5e74 -FormatData/zh/field.zone=\u533a\u57df -FormatData/zh/roc.DatePatterns/0=GGGGy\u5e74M\u6708d\u65e5EEEE -FormatData/zh/roc.DatePatterns/1=GGGGy\u5e74M\u6708d\u65e5 -FormatData/zh/roc.DatePatterns/2=GGGGy-M-d -FormatData/zh/roc.DatePatterns/3=GGGGy-M-d -FormatData/zh/islamic.DatePatterns/0=GGGGy\u5e74M\u6708d\u65e5EEEE -FormatData/zh/islamic.DatePatterns/1=GGGGy\u5e74M\u6708d\u65e5 -FormatData/zh/islamic.DatePatterns/2=GGGGy\u5e74M\u6708d\u65e5 -FormatData/zh/islamic.DatePatterns/3=GGGGyy-MM-dd -FormatData/zh_TW/calendarname.buddhist=\u4f5b\u6559\u66c6\u6cd5 -FormatData/zh_TW/calendarname.gregorian=\u516c\u66c6 -FormatData/zh_TW/calendarname.gregory=\u516c\u66c6 -FormatData/zh_TW/calendarname.islamic-civil=\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5 -FormatData/zh_TW/calendarname.islamic=\u4f0a\u65af\u862d\u66c6\u6cd5 -FormatData/zh_TW/calendarname.islamicc=\u4f0a\u65af\u862d\u57ce\u5e02\u66c6\u6cd5 -FormatData/zh_TW/calendarname.japanese=\u65e5\u672c\u66c6\u6cd5 -FormatData/zh_TW/calendarname.roc=\u6c11\u570b\u66c6 -FormatData/zh_TW/field.dayperiod=\u4e0a\u5348/\u4e0b\u5348 -FormatData/zh_TW/field.era=\u5e74\u4ee3 -FormatData/zh_TW/field.hour=\u5c0f\u6642 -FormatData/zh_TW/field.minute=\u5206\u9418 -FormatData/zh_TW/field.month=\u6708 -FormatData/zh_TW/field.second=\u79d2 -FormatData/zh_TW/field.week=\u9031 -FormatData/zh_TW/field.weekday=\u9031\u5929 -FormatData/zh_TW/field.year=\u5e74 -FormatData/zh_TW/roc.DatePatterns/0=GGGGy\u5e74M\u6708d\u65e5EEEE -FormatData/zh_TW/roc.DatePatterns/1=GGGGy\u5e74M\u6708d\u65e5 -FormatData/zh_TW/roc.DatePatterns/2=GGGGy/M/d -FormatData/zh_TW/roc.DatePatterns/3=GGGGy/M/d -FormatData/zh_TW/islamic.DatePatterns/0=GGGGy\u5e74M\u6708d\u65e5EEEE -FormatData/zh_TW/islamic.DatePatterns/1=GGGGy\u5e74M\u6708d\u65e5 -FormatData/zh_TW/islamic.DatePatterns/2=GGGGy/M/d -FormatData/zh_TW/islamic.DatePatterns/3=GGGGy/M/d - # bug 7114053 LocaleNames/sq/sq=shqip diff --git a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java index f1191c6e90c..45ead085fde 100644 --- a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java +++ b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java @@ -68,8 +68,8 @@ public class TestZoneInfo310 { } System.out.println("Compiling tz files!"); Main.main(alist.toArray(new String[alist.size()])); - ////////////////////////////////// + ////////////////////////////////// System.out.println("testing!"); ZoneInfoFile.ziDir = zidir; long t0, t1; @@ -96,11 +96,27 @@ public class TestZoneInfo310 { (t1 - t0) / 1000, zids_old.length); Arrays.sort(zids_old); + t0 = System.nanoTime(); + String[] alias_old = ZoneInfoOld.getAliasTable() + .keySet().toArray(new String[0]); + t1 = System.nanoTime(); + System.out.printf("OLD.getAliasTable()=%d, total=%d%n", + (t1 - t0) / 1000, alias_old.length); + Arrays.sort(alias_old); + + t0 = System.currentTimeMillis(); + for (String zid : zids_old) { + ZoneInfoOld.getTimeZone(zid); + } + t1 = System.currentTimeMillis(); + System.out.printf("OLD.TotalTZ()=%d (ms)%n", t1 - t0); + +/* t0 = System.nanoTime(); ZoneId.of("America/Los_Angeles").getRules(); t1 = System.nanoTime(); - System.out.printf("NEW.getTimeZone()[1]=%d%n", (t1 - t0) / 1000); - + System.out.printf("NEW.ZoneId.of()[1]=%d%n", (t1 - t0) / 1000); +*/ t0 = System.nanoTime(); TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles"); t1 = System.nanoTime(); @@ -123,6 +139,14 @@ public class TestZoneInfo310 { (t1 - t0) / 1000, zids_new.length); Arrays.sort(zids_new); + t0 = System.nanoTime(); + String[] alias_new = sun.util.calendar.ZoneInfo.getAliasTable() + .keySet().toArray(new String[0]); + t1 = System.nanoTime(); + System.out.printf("NEW.getAliasTable()=%d, total=%d%n", + (t1 - t0) / 1000, alias_new.length); + Arrays.sort(alias_new); + t0 = System.currentTimeMillis(); for (String zid : zids_new) { TimeZone.getTimeZone(zid); @@ -130,16 +154,14 @@ public class TestZoneInfo310 { t1 = System.currentTimeMillis(); System.out.printf("NEW.TotalTZ()=%d (ms)%n", t1 - t0); - t0 = System.currentTimeMillis(); - for (String zid : zids_old) { - ZoneInfoOld.getTimeZone(zid); - } - t1 = System.currentTimeMillis(); - System.out.printf("OLD.TotalTZ()=%d (ms)%n", t1 - t0); - if (!Arrays.equals(zids_old, zids_new)) { throw new RuntimeException(" FAILED: availableIds don't match"); } + + if (!Arrays.equals(alias_old, alias_new)) { + throw new RuntimeException(" FAILED: aliases don't match"); + } + for (String zid : zids_new) { ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid)); ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid); From dbdbff1445918612e6ba19f4dee759bd71090402 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Fri, 12 Apr 2013 09:51:04 -0700 Subject: [PATCH 51/52] 8012123: hijrah-config-umalqura.properties is missing from makefiles/profile-includes.txt Added the hijrah-config-umalqura.properties into the list Reviewed-by: alanb --- jdk/makefiles/profile-includes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/makefiles/profile-includes.txt b/jdk/makefiles/profile-includes.txt index 0a6ada9ae15..e9672714031 100644 --- a/jdk/makefiles/profile-includes.txt +++ b/jdk/makefiles/profile-includes.txt @@ -66,6 +66,7 @@ PROFILE_1_JRE_LIB_FILES := \ ext/sunec.jar \ ext/sunjce_provider.jar \ ext/sunpkcs11.jar \ + hijrah-config-umalqura.properties \ jce.jar \ jsse.jar \ logging.properties \ From 47686a92e05d71a493fd9f0ee9c17d2fc86e79d7 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Fri, 12 Apr 2013 10:02:33 -0700 Subject: [PATCH 52/52] 8011805: Update sun.tools.java class file reading/writing support to include the new constant pool entries Reviewed-by: mduigou, alanb --- .../invoke/InnerClassLambdaMetafactory.java | 2 +- .../sun/tools/java/BinaryConstantPool.java | 24 +++ .../sun/tools/java/RuntimeConstants.java | 3 + jdk/test/sun/tools/java/CFCTest.java | 181 ++++++++++++++++++ 4 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 jdk/test/sun/tools/java/CFCTest.java diff --git a/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java b/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java index f7191f7679f..9134bcf22ea 100644 --- a/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java +++ b/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java @@ -184,7 +184,7 @@ import java.security.PrivilegedAction; for (int i=0; i 88; + if (lam.get() == 88) { + System.out.println("Sanity passed: Lambda worked."); + } else { + throw new RuntimeException("Sanity failed: bad lambda execution"); + } + + // Verify that all the new constant pool constant types are present + String clsName = testClassPath + File.separator + testClassName + ".class"; + ClassConstantChecker ccc = new ClassConstantChecker(clsName); + ccc.checkFound(CONSTANT_METHODHANDLE); + ccc.checkFound(CONSTANT_METHODTYPE); + ccc.checkFound(CONSTANT_INVOKEDYNAMIC); + + // Heart of test: read the class file with the new constant types + exerciseClassDefinition(); + System.out.println("ClassDefinition read without failure.\n"); + } + + /** + * Failure is seen when getClassDefinition causes class read + */ + void exerciseClassDefinition() throws Exception { + BatchEnvironment env = new BatchEnvironment(System.out, + BatchEnvironment.createClassPath(testClassPath, null, null), + null); + try { + ClassDeclaration decl = env.getClassDeclaration( + Identifier.lookup(testClassName)); + decl.getClassDefinition(env); + } finally { + env.flushErrors(); + env.shutdown(); + } + } + + private class ClassConstantChecker { + + private DataInputStream in; + private boolean[] found; + + ClassConstantChecker(String clsName) throws IOException { + in = new DataInputStream(new FileInputStream(clsName)); + found = new boolean[CONSTANT_INVOKEDYNAMIC + 20]; + try { + check(); + } finally { + in.close(); + } + } + + void checkFound(int tag) throws Exception { + if (found[tag]) { + System.out.printf("Constant pool tag found: %d\n", tag); + } else { + throw new RuntimeException("Insufficient test, constant pool tag NOT found: " + tag); + } + } + + private void skip(int n) throws IOException { + if (in.skipBytes(n) != n) { + throw new EOFException(); + } + } + + private void check() throws IOException { + skip(8); // magic, version + int count = in.readUnsignedShort(); + for (int i = 1; i < count; i++) { + int j = i; + // JVM 4.4 cp_info.tag + int tag = in.readByte(); + found[tag] = true; + switch (tag) { + case CONSTANT_UTF8: + in.readUTF(); + break; + case CONSTANT_LONG: + case CONSTANT_DOUBLE: + skip(8); + break; + case CONSTANT_CLASS: + case CONSTANT_STRING: + skip(2); + break; + case CONSTANT_INTEGER: + case CONSTANT_FLOAT: + case CONSTANT_FIELD: + case CONSTANT_METHOD: + case CONSTANT_INTERFACEMETHOD: + case CONSTANT_NAMEANDTYPE: + skip(4); + break; + + case CONSTANT_METHODHANDLE: + skip(3); + break; + case CONSTANT_METHODTYPE: + skip(2); + break; + case CONSTANT_INVOKEDYNAMIC: + skip(4); + break; + + case 0: + default: + throw new ClassFormatError("invalid constant type: " + tag); + } + } + } + } +}