# HG changeset patch # User henryjen # Date 1544730666 28800 # Node ID b94283cb226baa47f87ede9d67a1ff4e5770c67f # Parent fd6de53a0d6e7c9084aca7582d7f98d51224d1ca# Parent cc4098b3bc10d1c390384289025fea7b0d4b9e93 Merge diff -r fd6de53a0d6e -r b94283cb226b make/autoconf/hotspot.m4 --- a/make/autoconf/hotspot.m4 Thu Dec 13 11:47:35 2018 -0800 +++ b/make/autoconf/hotspot.m4 Thu Dec 13 11:51:06 2018 -0800 @@ -327,7 +327,7 @@ # Only enable Shenandoah on supported arches AC_MSG_CHECKING([if shenandoah can be built]) - if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86" || test "x$OPENJDK_TARGET_CPU" = "xaarch64" ; then + if test "x$OPENJDK_TARGET_CPU" = "xx86_64" || test "x$OPENJDK_TARGET_CPU" = "xaarch64" ; then AC_MSG_RESULT([yes]) else DISABLED_JVM_FEATURES="$DISABLED_JVM_FEATURES shenandoahgc" diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/cpu/ppc/assembler_ppc.hpp --- a/src/hotspot/cpu/ppc/assembler_ppc.hpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/cpu/ppc/assembler_ppc.hpp Thu Dec 13 11:51:06 2018 -0800 @@ -539,6 +539,12 @@ XVSUBDP_OPCODE = (60u << OPCODE_SHIFT | 104u << 3), XVMULSP_OPCODE = (60u << OPCODE_SHIFT | 80u << 3), XVMULDP_OPCODE = (60u << OPCODE_SHIFT | 112u << 3), + XVMADDASP_OPCODE=(60u << OPCODE_SHIFT | 65u << 3), + XVMADDADP_OPCODE=(60u << OPCODE_SHIFT | 97u << 3), + XVMSUBASP_OPCODE=(60u << OPCODE_SHIFT | 81u << 3), + XVMSUBADP_OPCODE=(60u << OPCODE_SHIFT | 113u << 3), + XVNMSUBASP_OPCODE=(60u<< OPCODE_SHIFT | 209u << 3), + XVNMSUBADP_OPCODE=(60u<< OPCODE_SHIFT | 241u << 3), // Deliver A Random Number (introduced with POWER9) DARN_OPCODE = (31u << OPCODE_SHIFT | 755u << 1), @@ -2227,6 +2233,12 @@ inline void xvsubdp( VectorSRegister d, VectorSRegister a, VectorSRegister b); inline void xvmulsp( VectorSRegister d, VectorSRegister a, VectorSRegister b); inline void xvmuldp( VectorSRegister d, VectorSRegister a, VectorSRegister b); + inline void xvmaddasp(VectorSRegister d, VectorSRegister a, VectorSRegister b); + inline void xvmaddadp(VectorSRegister d, VectorSRegister a, VectorSRegister b); + inline void xvmsubasp(VectorSRegister d, VectorSRegister a, VectorSRegister b); + inline void xvmsubadp(VectorSRegister d, VectorSRegister a, VectorSRegister b); + inline void xvnmsubasp(VectorSRegister d, VectorSRegister a, VectorSRegister b); + inline void xvnmsubadp(VectorSRegister d, VectorSRegister a, VectorSRegister b); // VSX Extended Mnemonics inline void xxspltd( VectorSRegister d, VectorSRegister a, int x); diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/cpu/ppc/assembler_ppc.inline.hpp --- a/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp Thu Dec 13 11:51:06 2018 -0800 @@ -790,6 +790,12 @@ inline void Assembler::xvsubdp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVSUBDP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } inline void Assembler::xvmulsp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMULSP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } inline void Assembler::xvmuldp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMULDP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } +inline void Assembler::xvmaddasp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMADDASP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } +inline void Assembler::xvmaddadp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMADDADP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } +inline void Assembler::xvmsubasp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMSUBASP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } +inline void Assembler::xvmsubadp( VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVMSUBADP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } +inline void Assembler::xvnmsubasp(VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVNMSUBASP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } +inline void Assembler::xvnmsubadp(VectorSRegister d, VectorSRegister a, VectorSRegister b) { emit_int32( XVNMSUBADP_OPCODE | vsrt(d) | vsra(a) | vsrb(b)); } inline void Assembler::mtvrd( VectorRegister d, Register a) { emit_int32( MTVSRD_OPCODE | vsrt(d->to_vsr()) | ra(a)); } inline void Assembler::mfvrd( Register a, VectorRegister d) { emit_int32( MFVSRD_OPCODE | vsrt(d->to_vsr()) | ra(a)); } inline void Assembler::mtvrwz( VectorRegister d, Register a) { emit_int32( MTVSRWZ_OPCODE | vsrt(d->to_vsr()) | ra(a)); } diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/cpu/ppc/ppc.ad --- a/src/hotspot/cpu/ppc/ppc.ad Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/cpu/ppc/ppc.ad Thu Dec 13 11:51:06 2018 -0800 @@ -2257,6 +2257,9 @@ return SuperwordUseVSX; case Op_PopCountVI: return (SuperwordUseVSX && UsePopCountInstruction); + case Op_FmaVF: + case Op_FmaVD: + return (SuperwordUseVSX && UseFMA); case Op_Digit: case Op_LowerCase: case Op_UpperCase: @@ -14475,6 +14478,92 @@ ins_pipe(pipe_class_default); %} +// --------------------------------- FMA -------------------------------------- +// dst + src1 * src2 +instruct vfma4F(vecX dst, vecX src1, vecX src2) %{ + match(Set dst (FmaVF dst (Binary src1 src2))); + predicate(n->as_Vector()->length() == 4); + + format %{ "XVMADDASP $dst, $src1, $src2" %} + + size(4); + ins_encode %{ + __ xvmaddasp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister); + %} + ins_pipe(pipe_class_default); +%} + +// dst - src1 * src2 +instruct vfma4F_neg1(vecX dst, vecX src1, vecX src2) %{ + match(Set dst (FmaVF dst (Binary (NegVF src1) src2))); + match(Set dst (FmaVF dst (Binary src1 (NegVF src2)))); + predicate(n->as_Vector()->length() == 4); + + format %{ "XVNMSUBASP $dst, $src1, $src2" %} + + size(4); + ins_encode %{ + __ xvnmsubasp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister); + %} + ins_pipe(pipe_class_default); +%} + +// - dst + src1 * src2 +instruct vfma4F_neg2(vecX dst, vecX src1, vecX src2) %{ + match(Set dst (FmaVF (NegVF dst) (Binary src1 src2))); + predicate(n->as_Vector()->length() == 4); + + format %{ "XVMSUBASP $dst, $src1, $src2" %} + + size(4); + ins_encode %{ + __ xvmsubasp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister); + %} + ins_pipe(pipe_class_default); +%} + +// dst + src1 * src2 +instruct vfma2D(vecX dst, vecX src1, vecX src2) %{ + match(Set dst (FmaVD dst (Binary src1 src2))); + predicate(n->as_Vector()->length() == 2); + + format %{ "XVMADDADP $dst, $src1, $src2" %} + + size(4); + ins_encode %{ + __ xvmaddadp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister); + %} + ins_pipe(pipe_class_default); +%} + +// dst - src1 * src2 +instruct vfma2D_neg1(vecX dst, vecX src1, vecX src2) %{ + match(Set dst (FmaVD dst (Binary (NegVD src1) src2))); + match(Set dst (FmaVD dst (Binary src1 (NegVD src2)))); + predicate(n->as_Vector()->length() == 2); + + format %{ "XVNMSUBADP $dst, $src1, $src2" %} + + size(4); + ins_encode %{ + __ xvnmsubadp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister); + %} + ins_pipe(pipe_class_default); +%} + +// - dst + src1 * src2 +instruct vfma2D_neg2(vecX dst, vecX src1, vecX src2) %{ + match(Set dst (FmaVD (NegVD dst) (Binary src1 src2))); + predicate(n->as_Vector()->length() == 2); + + format %{ "XVMSUBADP $dst, $src1, $src2" %} + + size(4); + ins_encode %{ + __ xvmsubadp($dst$$VectorSRegister, $src1$$VectorSRegister, $src2$$VectorSRegister); + %} + ins_pipe(pipe_class_default); +%} //----------Overflow Math Instructions----------------------------------------- diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/cpu/x86/macroAssembler_x86_aes.cpp --- a/src/hotspot/cpu/x86/macroAssembler_x86_aes.cpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/cpu/x86/macroAssembler_x86_aes.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -29,6 +29,7 @@ #include "runtime/stubRoutines.hpp" #include "macroAssembler_x86.hpp" +#ifdef _LP64 // Multiply 128 x 128 bits, using 4 pclmulqdq operations void MacroAssembler::schoolbookAAD(int i, Register htbl, XMMRegister data, XMMRegister tmp0, XMMRegister tmp1, XMMRegister tmp2, XMMRegister tmp3) { @@ -319,4 +320,5 @@ vpxor(xmm1, xmm1, xmm1, Assembler::AVX_128bit); vpxor(xmm3, xmm3, xmm3, Assembler::AVX_128bit); vpxor(xmm15, xmm15, xmm15, Assembler::AVX_128bit); -} \ No newline at end of file +} +#endif // _LP64 diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/os/linux/os_linux.cpp --- a/src/hotspot/os/linux/os_linux.cpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/os/linux/os_linux.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -1354,9 +1354,11 @@ void os::abort(bool dump_core, void* siginfo, const void* context) { os::shutdown(); if (dump_core) { +#if INCLUDE_CDS if (UseSharedSpaces && DumpPrivateMappingsInCore) { ClassLoader::close_jrt_image(); } +#endif #ifndef PRODUCT fdStream out(defaultStream::output_fd()); out.print_raw("Current thread is "); @@ -5075,9 +5077,11 @@ set_coredump_filter(DAX_SHARED_BIT); } +#if INCLUDE_CDS if (UseSharedSpaces && DumpPrivateMappingsInCore) { set_coredump_filter(FILE_BACKED_PVT_BIT); } +#endif return JNI_OK; } diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -939,9 +939,6 @@ q = queues->claim_next(); while (q != NULL) { if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) { - ShenandoahCancelledTerminatorTerminator tt; - ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers); - while (!terminator->offer_termination(&tt)); return; } @@ -965,9 +962,6 @@ */ while (true) { if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) { - ShenandoahCancelledTerminatorTerminator tt; - ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers); - while (!terminator->offer_termination(&tt)); return; } @@ -991,7 +985,8 @@ // Need to leave the STS here otherwise it might block safepoints. ShenandoahSuspendibleThreadSetLeaver stsl(CANCELLABLE && ShenandoahSuspendibleWorkers); ShenandoahTerminationTimingsTracker term_tracker(worker_id); - if (terminator->offer_termination()) return; + ShenandoahTerminatorTerminator tt(heap); + if (terminator->offer_termination(&tt)) return; } } } diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp --- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -49,28 +49,8 @@ return true; } -class ShenandoahOWSTTerminator: public OWSTTaskTerminator { -public: - ShenandoahOWSTTerminator(uint n_threads, TaskQueueSetSuper* queue_set) : - OWSTTaskTerminator(n_threads, queue_set){ } - -protected: - bool exit_termination(size_t tasks, TerminatorTerminator* terminator); -}; - -bool ShenandoahOWSTTerminator::exit_termination(size_t tasks, TerminatorTerminator* terminator) { - ShenandoahTerminatorTerminator* t = (ShenandoahTerminatorTerminator*)terminator; - bool force = (t != NULL) && t->should_force_termination(); - if (force) { - // Force termination : continue termination, even there are remaining tasks. - return false; - } else { - return OWSTTaskTerminator::exit_termination(tasks, terminator); - } -} - ShenandoahTaskTerminator::ShenandoahTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) : - _terminator(new ShenandoahOWSTTerminator(n_threads, queue_set)) { } + _terminator(new OWSTTaskTerminator(n_threads, queue_set)) { } ShenandoahTaskTerminator::~ShenandoahTaskTerminator() { assert(_terminator != NULL, "Invariant"); diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp --- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp Thu Dec 13 11:51:06 2018 -0800 @@ -306,18 +306,12 @@ }; class ShenandoahTerminatorTerminator : public TerminatorTerminator { +private: + ShenandoahHeap* _heap; public: + ShenandoahTerminatorTerminator(ShenandoahHeap* const heap) : _heap(heap) { } // return true, terminates immediately, even if there's remaining work left - virtual bool should_force_termination() { return false; } -}; - -class ShenandoahCancelledTerminatorTerminator : public ShenandoahTerminatorTerminator { - virtual bool should_exit_termination() { - return false; - } - virtual bool should_force_termination() { - return true; - } + virtual bool should_exit_termination() { return _heap->cancelled_gc(); } }; class ShenandoahTaskTerminator : public StackObj { diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp --- a/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -498,10 +498,6 @@ q = queues->claim_next(); while (q != NULL) { if (_heap->check_cancelled_gc_and_yield(sts_yield)) { - ShenandoahCancelledTerminatorTerminator tt; - ShenandoahEvacOOMScopeLeaver oom_scope_leaver; - ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers); - while (!terminator->offer_termination(&tt)); return; } @@ -547,17 +543,15 @@ ShenandoahEvacOOMScopeLeaver oom_scope_leaver; ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers); ShenandoahTerminationTimingsTracker term_tracker(worker_id); - if (terminator->offer_termination()) return; + ShenandoahTerminatorTerminator tt(_heap); + + if (terminator->offer_termination(&tt)) return; } } } bool ShenandoahTraversalGC::check_and_handle_cancelled_gc(ShenandoahTaskTerminator* terminator, bool sts_yield) { if (_heap->cancelled_gc()) { - ShenandoahCancelledTerminatorTerminator tt; - ShenandoahEvacOOMScopeLeaver oom_scope_leaver; - ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers); - while (! terminator->offer_termination(&tt)); return true; } return false; diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/jni/jfrJniMethod.cpp --- a/src/hotspot/share/jfr/jni/jfrJniMethod.cpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/jfr/jni/jfrJniMethod.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -33,7 +33,7 @@ #include "jfr/recorder/checkpoint/jfrMetadataEvent.hpp" #include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp" #include "jfr/recorder/repository/jfrRepository.hpp" -#include "jfr/recorder/repository/jfrChunkSizeNotifier.hpp" +#include "jfr/recorder/repository/jfrChunkRotation.hpp" #include "jfr/recorder/repository/jfrChunkWriter.hpp" #include "jfr/recorder/service/jfrOptionSet.hpp" #include "jfr/recorder/stacktrace/jfrStackTraceRepository.hpp" @@ -114,7 +114,7 @@ NO_TRANSITION_END NO_TRANSITION(void, jfr_set_file_notification(JNIEnv* env, jobject jvm, jlong threshold)) - JfrChunkSizeNotifier::set_chunk_size_threshold((size_t)threshold); + JfrChunkRotation::set_threshold((intptr_t)threshold); NO_TRANSITION_END NO_TRANSITION(void, jfr_set_sample_threads(JNIEnv* env, jobject jvm, jboolean sampleThreads)) @@ -173,6 +173,9 @@ return JfrEventSetting::set_cutoff(event_type_id, cutoff_ticks) ? JNI_TRUE : JNI_FALSE; NO_TRANSITION_END +NO_TRANSITION(jboolean, jfr_should_rotate_disk(JNIEnv* env, jobject jvm)) + return JfrChunkRotation::should_rotate() ? JNI_TRUE : JNI_FALSE; +NO_TRANSITION_END /* * JVM_ENTRY_NO_ENV entries diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/jni/jfrJniMethod.hpp --- a/src/hotspot/share/jfr/jni/jfrJniMethod.hpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/jfr/jni/jfrJniMethod.hpp Thu Dec 13 11:51:06 2018 -0800 @@ -129,6 +129,9 @@ void JNICALL jfr_emit_old_object_samples(JNIEnv* env, jobject jvm, jlong cutoff_ticks, jboolean); +jboolean JNICALL jfr_should_rotate_disk(JNIEnv* env, jobject jvm); + + #ifdef __cplusplus } #endif diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp --- a/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -78,7 +78,8 @@ (char*)"setForceInstrumentation", (char*)"(Z)V", (void*)jfr_set_force_instrumentation, (char*)"getUnloadedEventClassCount", (char*)"()J", (void*)jfr_get_unloaded_event_classes_count, (char*)"setCutoff", (char*)"(JJ)Z", (void*)jfr_set_cutoff, - (char*)"emitOldObjectSamples", (char*)"(JZ)V", (void*)jfr_emit_old_object_samples + (char*)"emitOldObjectSamples", (char*)"(JZ)V", (void*)jfr_emit_old_object_samples, + (char*)"shouldRotateDisk", (char*)"()Z", (void*)jfr_should_rotate_disk }; const size_t method_array_length = sizeof(method) / sizeof(JNINativeMethod); diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/leakprofiler/emitEventOperation.cpp --- a/src/hotspot/share/jfr/leakprofiler/emitEventOperation.cpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/jfr/leakprofiler/emitEventOperation.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -185,7 +185,7 @@ if (object->is_array()) { return arrayOop(object)->length(); } - return -1; + return min_jint; } void EmitEventOperation::write_event(const ObjectSample* sample, EdgeStore* edge_store) { diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/metadata/metadata.xml --- a/src/hotspot/share/jfr/metadata/metadata.xml Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/jfr/metadata/metadata.xml Thu Dec 13 11:51:06 2018 -0800 @@ -65,19 +65,19 @@ - - - @@ -350,7 +350,7 @@ - + @@ -362,7 +362,7 @@ - + @@ -564,9 +564,9 @@ relation="SafepointId" /> - - + - @@ -647,8 +647,8 @@ - - + + @@ -663,13 +663,13 @@ - + - - + + @@ -687,7 +687,7 @@ - + @@ -741,8 +741,7 @@ + description="Module to which the package is qualifiedly exported. If null or N/A, the package is unqualifiedly exported" /> @@ -1096,7 +1095,7 @@ - + @@ -1134,13 +1133,16 @@ - - - - - - - - - + + + + + + + + + + + + diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/metadata/metadata.xsd --- a/src/hotspot/share/jfr/metadata/metadata.xsd Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/jfr/metadata/metadata.xsd Thu Dec 13 11:51:06 2018 -0800 @@ -107,8 +107,7 @@ - - + diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/periodic/jfrNetworkUtilization.cpp --- a/src/hotspot/share/jfr/periodic/jfrNetworkUtilization.cpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/jfr/periodic/jfrNetworkUtilization.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -174,8 +174,8 @@ event.set_starttime(cur_time); event.set_endtime(cur_time); event.set_networkInterface(entry.id); - event.set_readRate(read_rate); - event.set_writeRate(write_rate); + event.set_readRate(8 * read_rate); + event.set_writeRate(8 * write_rate); event.commit(); } // update existing entry with new values diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/recorder/repository/jfrChunkRotation.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/jfr/recorder/repository/jfrChunkRotation.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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 "jfr/jni/jfrJavaSupport.hpp" +#include "jfr/recorder/repository/jfrChunkRotation.hpp" +#include "jfr/recorder/repository/jfrChunkWriter.hpp" + +static jobject chunk_monitor = NULL; +static intptr_t threshold = 0; +static bool rotate = false; + +static jobject install_chunk_monitor(Thread* thread) { + assert(chunk_monitor == NULL, "invariant"); + // read static field + HandleMark hm(thread); + static const char klass[] = "jdk/jfr/internal/JVM"; + static const char field[] = "FILE_DELTA_CHANGE"; + static const char signature[] = "Ljava/lang/Object;"; + JavaValue result(T_OBJECT); + JfrJavaArguments field_args(&result, klass, field, signature, thread); + JfrJavaSupport::get_field_global_ref(&field_args, thread); + chunk_monitor = result.get_jobject(); + return chunk_monitor; +} + +// lazy install +static jobject get_chunk_monitor(Thread* thread) { + return chunk_monitor != NULL ? chunk_monitor : install_chunk_monitor(thread); +} + +static void notify() { + Thread* const thread = Thread::current(); + JfrJavaSupport::notify_all(get_chunk_monitor(thread), thread); +} + +void JfrChunkRotation::evaluate(const JfrChunkWriter& writer) { + assert(threshold > 0, "invariant"); + if (rotate) { + // already in progress + return; + } + assert(!rotate, "invariant"); + if (writer.size_written() > threshold) { + rotate = true; + notify(); + } +} + +bool JfrChunkRotation::should_rotate() { + return rotate; +} + +void JfrChunkRotation::on_rotation() { + rotate = false; +} + +void JfrChunkRotation::set_threshold(intptr_t bytes) { + threshold = bytes; +} diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/recorder/repository/jfrChunkRotation.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/jfr/recorder/repository/jfrChunkRotation.hpp Thu Dec 13 11:51:06 2018 -0800 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute 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_JFR_RECORDER_REPOSITORY_JFRCHUNKROTATION_HPP +#define SHARE_VM_JFR_RECORDER_REPOSITORY_JFRCHUNKROTATION_HPP + +#include "memory/allocation.hpp" + +class JfrChunkWriter; + +// +// Responsible for notifications about current chunk size now exceeding threshold. +// This is a means to initiate a chunk rotation on the basis of the size written. +// +class JfrChunkRotation : AllStatic { + public: + static void evaluate(const JfrChunkWriter& writer); + static void set_threshold(intptr_t bytes); + static bool should_rotate(); + static void on_rotation(); +}; + +#endif // SHARE_VM_JFR_RECORDER_REPOSITORY_JFRCHUNKROTATION_HPP diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/recorder/repository/jfrChunkSizeNotifier.cpp --- a/src/hotspot/share/jfr/recorder/repository/jfrChunkSizeNotifier.cpp Thu Dec 13 11:47:35 2018 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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 "jfr/jni/jfrJavaSupport.hpp" -#include "jfr/recorder/repository/jfrChunkWriter.hpp" -#include "jfr/recorder/repository/jfrChunkSizeNotifier.hpp" - -size_t JfrChunkSizeNotifier::_chunk_size_threshold = 0; - -void JfrChunkSizeNotifier::set_chunk_size_threshold(size_t bytes) { - _chunk_size_threshold = bytes; -} - -size_t JfrChunkSizeNotifier::chunk_size_threshold() { - return _chunk_size_threshold; -} - -static jobject new_chunk_monitor = NULL; - -// lazy install -static jobject get_new_chunk_monitor(Thread* thread) { - static bool initialized = false; - if (initialized) { - assert(new_chunk_monitor != NULL, "invariant"); - return new_chunk_monitor; - } - assert(new_chunk_monitor == NULL, "invariant"); - // read static field - HandleMark hm(thread); - static const char klass[] = "jdk/jfr/internal/JVM"; - static const char field[] = "FILE_DELTA_CHANGE"; - static const char signature[] = "Ljava/lang/Object;"; - JavaValue result(T_OBJECT); - JfrJavaArguments field_args(&result, klass, field, signature, thread); - JfrJavaSupport::get_field_global_ref(&field_args, thread); - new_chunk_monitor = result.get_jobject(); - initialized = new_chunk_monitor != NULL; - return new_chunk_monitor; -} - -void JfrChunkSizeNotifier::notify() { - Thread* const thread = Thread::current(); - JfrJavaSupport::notify_all(get_new_chunk_monitor(thread), thread); -} - -void JfrChunkSizeNotifier::release_monitor() { - if (new_chunk_monitor != NULL) { - JfrJavaSupport::destroy_global_jni_handle(new_chunk_monitor); - new_chunk_monitor = NULL; - } -} diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/recorder/repository/jfrChunkSizeNotifier.hpp --- a/src/hotspot/share/jfr/recorder/repository/jfrChunkSizeNotifier.hpp Thu Dec 13 11:47:35 2018 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute 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_JFR_RECORDER_REPOSITORY_JFRRCHUNKSIZENOTIFIER_HPP -#define SHARE_VM_JFR_RECORDER_REPOSITORY_JFRRCHUNKSIZENOTIFIER_HPP - -#include "memory/allocation.hpp" - -// -// Responsible for notifications about current chunk size now exceeding threshold. -// This is a means to initiate a chunk rotation on the basis of size written. -// -class JfrChunkSizeNotifier : AllStatic { - friend class JfrRecorder; - private: - static size_t _chunk_size_threshold; - static void release_monitor(); - public: - static void set_chunk_size_threshold(size_t bytes); - static size_t chunk_size_threshold(); - static void notify(); -}; - -#endif // SHARE_VM_JFR_RECORDER_REPOSITORY_JFRRCHUNKSIZENOTIFIER_HPP diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp --- a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -28,7 +28,7 @@ #include "jfr/recorder/jfrRecorder.hpp" #include "jfr/recorder/checkpoint/jfrCheckpointManager.hpp" #include "jfr/recorder/checkpoint/jfrMetadataEvent.hpp" -#include "jfr/recorder/repository/jfrChunkSizeNotifier.hpp" +#include "jfr/recorder/repository/jfrChunkRotation.hpp" #include "jfr/recorder/repository/jfrChunkWriter.hpp" #include "jfr/recorder/repository/jfrRepository.hpp" #include "jfr/recorder/service/jfrPostBox.hpp" @@ -340,6 +340,7 @@ void JfrRecorderService::open_new_chunk(bool vm_error) { assert(!_chunkwriter.is_valid(), "invariant"); assert(!JfrStream_lock->owned_by_self(), "invariant"); + JfrChunkRotation::on_rotation(); MutexLockerEx stream_lock(JfrStream_lock, Mutex::_no_safepoint_check_flag); if (!_repository.open_chunk(vm_error)) { assert(!_chunkwriter.is_valid(), "invariant"); @@ -535,8 +536,5 @@ } void JfrRecorderService::evaluate_chunk_size_for_rotation() { - const size_t size_written = _chunkwriter.size_written(); - if (size_written > JfrChunkSizeNotifier::chunk_size_threshold()) { - JfrChunkSizeNotifier::notify(); - } + JfrChunkRotation::evaluate(_chunkwriter); } diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/runtime/globals.hpp --- a/src/hotspot/share/runtime/globals.hpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/runtime/globals.hpp Thu Dec 13 11:51:06 2018 -0800 @@ -501,6 +501,13 @@ diagnostic(bool, AbortVMOnSafepointTimeout, false, \ "Abort upon failure to reach safepoint (see SafepointTimeout)") \ \ + diagnostic(bool, AbortVMOnVMOperationTimeout, false, \ + "Abort upon failure to complete VM operation promptly") \ + \ + diagnostic(intx, AbortVMOnVMOperationTimeoutDelay, 1000, \ + "Delay in milliseconds for option AbortVMOnVMOperationTimeout") \ + range(0, max_intx) \ + \ /* 50 retries * (5 * current_retry_count) millis = ~6.375 seconds */ \ /* typically, at most a few retries are needed */ \ product(intx, SuspendRetryCount, 50, \ diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/runtime/vmThread.cpp --- a/src/hotspot/share/runtime/vmThread.cpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/runtime/vmThread.cpp Thu Dec 13 11:51:06 2018 -0800 @@ -28,6 +28,7 @@ #include "jfr/jfrEvents.hpp" #include "jfr/support/jfrThreadId.hpp" #include "logging/log.hpp" +#include "logging/logStream.hpp" #include "logging/logConfiguration.hpp" #include "memory/resourceArea.hpp" #include "oops/method.hpp" @@ -197,6 +198,32 @@ drain_list_oops_do(f); } +//------------------------------------------------------------------------------------------------------------------ +// Timeout machinery + +void VMOperationTimeoutTask::task() { + assert(AbortVMOnVMOperationTimeout, "only if enabled"); + if (is_armed()) { + jlong delay = (os::javaTimeMillis() - _arm_time); + if (delay > AbortVMOnVMOperationTimeoutDelay) { + fatal("VM operation took too long: " SIZE_FORMAT " ms (timeout: " SIZE_FORMAT " ms)", + delay, AbortVMOnVMOperationTimeoutDelay); + } + } +} + +bool VMOperationTimeoutTask::is_armed() { + return OrderAccess::load_acquire(&_armed) != 0; +} + +void VMOperationTimeoutTask::arm() { + _arm_time = os::javaTimeMillis(); + OrderAccess::release_store_fence(&_armed, 1); +} + +void VMOperationTimeoutTask::disarm() { + OrderAccess::release_store_fence(&_armed, 0); +} //------------------------------------------------------------------------------------------------------------------ // Implementation of VMThread stuff @@ -209,12 +236,28 @@ VMOperationQueue* VMThread::_vm_queue = NULL; PerfCounter* VMThread::_perf_accumulated_vm_operation_time = NULL; const char* VMThread::_no_op_reason = NULL; +VMOperationTimeoutTask* VMThread::_timeout_task = NULL; void VMThread::create() { assert(vm_thread() == NULL, "we can only allocate one VMThread"); _vm_thread = new VMThread(); + if (AbortVMOnVMOperationTimeout) { + // Make sure we call the timeout task frequently enough, but not too frequent. + // Try to make the interval 10% of the timeout delay, so that we miss the timeout + // by those 10% at max. Periodic task also expects it to fit min/max intervals. + size_t interval = (size_t)AbortVMOnVMOperationTimeoutDelay / 10; + interval = interval / PeriodicTask::interval_gran * PeriodicTask::interval_gran; + interval = MAX2(interval, PeriodicTask::min_interval); + interval = MIN2(interval, PeriodicTask::max_interval); + + _timeout_task = new VMOperationTimeoutTask(interval); + _timeout_task->enroll(); + } else { + assert(_timeout_task == NULL, "sanity"); + } + // Create VM operation queue _vm_queue = new VMOperationQueue(); guarantee(_vm_queue != NULL, "just checking"); @@ -492,6 +535,11 @@ _vm_queue->set_drain_list(safepoint_ops); // ensure ops can be scanned SafepointSynchronize::begin(); + + if (_timeout_task != NULL) { + _timeout_task->arm(); + } + evaluate_operation(_cur_vm_operation); // now process all queued safepoint ops, iteratively draining // the queue until there are none left @@ -533,6 +581,10 @@ _vm_queue->set_drain_list(NULL); + if (_timeout_task != NULL) { + _timeout_task->disarm(); + } + // Complete safepoint synchronization SafepointSynchronize::end(); diff -r fd6de53a0d6e -r b94283cb226b src/hotspot/share/runtime/vmThread.hpp --- a/src/hotspot/share/runtime/vmThread.hpp Thu Dec 13 11:47:35 2018 -0800 +++ b/src/hotspot/share/runtime/vmThread.hpp Thu Dec 13 11:51:06 2018 -0800 @@ -27,6 +27,7 @@ #include "runtime/perfData.hpp" #include "runtime/thread.hpp" +#include "runtime/task.hpp" #include "runtime/vmOperations.hpp" // @@ -84,6 +85,26 @@ }; +// VM operation timeout handling: warn or abort the VM when VM operation takes +// too long. Periodic tasks do not participate in safepoint protocol, and therefore +// can fire when application threads are stopped. + +class VMOperationTimeoutTask : public PeriodicTask { +private: + volatile int _armed; + jlong _arm_time; + +public: + VMOperationTimeoutTask(size_t interval_time) : + PeriodicTask(interval_time), _armed(0), _arm_time(0) {} + + virtual void task(); + + bool is_armed(); + void arm(); + void disarm(); +}; + // // A single VMThread (the primordial thread) spawns all other threads // and is itself used by other threads to offload heavy vm operations @@ -101,6 +122,8 @@ static const char* _no_op_reason; + static VMOperationTimeoutTask* _timeout_task; + static bool no_op_safepoint_needed(bool check_time); void evaluate_operation(VM_Operation* op); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/com/sun/java/util/jar/pack/Attribute.java --- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Attribute.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Attribute.java Thu Dec 13 11:51:06 2018 -0800 @@ -996,7 +996,7 @@ endp = cstr.indexOf(',', cp); if (endp < 0) endp = cstrlen; String cstr1 = cstr.substring(cp, endp); - if (cstr1.length() == 0) + if (cstr1.isEmpty()) cstr1 = "empty"; // will fail parse int value0, value1; // Check for a case range (new in 1.6). diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java --- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java Thu Dec 13 11:51:06 2018 -0800 @@ -279,7 +279,7 @@ junpack.properties().putAll(engProps); if (doRepack && newfile.equals(jarfile)) { String zipc = getZipComment(jarfile); - if (verbose && zipc.length() > 0) + if (verbose && !zipc.isEmpty()) System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.DETECTED_ZIP_COMMENT), zipc)); if (zipc.indexOf(Utils.PACK_ZIP_ARCHIVE_MARKER_COMMENT) >= 0) { System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.SKIP_FOR_REPACKED), jarfile)); @@ -552,7 +552,7 @@ if (words.length == 0) continue loadOptmap; String opt = words[0]; words[0] = ""; // initial word is not a spec - if (opt.length() == 0 && words.length >= 1) { + if (opt.isEmpty() && words.length >= 1) { opt = words[1]; // initial "word" is empty due to leading ' ' words[1] = ""; } @@ -622,7 +622,7 @@ switch (specop) { case '+': // + means we want an non-empty val suffix. - ok = (val.length() != 0); + ok = !val.isEmpty(); specop = spec.charAt(sidx++); break; case '*': @@ -641,10 +641,10 @@ String specarg = spec.substring(sidx); switch (specop) { case '.': // terminate the option sequence - resultString = (specarg.length() != 0)? specarg.intern(): opt; + resultString = specarg.isEmpty() ? opt : specarg.intern(); break doArgs; case '?': // abort the option sequence - resultString = (specarg.length() != 0)? specarg.intern(): arg; + resultString = specarg.isEmpty() ? arg : specarg.intern(); isError = true; break eachSpec; case '@': // change the effective opt name @@ -655,14 +655,14 @@ val = ""; break; case '!': // negation option - String negopt = (specarg.length() != 0)? specarg.intern(): opt; + String negopt = specarg.isEmpty() ? opt : specarg.intern(); properties.remove(negopt); properties.put(negopt, null); // leave placeholder didAction = true; break; case '$': // normal "boolean" option String boolval; - if (specarg.length() != 0) { + if (!specarg.isEmpty()) { // If there is a given spec token, store it. boolval = specarg; } else { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/com/sun/net/ssl/KeyManagerFactory.java --- a/src/java.base/share/classes/com/sun/net/ssl/KeyManagerFactory.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/com/sun/net/ssl/KeyManagerFactory.java Thu Dec 13 11:51:06 2018 -0800 @@ -153,7 +153,7 @@ String provider) throws NoSuchAlgorithmException, NoSuchProviderException { - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = SSLSecurity.getImpl(algorithm, "KeyManagerFactory", provider); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/com/sun/net/ssl/SSLContext.java --- a/src/java.base/share/classes/com/sun/net/ssl/SSLContext.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/com/sun/net/ssl/SSLContext.java Thu Dec 13 11:51:06 2018 -0800 @@ -109,7 +109,7 @@ public static SSLContext getInstance(String protocol, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext", provider); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java --- a/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/com/sun/net/ssl/TrustManagerFactory.java Thu Dec 13 11:51:06 2018 -0800 @@ -155,7 +155,7 @@ String provider) throws NoSuchAlgorithmException, NoSuchProviderException { - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = SSLSecurity.getImpl(algorithm, "TrustManagerFactory", provider); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/io/Console.java --- a/src/java.base/share/classes/java/io/Console.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/io/Console.java Thu Dec 13 11:51:06 2018 -0800 @@ -247,7 +247,7 @@ String line = null; synchronized (writeLock) { synchronized(readLock) { - if (fmt.length() != 0) + if (!fmt.isEmpty()) pw.format(fmt, args); try { char[] ca = readline(false); @@ -319,7 +319,7 @@ } IOError ioe = null; try { - if (fmt.length() != 0) + if (!fmt.isEmpty()) pw.format(fmt, args); passwd = readline(true); } catch (IOException x) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/ClassLoader.java --- a/src/java.base/share/classes/java/lang/ClassLoader.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/ClassLoader.java Thu Dec 13 11:51:06 2018 -0800 @@ -1119,7 +1119,7 @@ // true if the name is null or has the potential to be a valid binary name private boolean checkName(String name) { - if ((name == null) || (name.length() == 0)) + if ((name == null) || (name.isEmpty())) return true; if ((name.indexOf('/') != -1) || (name.charAt(0) == '[')) return false; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/Double.java --- a/src/java.base/share/classes/java/lang/Double.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/Double.java Thu Dec 13 11:51:06 2018 -0800 @@ -1077,8 +1077,8 @@ } /** - * Returns a nominal descriptor for this instance, which is the instance - * itself. + * Returns an {@link Optional} containing the nominal descriptor for this + * instance, which is the instance itself. * * @return an {@link Optional} describing the {@linkplain Double} instance * @since 12 diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/Float.java --- a/src/java.base/share/classes/java/lang/Float.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/Float.java Thu Dec 13 11:51:06 2018 -0800 @@ -989,8 +989,8 @@ } /** - * Returns a nominal descriptor for this instance, which is the instance - * itself. + * Returns an {@link Optional} containing the nominal descriptor for this + * instance, which is the instance itself. * * @return an {@link Optional} describing the {@linkplain Float} instance * @since 12 diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/Integer.java --- a/src/java.base/share/classes/java/lang/Integer.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/Integer.java Thu Dec 13 11:51:06 2018 -0800 @@ -1409,7 +1409,7 @@ boolean negative = false; Integer result; - if (nm.length() == 0) + if (nm.isEmpty()) throw new NumberFormatException("Zero length string"); char firstChar = nm.charAt(0); // Handle sign, if present @@ -1838,8 +1838,8 @@ } /** - * Returns a nominal descriptor for this instance, which is the instance - * itself. + * Returns an {@link Optional} containing the nominal descriptor for this + * instance, which is the instance itself. * * @return an {@link Optional} describing the {@linkplain Integer} instance * @since 12 diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/Long.java --- a/src/java.base/share/classes/java/lang/Long.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/Long.java Thu Dec 13 11:51:06 2018 -0800 @@ -1248,7 +1248,7 @@ boolean negative = false; Long result; - if (nm.length() == 0) + if (nm.isEmpty()) throw new NumberFormatException("Zero length string"); char firstChar = nm.charAt(0); // Handle sign, if present @@ -1967,8 +1967,8 @@ } /** - * Returns a nominal descriptor for this instance, which is the instance - * itself. + * Returns an {@link Optional} containing the nominal descriptor for this + * instance, which is the instance itself. * * @return an {@link Optional} describing the {@linkplain Long} instance * @since 12 diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/Package.java --- a/src/java.base/share/classes/java/lang/Package.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/Package.java Thu Dec 13 11:51:06 2018 -0800 @@ -397,11 +397,11 @@ public String toString() { String spec = versionInfo.specTitle; String ver = versionInfo.specVersion; - if (spec != null && spec.length() > 0) + if (spec != null && !spec.isEmpty()) spec = ", " + spec; else spec = ""; - if (ver != null && ver.length() > 0) + if (ver != null && !ver.isEmpty()) ver = ", version " + ver; else ver = ""; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/Runtime.java --- a/src/java.base/share/classes/java/lang/Runtime.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/Runtime.java Thu Dec 13 11:51:06 2018 -0800 @@ -403,7 +403,7 @@ */ public Process exec(String command, String[] envp, File dir) throws IOException { - if (command.length() == 0) + if (command.isEmpty()) throw new IllegalArgumentException("Empty command"); StringTokenizer st = new StringTokenizer(command); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/String.java --- a/src/java.base/share/classes/java/lang/String.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/String.java Thu Dec 13 11:51:06 2018 -0800 @@ -664,7 +664,7 @@ * object. */ public int length() { - return value.length >> coder(); + return isLatin1() ? value.length : value.length >> UTF16; } /** @@ -1943,8 +1943,7 @@ * characters followed by the string argument's characters. */ public String concat(String str) { - int olen = str.length(); - if (olen == 0) { + if (str.isEmpty()) { return this; } if (coder() == str.coder()) { @@ -1956,6 +1955,7 @@ return new String(buf, coder); } int len = length(); + int olen = str.length(); byte[] buf = StringUTF16.newBytesFor(len + olen); getBytes(buf, 0, UTF16); str.getBytes(buf, len, UTF16); @@ -2316,7 +2316,7 @@ // Construct result int resultSize = list.size(); if (limit == 0) { - while (resultSize > 0 && list.get(resultSize - 1).length() == 0) { + while (resultSize > 0 && list.get(resultSize - 1).isEmpty()) { resultSize--; } } @@ -3545,8 +3545,8 @@ } /** - * Returns a nominal descriptor for this instance, which is the instance - * itself. + * Returns an {@link Optional} containing the nominal descriptor for this + * instance, which is the instance itself. * * @return an {@link Optional} describing the {@linkplain String} instance * @since 12 diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/VersionProps.java.template --- a/src/java.base/share/classes/java/lang/VersionProps.java.template Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/VersionProps.java.template Thu Dec 13 11:51:06 2018 -0800 @@ -73,7 +73,7 @@ "@@VENDOR_VERSION_STRING@@"; private static final String vendor_version = - (VENDOR_VERSION_STRING.length() > 0 + (!VENDOR_VERSION_STRING.isEmpty() ? " " + VENDOR_VERSION_STRING : ""); private static final String VENDOR = @@ -95,7 +95,7 @@ props.put("java.version.date", java_version_date); props.put("java.runtime.version", java_runtime_version); props.put("java.runtime.name", java_runtime_name); - if (VENDOR_VERSION_STRING.length() > 0) + if (!VENDOR_VERSION_STRING.isEmpty()) props.put("java.vendor.version", VENDOR_VERSION_STRING); props.put("java.class.version", CLASSFILE_MAJOR_MINOR); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/constant/ClassDesc.java --- a/src/java.base/share/classes/java/lang/constant/ClassDesc.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/constant/ClassDesc.java Thu Dec 13 11:51:06 2018 -0800 @@ -112,13 +112,13 @@ * * A field type descriptor string for a non-array type is either * a one-letter code corresponding to a primitive type - * ({@code J,I,C,S,B,D,F,Z,V}), or the letter {@code L}, followed - * by the fully qualified binary name of a class, followed by {@code ;}. - * A field type descriptor for an array type is the character {@code [} + * ({@code "J", "I", "C", "S", "B", "D", "F", "Z", "V"}), or the letter {@code "L"}, followed + * by the fully qualified binary name of a class, followed by {@code ";"}. + * A field type descriptor for an array type is the character {@code "["} * followed by the field descriptor for the component type. Examples of - * valid type descriptor strings include {@code Ljava/lang/String;}, {@code I}, - * {@code [I}, {@code V}, {@code [Ljava/lang/String;}, etc. - * for more detail. + * valid type descriptor strings include {@code "Ljava/lang/String;"}, {@code "I"}, + * {@code "[I"}, {@code "V"}, {@code "[Ljava/lang/String;"}, etc. + * See JVMS 4.3.2 ("Field Descriptors") for more detail. * * @param descriptor a field descriptor string * @return a {@linkplain ClassDesc} describing the desired class @@ -126,9 +126,15 @@ * @throws IllegalArgumentException if the name string is not in the * correct format * @jvms 4.3.2 Field Descriptors + * @jvms 4.4.1 The CONSTANT_Class_info Structure */ static ClassDesc ofDescriptor(String descriptor) { requireNonNull(descriptor); + int depth = ConstantUtils.arrayDepth(descriptor); + if (depth > ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS) { + throw new IllegalArgumentException(String.format("Cannot create an array type descriptor with more than %d dimensions", + ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS)); + } return (descriptor.length() == 1) ? new PrimitiveClassDescImpl(descriptor) : new ReferenceClassDescImpl(descriptor); @@ -139,8 +145,15 @@ * is described by this {@linkplain ClassDesc}. * * @return a {@linkplain ClassDesc} describing the array type + * @throws IllegalStateException if the resulting {@linkplain ClassDesc} would have an array rank of greater than 255 + * @jvms 4.4.1 The CONSTANT_Class_info Structure */ default ClassDesc arrayType() { + int depth = ConstantUtils.arrayDepth(descriptorString()); + if (depth >= ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS) { + throw new IllegalStateException(String.format("Cannot create an array type descriptor with more than %d dimensions", + ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS)); + } return arrayType(1); } @@ -150,11 +163,14 @@ * * @param rank the rank of the array * @return a {@linkplain ClassDesc} describing the array type - * @throws IllegalArgumentException if the rank is zero or negative + * @throws IllegalArgumentException if the rank is less than zero or if the rank of the resulting array type is + * greater than 255 + * @jvms 4.4.1 The CONSTANT_Class_info Structure */ default ClassDesc arrayType(int rank) { - if (rank <= 0) - throw new IllegalArgumentException("rank: " + rank); + int currentDepth = ConstantUtils.arrayDepth(descriptorString()); + if (rank <= 0 || currentDepth + rank > ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS) + throw new IllegalArgumentException("rank: " + currentDepth + rank); return ClassDesc.ofDescriptor("[".repeat(rank) + descriptorString()); } @@ -162,6 +178,12 @@ * Returns a {@linkplain ClassDesc} for a nested class of the class or * interface type described by this {@linkplain ClassDesc}. * + * @apiNote + * + * Example: If descriptor {@code d} describes the class {@code java.util.Map}, a + * descriptor for the class {@code java.util.Map.Entry} could be obtained + * by {@code d.nested("Entry")}. + * * @param nestedName the unqualified name of the nested class * @return a {@linkplain ClassDesc} describing the nested class * @throws NullPointerException if any argument is {@code null} diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/constant/Constable.java --- a/src/java.base/share/classes/java/lang/constant/Constable.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/constant/Constable.java Thu Dec 13 11:51:06 2018 -0800 @@ -65,8 +65,9 @@ */ public interface Constable { /** - * Returns a nominal descriptor for this instance, if one can be - * constructed, or an empty {@link Optional} if one cannot be constructed. + * Returns an {@link Optional} containing the nominal descriptor for this + * instance, if one can be constructed, or an empty {@link Optional} + * if one cannot be constructed. * * @return An {@link Optional} containing the resulting nominal descriptor, * or an empty {@link Optional} if one cannot be constructed. diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/constant/ConstantUtils.java --- a/src/java.base/share/classes/java/lang/constant/ConstantUtils.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/constant/ConstantUtils.java Thu Dec 13 11:51:06 2018 -0800 @@ -37,6 +37,7 @@ /** an empty constant descriptor */ public static final ConstantDesc[] EMPTY_CONSTANTDESC = new ConstantDesc[0]; static final Constable[] EMPTY_CONSTABLE = new Constable[0]; + static final int MAX_ARRAY_TYPE_DESC_DIMENSIONS = 255; private static final Set pointyNames = Set.of("", ""); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/constant/package-info.java --- a/src/java.base/share/classes/java/lang/constant/package-info.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/constant/package-info.java Thu Dec 13 11:51:06 2018 -0800 @@ -49,7 +49,7 @@ * storing the value in a constant pool entry, or reconstituting the value given * a class loading context. Every {@link java.lang.constant.ConstantDesc} * knows how to resolve itself -- compute the value that it describes -- - * via {@link java.lang.constant.ConstantDesc#resolveConstantDesc(java.lang.invoke.MethodHandles.Lookup)}. + * via {@link java.lang.constant.ConstantDesc#resolveConstantDesc(java.lang.invoke.MethodHandles.Lookup) ConstantDesc.resolveConstantDesc}. * This allows an API which accepts {@link java.lang.constant.ConstantDesc} * objects to evaluate them reflectively, provided that the classes and methods * referenced in their nominal description are present and accessible. @@ -68,7 +68,7 @@ * When a bytecode-reading API encounters a constant pool entry, it can * convert it to the appropriate type of nominal descriptor. For dynamic * constants, bytecode-reading APIs may wish to use the factory - * {@link java.lang.constant.DynamicConstantDesc#ofCanonical(DirectMethodHandleDesc, java.lang.String, ClassDesc, ConstantDesc[])}, + * {@link java.lang.constant.DynamicConstantDesc#ofCanonical(DirectMethodHandleDesc, java.lang.String, ClassDesc, ConstantDesc[]) DynamicConstantDesc.ofCanonical}, * which will inspect the bootstrap and, for well-known bootstraps, return * a more specific subtype of {@link java.lang.constant.DynamicConstantDesc}, such as * {@link java.lang.Enum.EnumDesc}. diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java --- a/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java Thu Dec 13 11:51:06 2018 -0800 @@ -103,7 +103,7 @@ if (type != Class.class) { throw new IllegalArgumentException(); } - if (name.length() == 0 || name.length() > 1) { + if (name.length() != 1) { throw new IllegalArgumentException(String.format("not primitive: %s", name)); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/invoke/MethodHandles.java --- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Thu Dec 13 11:51:06 2018 -0800 @@ -201,7 +201,7 @@ throw new IllegalAccessException(callerModule + " does not read " + targetModule); if (targetModule.isNamed()) { String pn = targetClass.getPackageName(); - assert pn.length() > 0 : "unnamed package cannot be in named module"; + assert !pn.isEmpty() : "unnamed package cannot be in named module"; if (!targetModule.isOpen(pn, callerModule)) throw new IllegalAccessException(targetModule + " does not open " + pn + " to " + callerModule); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/invoke/ProxyClassesDumper.java --- a/src/java.base/share/classes/java/lang/invoke/ProxyClassesDumper.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/invoke/ProxyClassesDumper.java Thu Dec 13 11:51:06 2018 -0800 @@ -62,7 +62,7 @@ } try { path = path.trim(); - final Path dir = Path.of(path.length() == 0 ? "." : path); + final Path dir = Path.of(path.isEmpty() ? "." : path); AccessController.doPrivileged(new PrivilegedAction<>() { @Override public Void run() { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/invoke/TypeDescriptor.java --- a/src/java.base/share/classes/java/lang/invoke/TypeDescriptor.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/invoke/TypeDescriptor.java Thu Dec 13 11:51:06 2018 -0800 @@ -61,7 +61,8 @@ boolean isArray(); /** - * Does this field descriptor describe a primitive type? + * Does this field descriptor describe a primitive type (including void.) + * * @return whether this field descriptor describes a primitive type */ boolean isPrimitive(); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/lang/invoke/VarHandle.java --- a/src/java.base/share/classes/java/lang/invoke/VarHandle.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/lang/invoke/VarHandle.java Thu Dec 13 11:51:06 2018 -0800 @@ -1864,6 +1864,16 @@ } } + /** + * Compare this {@linkplain VarHandle} with another object for equality. + * Two {@linkplain VarHandle}s are considered equal if they both describe the + * same instance field, both describe the same static field, both describe + * array elements for arrays with the same component type, or both describe + * the same component of an off-heap structure. + * + * @param o the other object + * @return Whether this {@linkplain VarHandle} is equal to the other object + */ @Override public final boolean equals(Object o) { if (this == o) return true; @@ -1883,6 +1893,12 @@ abstract int internalHashCode(); + /** + * Returns a compact textual description of this {@linkplain VarHandle}, + * including the type of variable described, and a description of its coordinates. + * + * @return A compact textual description of this {@linkplain VarHandle} + */ @Override public final String toString() { return String.format("VarHandle[varType=%s, coord=%s]", @@ -2272,6 +2288,14 @@ } } + /** + * Returns a compact textual description of this constant description. + * For a field {@linkplain VarHandle}, includes the owner, name, and type + * of the field, and whether it is static; for an array {@linkplain VarHandle}, + * the name of the component type. + * + * @return A compact textual description of this descriptor + */ @Override public String toString() { switch (kind) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/net/HttpCookie.java --- a/src/java.base/share/classes/java/net/HttpCookie.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/net/HttpCookie.java Thu Dec 13 11:51:06 2018 -0800 @@ -149,7 +149,7 @@ */ HttpCookie(String name, String value, String header, long creationTime) { name = name.trim(); - if (name.length() == 0 || !isToken(name) || name.charAt(0) == '$') { + if (name.isEmpty() || !isToken(name) || name.charAt(0) == '$') { throw new IllegalArgumentException("Illegal cookie name"); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/net/Inet6Address.java --- a/src/java.base/share/classes/java/net/Inet6Address.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/net/Inet6Address.java Thu Dec 13 11:51:06 2018 -0800 @@ -433,7 +433,7 @@ NetworkInterface nif) throws UnknownHostException { - if (host != null && host.length() > 0 && host.charAt(0) == '[') { + if (host != null && !host.isEmpty() && host.charAt(0) == '[') { if (host.charAt(host.length()-1) == ']') { host = host.substring(1, host.length() -1); } @@ -466,7 +466,7 @@ int scope_id) throws UnknownHostException { - if (host != null && host.length() > 0 && host.charAt(0) == '[') { + if (host != null && !host.isEmpty() && host.charAt(0) == '[') { if (host.charAt(host.length()-1) == ']') { host = host.substring(1, host.length() -1); } @@ -601,7 +601,7 @@ boolean scope_ifname_set = gf.get("scope_ifname_set", false); String ifname = (String)gf.get("ifname", null); - if (ifname != null && !"".equals (ifname)) { + if (ifname != null && !ifname.isEmpty()) { try { scope_ifname = NetworkInterface.getByName(ifname); if (scope_ifname == null) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/net/InetAddress.java --- a/src/java.base/share/classes/java/net/InetAddress.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/net/InetAddress.java Thu Dec 13 11:51:06 2018 -0800 @@ -1187,7 +1187,7 @@ */ public static InetAddress getByAddress(String host, byte[] addr) throws UnknownHostException { - if (host != null && host.length() > 0 && host.charAt(0) == '[') { + if (host != null && !host.isEmpty() && host.charAt(0) == '[') { if (host.charAt(host.length()-1) == ']') { host = host.substring(1, host.length() -1); } @@ -1301,7 +1301,7 @@ private static InetAddress[] getAllByName(String host, InetAddress reqAddr) throws UnknownHostException { - if (host == null || host.length() == 0) { + if (host == null || host.isEmpty()) { InetAddress[] ret = new InetAddress[1]; ret[0] = impl.loopbackAddress(); return ret; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/net/SocketPermission.java --- a/src/java.base/share/classes/java/net/SocketPermission.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/net/SocketPermission.java Thu Dec 13 11:51:06 2018 -0800 @@ -460,7 +460,7 @@ } return; } else { - if (host.length() > 0) { + if (!host.isEmpty()) { // see if we are being initialized with an IP address. char ch = host.charAt(0); if (ch == ':' || Character.digit(ch, 16) != -1) { @@ -705,8 +705,7 @@ .orElse(b); } - return cdomain.length() != 0 && hdomain.length() != 0 - && cdomain.equals(hdomain); + return !cdomain.isEmpty() && !hdomain.isEmpty() && cdomain.equals(hdomain); } private boolean authorized(String cname, byte[] addr) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/net/URI.java --- a/src/java.base/share/classes/java/net/URI.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/net/URI.java Thu Dec 13 11:51:06 2018 -0800 @@ -1959,10 +1959,8 @@ throws URISyntaxException { if (scheme != null) { - if ((path != null) - && ((path.length() > 0) && (path.charAt(0) != '/'))) - throw new URISyntaxException(s, - "Relative path in absolute URI"); + if (path != null && !path.isEmpty() && path.charAt(0) != '/') + throw new URISyntaxException(s, "Relative path in absolute URI"); } } @@ -2163,7 +2161,7 @@ ru.port = base.port; String cp = (child.path == null) ? "" : child.path; - if ((cp.length() > 0) && (cp.charAt(0) == '/')) { + if (!cp.isEmpty() && cp.charAt(0) == '/') { // 5.2 (5): Child path is absolute ru.path = child.path; } else { @@ -2187,7 +2185,7 @@ // o.w., return a new URI containing the normalized path. // private static URI normalize(URI u) { - if (u.isOpaque() || (u.path == null) || (u.path.length() == 0)) + if (u.isOpaque() || u.path == null || u.path.isEmpty()) return u; String np = normalize(u.path); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/net/URL.java --- a/src/java.base/share/classes/java/net/URL.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/net/URL.java Thu Dec 13 11:51:06 2018 -0800 @@ -1513,7 +1513,7 @@ String ref = (String)gf.get("ref", null); int hashCode = gf.get("hashCode", -1); if (authority == null - && ((host != null && host.length() > 0) || port != -1)) { + && ((host != null && !host.isEmpty()) || port != -1)) { if (host == null) host = ""; authority = (port == -1) ? host : host + ":" + port; @@ -1560,7 +1560,7 @@ // Construct authority part if (authority == null - && ((host != null && host.length() > 0) || port != -1)) { + && ((host != null && !host.isEmpty()) || port != -1)) { if (host == null) host = ""; authority = (port == -1) ? host : host + ":" + port; @@ -1716,7 +1716,7 @@ // pre-compute length of StringBuffer int len = protocol.length() + 1; - if (authority != null && authority.length() > 0) + if (authority != null && !authority.isEmpty()) len += 2 + authority.length(); if (file != null) { len += file.length(); @@ -1726,7 +1726,7 @@ StringBuilder result = new StringBuilder(len); result.append(protocol); result.append(":"); - if (authority != null && authority.length() > 0) { + if (authority != null && !authority.isEmpty()) { result.append("//"); result.append(authority); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/net/URLClassLoader.java --- a/src/java.base/share/classes/java/net/URLClassLoader.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/net/URLClassLoader.java Thu Dec 13 11:51:06 2018 -0800 @@ -743,7 +743,7 @@ locUrl = ((JarURLConnection)urlConnection).getJarFileURL(); } String host = locUrl.getHost(); - if (host != null && (host.length() > 0)) + if (host != null && !host.isEmpty()) p = new SocketPermission(host, SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/net/URLDecoder.java --- a/src/java.base/share/classes/java/net/URLDecoder.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/net/URLDecoder.java Thu Dec 13 11:51:06 2018 -0800 @@ -133,7 +133,7 @@ * @since 1.4 */ public static String decode(String s, String enc) throws UnsupportedEncodingException { - if (enc.length() == 0) { + if (enc.isEmpty()) { throw new UnsupportedEncodingException ("URLDecoder: empty string enc parameter"); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/net/URLPermission.java --- a/src/java.base/share/classes/java/net/URLPermission.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/net/URLPermission.java Thu Dec 13 11:51:06 2018 -0800 @@ -409,7 +409,7 @@ char c = methods.charAt(i); if (c == ',') { String s = b.toString(); - if (s.length() > 0) + if (!s.isEmpty()) l.add(s); b = new StringBuilder(); } else if (c == ' ' || c == '\t') { @@ -423,7 +423,7 @@ } } String s = b.toString(); - if (s.length() > 0) + if (!s.isEmpty()) l.add(s); return l; } @@ -448,7 +448,7 @@ b.append(c); } else if (c == ',') { String s = b.toString(); - if (s.length() > 0) + if (!s.isEmpty()) l.add(s); b = new StringBuilder(); capitalizeNext = true; @@ -458,7 +458,7 @@ } } String s = b.toString(); - if (s.length() > 0) + if (!s.isEmpty()) l.add(s); return l; } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/net/URLStreamHandler.java --- a/src/java.base/share/classes/java/net/URLStreamHandler.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/net/URLStreamHandler.java Thu Dec 13 11:51:06 2018 -0800 @@ -235,7 +235,7 @@ start = i; // If the authority is defined then the path is defined by the // spec only; See RFC 2396 Section 5.2.4. - if (authority != null && authority.length() > 0) + if (authority != null && !authority.isEmpty()) path = ""; } @@ -247,7 +247,7 @@ if (start < limit) { if (spec.charAt(start) == '/') { path = spec.substring(start, limit); - } else if (path != null && path.length() > 0) { + } else if (path != null && !path.isEmpty()) { isRelPath = true; int ind = path.lastIndexOf('/'); String separator = ""; @@ -483,11 +483,11 @@ String s; return u.getProtocol() + ':' - + (((s = u.getAuthority()) != null && s.length() > 0) + + ((s = u.getAuthority()) != null && !s.isEmpty() ? "//" + s : "") - + (((s = u.getPath()) != null) ? s : "") - + (((s = u.getQuery()) != null) ? '?' + s : "") - + (((s = u.getRef()) != null) ? '#' + s : ""); + + ((s = u.getPath()) != null ? s : "") + + ((s = u.getQuery()) != null ? '?' + s : "") + + ((s = u.getRef()) != null ? '#' + s : ""); } /** @@ -544,7 +544,7 @@ */ String authority = null; String userInfo = null; - if (host != null && host.length() != 0) { + if (host != null && !host.isEmpty()) { authority = (port == -1) ? host : host + ":" + port; int at = host.lastIndexOf('@'); if (at != -1) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/nio/file/LinkPermission.java --- a/src/java.base/share/classes/java/nio/file/LinkPermission.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/nio/file/LinkPermission.java Thu Dec 13 11:51:06 2018 -0800 @@ -104,7 +104,7 @@ public LinkPermission(String name, String actions) { super(name); checkName(name); - if (actions != null && actions.length() > 0) { + if (actions != null && !actions.isEmpty()) { throw new IllegalArgumentException("actions: " + actions); } } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java --- a/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/security/AlgorithmParameterGenerator.java Thu Dec 13 11:51:06 2018 -0800 @@ -228,7 +228,7 @@ throws NoSuchAlgorithmException, NoSuchProviderException { Objects.requireNonNull(algorithm, "null algorithm name"); - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = Security.getImpl(algorithm, "AlgorithmParameterGenerator", diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/security/AlgorithmParameters.java --- a/src/java.base/share/classes/java/security/AlgorithmParameters.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/security/AlgorithmParameters.java Thu Dec 13 11:51:06 2018 -0800 @@ -209,7 +209,7 @@ throws NoSuchAlgorithmException, NoSuchProviderException { Objects.requireNonNull(algorithm, "null algorithm name"); - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters", provider); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/security/KeyStore.java --- a/src/java.base/share/classes/java/security/KeyStore.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/security/KeyStore.java Thu Dec 13 11:51:06 2018 -0800 @@ -913,7 +913,7 @@ throws KeyStoreException, NoSuchProviderException { Objects.requireNonNull(type, "null type name"); - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); try { Object[] objs = Security.getImpl(type, "KeyStore", provider); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/security/MessageDigest.java --- a/src/java.base/share/classes/java/security/MessageDigest.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/security/MessageDigest.java Thu Dec 13 11:51:06 2018 -0800 @@ -237,7 +237,7 @@ throws NoSuchAlgorithmException, NoSuchProviderException { Objects.requireNonNull(algorithm, "null algorithm name"); - if (provider == null || provider.length() == 0) + if (provider == null || provider.isEmpty()) throw new IllegalArgumentException("missing provider"); Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider); if (objs[0] instanceof MessageDigest) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/security/Permission.java --- a/src/java.base/share/classes/java/security/Permission.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/security/Permission.java Thu Dec 13 11:51:06 2018 -0800 @@ -222,7 +222,7 @@ */ public String toString() { String actions = getActions(); - if ((actions == null) || (actions.length() == 0)) { // OPTIONAL + if (actions == null || actions.isEmpty()) { // OPTIONAL return "(\"" + getClass().getName() + "\" \"" + name + "\")"; } else { return "(\"" + getClass().getName() + "\" \"" + name + diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/security/Policy.java --- a/src/java.base/share/classes/java/security/Policy.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/security/Policy.java Thu Dec 13 11:51:06 2018 -0800 @@ -456,7 +456,7 @@ throws NoSuchProviderException, NoSuchAlgorithmException { Objects.requireNonNull(type, "null type name"); - if (provider == null || provider.length() == 0) { + if (provider == null || provider.isEmpty()) { throw new IllegalArgumentException("missing provider"); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/security/SecureRandom.java --- a/src/java.base/share/classes/java/security/SecureRandom.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/security/SecureRandom.java Thu Dec 13 11:51:06 2018 -0800 @@ -942,7 +942,7 @@ } }); - if ((property == null) || (property.length() == 0)) { + if (property == null || property.isEmpty()) { throw new NoSuchAlgorithmException( "Null/empty securerandom.strongAlgorithms Security Property"); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/security/Security.java --- a/src/java.base/share/classes/java/security/Security.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/security/Security.java Thu Dec 13 11:51:06 2018 -0800 @@ -649,7 +649,7 @@ } } - if ((candidates == null) || (candidates.isEmpty())) + if (candidates == null || candidates.isEmpty()) return null; Object[] candidatesArray = candidates.toArray(); @@ -1005,11 +1005,11 @@ String algName = null; String attrName = null; - if (filterValue.length() == 0) { + if (filterValue.isEmpty()) { // The filterValue is an empty string. So the filterKey // should be in the format of .. algName = filterKey.substring(algIndex + 1).trim(); - if (algName.length() == 0) { + if (algName.isEmpty()) { // There must be a algorithm or type name. throw new InvalidParameterException("Invalid filter"); } @@ -1024,7 +1024,7 @@ throw new InvalidParameterException("Invalid filter"); } else { attrName = filterKey.substring(attrIndex + 1).trim(); - if (attrName.length() == 0) { + if (attrName.isEmpty()) { // There is no attribute name in the filter. throw new InvalidParameterException("Invalid filter"); } @@ -1070,7 +1070,7 @@ **/ public static Set getAlgorithms(String serviceName) { - if ((serviceName == null) || (serviceName.length() == 0) || + if ((serviceName == null) || (serviceName.isEmpty()) || (serviceName.endsWith("."))) { return Collections.emptySet(); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/security/Signature.java --- a/src/java.base/share/classes/java/security/Signature.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/security/Signature.java Thu Dec 13 11:51:06 2018 -0800 @@ -360,7 +360,7 @@ Objects.requireNonNull(algorithm, "null algorithm name"); if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) { // exception compatibility with existing code - if ((provider == null) || (provider.length() == 0)) { + if (provider == null || provider.isEmpty()) { throw new IllegalArgumentException("missing provider"); } Provider p = Security.getProvider(provider); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/security/cert/TrustAnchor.java --- a/src/java.base/share/classes/java/security/cert/TrustAnchor.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/security/cert/TrustAnchor.java Thu Dec 13 11:51:06 2018 -0800 @@ -210,7 +210,7 @@ if (caName == null) throw new NullPointerException("the caName parameter must be " + "non-null"); - if (caName.length() == 0) + if (caName.isEmpty()) throw new IllegalArgumentException("the caName " + "parameter must be a non-empty String"); // check if caName is formatted correctly diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/text/AttributedString.java --- a/src/java.base/share/classes/java/text/AttributedString.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/text/AttributedString.java Thu Dec 13 11:51:06 2018 -0800 @@ -85,7 +85,7 @@ text = buffer.toString(); - if (text.length() > 0) { + if (!text.isEmpty()) { // Determine the runs, creating a new run when the attributes // differ. int offset = 0; @@ -144,7 +144,7 @@ } this.text = text; - if (text.length() == 0) { + if (text.isEmpty()) { if (attributes.isEmpty()) return; throw new IllegalArgumentException("Can't add attribute to 0-length text"); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/text/CollationElementIterator.java --- a/src/java.base/share/classes/java/text/CollationElementIterator.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/text/CollationElementIterator.java Thu Dec 13 11:51:06 2018 -0800 @@ -125,7 +125,7 @@ CollationElementIterator(String sourceText, RuleBasedCollator owner) { this.owner = owner; ordering = owner.getTables(); - if ( sourceText.length() != 0 ) { + if (!sourceText.isEmpty()) { NormalizerBase.Mode mode = CollatorUtilities.toNormalizerMode(owner.getDecomposition()); text = new NormalizerBase(sourceText, mode); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/text/CompactNumberFormat.java --- a/src/java.base/share/classes/java/text/CompactNumberFormat.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/text/CompactNumberFormat.java Thu Dec 13 11:51:06 2018 -0800 @@ -799,7 +799,7 @@ */ private void append(StringBuffer result, String string, FieldDelegate delegate, List positions) { - if (string.length() > 0) { + if (!string.isEmpty()) { int start = result.length(); result.append(string); for (int counter = 0; counter < positions.size(); counter++) { @@ -1213,7 +1213,7 @@ } // If no 0s are specified in a non empty pattern, it is invalid - if (pattern.length() != 0 && zeros.isEmpty()) { + if (!pattern.isEmpty() && zeros.isEmpty()) { throw new IllegalArgumentException("Invalid pattern" + " [" + pattern + "]: all patterns must include digit" + " placement 0s"); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/text/DecimalFormat.java --- a/src/java.base/share/classes/java/text/DecimalFormat.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/text/DecimalFormat.java Thu Dec 13 11:51:06 2018 -0800 @@ -1113,11 +1113,9 @@ // Records the need for adding prefix or suffix fastPathData.positiveAffixesRequired - = (positivePrefix.length() != 0) - || (positiveSuffix.length() != 0); + = !positivePrefix.isEmpty() || !positiveSuffix.isEmpty(); fastPathData.negativeAffixesRequired - = (negativePrefix.length() != 0) - || (negativeSuffix.length() != 0); + = !negativePrefix.isEmpty() || !negativeSuffix.isEmpty(); // Creates a cached char container for result, with max possible size. int maxNbIntegralDigits = 10; @@ -2062,7 +2060,7 @@ Format.Field signAttribute) { int start = result.length(); - if (string.length() > 0) { + if (!string.isEmpty()) { result.append(string); for (int counter = 0, max = positions.length; counter < max; counter++) { @@ -3042,7 +3040,7 @@ } else { string = symbols.getCurrencySymbol(); } - if (string.length() > 0) { + if (!string.isEmpty()) { if (positions == null) { positions = new ArrayList<>(2); } @@ -3613,7 +3611,7 @@ } } - if (pattern.length() == 0) { + if (pattern.isEmpty()) { posPrefixPattern = posSuffixPattern = ""; setMinimumIntegerDigits(0); setMaximumIntegerDigits(MAXIMUM_INTEGER_DIGITS); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/text/DecimalFormatSymbols.java --- a/src/java.base/share/classes/java/text/DecimalFormatSymbols.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/text/DecimalFormatSymbols.java Thu Dec 13 11:51:06 2018 -0800 @@ -663,7 +663,7 @@ // Check for empty country string separately because it's a valid // country ID for Locale (and used for the C locale), but not a valid // ISO 3166 country code, and exceptions are expensive. - if (locale.getCountry().length() > 0) { + if (!locale.getCountry().isEmpty()) { try { currency = Currency.getInstance(locale); } catch (IllegalArgumentException e) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/text/MergeCollation.java --- a/src/java.base/share/classes/java/text/MergeCollation.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/text/MergeCollation.java Thu Dec 13 11:51:06 2018 -0800 @@ -92,7 +92,7 @@ int i; for (i = 0; i < patterns.size(); ++i) { PatternEntry entry = patterns.get(i); - if (entry.extension.length() != 0) { + if (!entry.extension.isEmpty()) { if (extList == null) extList = new ArrayList<>(); extList.add(entry); @@ -122,7 +122,7 @@ private final PatternEntry findLastWithNoExtension(int i) { for (--i;i >= 0; --i) { PatternEntry entry = patterns.get(i); - if (entry.extension.length() == 0) { + if (entry.extension.isEmpty()) { return entry; } } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/text/MessageFormat.java --- a/src/java.base/share/classes/java/text/MessageFormat.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/text/MessageFormat.java Thu Dec 13 11:51:06 2018 -0800 @@ -1330,7 +1330,7 @@ } arg = null; } - if (arg != null && arg.length() > 0) { + if (arg != null && !arg.isEmpty()) { result.append(arg); characterIterators.add( createAttributedCharacterIterator( @@ -1476,7 +1476,7 @@ // now get the format Format newFormat = null; - if (segments[SEG_TYPE].length() != 0) { + if (!segments[SEG_TYPE].isEmpty()) { int type = findKeyword(segments[SEG_TYPE], TYPE_KEYWORDS); switch (type) { case TYPE_NULL: diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/text/PatternEntry.java --- a/src/java.base/share/classes/java/text/PatternEntry.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/text/PatternEntry.java Thu Dec 13 11:51:06 2018 -0800 @@ -141,7 +141,7 @@ if (showWhiteSpace) toAddTo.append(' '); appendQuoted(chars,toAddTo); - if (showExtension && extension.length() != 0) { + if (showExtension && !extension.isEmpty()) { toAddTo.append('/'); appendQuoted(extension,toAddTo); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/text/RBTableBuilder.java --- a/src/java.base/share/classes/java/text/RBTableBuilder.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/text/RBTableBuilder.java Thu Dec 13 11:51:06 2018 -0800 @@ -75,13 +75,10 @@ * @exception ParseException If the rules format is incorrect. */ - public void build(String pattern, int decmp) throws ParseException - { - boolean isSource = true; - int i = 0; + public void build(String pattern, int decmp) throws ParseException { String expChars; String groupChars; - if (pattern.length() == 0) + if (pattern.isEmpty()) throw new ParseException("Build rules empty.", 0); // This array maps Unicode characters to their collation ordering @@ -119,8 +116,7 @@ int order = 0; // Now walk though each entry and add it to my own tables - for (i = 0; i < mPattern.getCount(); ++i) - { + for (int i = 0; i < mPattern.getCount(); ++i) { PatternEntry entry = mPattern.getItemAt(i); if (entry != null) { groupChars = entry.getChars(); @@ -140,7 +136,7 @@ order = increment(entry.getStrength(), order); expChars = entry.getExtension(); - if (expChars.length() != 0) { + if (!expChars.isEmpty()) { addExpandOrder(groupChars, expChars, order); } else if (groupChars.length() > 1) { char ch = groupChars.charAt(0); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/time/ZoneId.java --- a/src/java.base/share/classes/java/time/ZoneId.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/time/ZoneId.java Thu Dec 13 11:51:06 2018 -0800 @@ -372,7 +372,7 @@ public static ZoneId ofOffset(String prefix, ZoneOffset offset) { Objects.requireNonNull(prefix, "prefix"); Objects.requireNonNull(offset, "offset"); - if (prefix.length() == 0) { + if (prefix.isEmpty()) { return offset; } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java --- a/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Thu Dec 13 11:51:06 2018 -0800 @@ -1439,7 +1439,7 @@ */ public DateTimeFormatterBuilder appendLiteral(String literal) { Objects.requireNonNull(literal, "literal"); - if (literal.length() > 0) { + if (!literal.isEmpty()) { if (literal.length() == 1) { appendInternal(new CharLiteralPrinterParser(literal.charAt(0))); } else { @@ -1832,7 +1832,7 @@ throw new IllegalArgumentException("Pattern ends with an incomplete string literal: " + pattern); } String str = pattern.substring(start + 1, pos); - if (str.length() == 0) { + if (str.isEmpty()) { appendLiteral('\''); } else { appendLiteral(str.replace("''", "'")); @@ -4332,7 +4332,7 @@ this.key = k; this.value = v; this.child = child; - if (k.length() == 0){ + if (k.isEmpty()) { c0 = 0xffff; } else { c0 = key.charAt(0); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/util/Calendar.java --- a/src/java.base/share/classes/java/util/Calendar.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/util/Calendar.java Thu Dec 13 11:51:06 2018 -0800 @@ -2232,7 +2232,7 @@ if (strings != null) { Map names = new HashMap<>(); for (int i = 0; i < strings.length; i++) { - if (strings[i].length() == 0) { + if (strings[i].isEmpty()) { continue; } names.put(strings[i], i); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/util/Locale.java --- a/src/java.base/share/classes/java/util/Locale.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/util/Locale.java Thu Dec 13 11:51:06 2018 -0800 @@ -1396,11 +1396,11 @@ */ @Override public final String toString() { - boolean l = (baseLocale.getLanguage().length() != 0); - boolean s = (baseLocale.getScript().length() != 0); - boolean r = (baseLocale.getRegion().length() != 0); - boolean v = (baseLocale.getVariant().length() != 0); - boolean e = (localeExtensions != null && localeExtensions.getID().length() != 0); + boolean l = !baseLocale.getLanguage().isEmpty(); + boolean s = !baseLocale.getScript().isEmpty(); + boolean r = !baseLocale.getRegion().isEmpty(); + boolean v = !baseLocale.getVariant().isEmpty(); + boolean e = localeExtensions != null && !localeExtensions.getID().isEmpty(); StringBuilder result = new StringBuilder(baseLocale.getLanguage()); if (r || (l && (v || s || e))) { @@ -1504,18 +1504,18 @@ StringBuilder buf = new StringBuilder(); String subtag = tag.getLanguage(); - if (subtag.length() > 0) { + if (!subtag.isEmpty()) { buf.append(LanguageTag.canonicalizeLanguage(subtag)); } subtag = tag.getScript(); - if (subtag.length() > 0) { + if (!subtag.isEmpty()) { buf.append(LanguageTag.SEP); buf.append(LanguageTag.canonicalizeScript(subtag)); } subtag = tag.getRegion(); - if (subtag.length() > 0) { + if (!subtag.isEmpty()) { buf.append(LanguageTag.SEP); buf.append(LanguageTag.canonicalizeRegion(subtag)); } @@ -1534,7 +1534,7 @@ } subtag = tag.getPrivateuse(); - if (subtag.length() > 0) { + if (!subtag.isEmpty()) { if (buf.length() > 0) { buf.append(LanguageTag.SEP); } @@ -1684,7 +1684,7 @@ bldr.setLanguageTag(tag); BaseLocale base = bldr.getBaseLocale(); LocaleExtensions exts = bldr.getLocaleExtensions(); - if (exts == null && base.getVariant().length() > 0) { + if (exts == null && !base.getVariant().isEmpty()) { exts = getCompatibilityExtensions(base.getLanguage(), base.getScript(), base.getRegion(), base.getVariant()); } @@ -1917,7 +1917,7 @@ * @exception NullPointerException if inLocale is null */ public String getDisplayVariant(Locale inLocale) { - if (baseLocale.getVariant().length() == 0) + if (baseLocale.getVariant().isEmpty()) return ""; LocaleResources lr = LocaleProviderAdapter @@ -1998,14 +1998,14 @@ // The display name consists of a main name, followed by qualifiers. // Typically, the format is "MainName (Qualifier, Qualifier)" but this // depends on what pattern is stored in the display locale. - String mainName = null; - String[] qualifierNames = null; + String mainName; + String[] qualifierNames; // The main name is the language, or if there is no language, the script, // then if no script, the country. If there is no language/script/country // (an anomalous situation) then the display name is simply the variant's // display name. - if (languageName.length() == 0 && scriptName.length() == 0 && countryName.length() == 0) { + if (languageName.isEmpty() && scriptName.isEmpty() && countryName.isEmpty()) { if (variantNames.length == 0) { return ""; } else { @@ -2013,13 +2013,13 @@ } } ArrayList names = new ArrayList<>(4); - if (languageName.length() != 0) { + if (!languageName.isEmpty()) { names.add(languageName); } - if (scriptName.length() != 0) { + if (!scriptName.isEmpty()) { names.add(scriptName); } - if (countryName.length() != 0) { + if (!countryName.isEmpty()) { names.add(countryName); } if (variantNames.length != 0) { @@ -2309,7 +2309,7 @@ String variant = (String)fields.get("variant", ""); String extStr = (String)fields.get("extensions", ""); baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant); - if (extStr.length() > 0) { + if (!extStr.isEmpty()) { try { InternalLocaleBuilder bldr = new InternalLocaleBuilder(); bldr.setExtensions(extStr); @@ -2367,13 +2367,13 @@ LocaleExtensions extensions = null; // Special cases for backward compatibility support if (LocaleUtils.caseIgnoreMatch(language, "ja") - && script.length() == 0 + && script.isEmpty() && LocaleUtils.caseIgnoreMatch(country, "jp") && "JP".equals(variant)) { // ja_JP_JP -> u-ca-japanese (calendar = japanese) extensions = LocaleExtensions.CALENDAR_JAPANESE; } else if (LocaleUtils.caseIgnoreMatch(language, "th") - && script.length() == 0 + && script.isEmpty() && LocaleUtils.caseIgnoreMatch(country, "th") && "TH".equals(variant)) { // th_TH_TH -> u-nu-thai (numbersystem = thai) @@ -2806,7 +2806,7 @@ public Locale build() { BaseLocale baseloc = localeBuilder.getBaseLocale(); LocaleExtensions extensions = localeBuilder.getLocaleExtensions(); - if (extensions == null && baseloc.getVariant().length() > 0) { + if (extensions == null && !baseloc.getVariant().isEmpty()) { extensions = getCompatibilityExtensions(baseloc.getLanguage(), baseloc.getScript(), baseloc.getRegion(), baseloc.getVariant()); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/util/ResourceBundle.java --- a/src/java.base/share/classes/java/util/ResourceBundle.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/util/ResourceBundle.java Thu Dec 13 11:51:06 2018 -0800 @@ -771,8 +771,8 @@ @Override public String toString() { String l = locale.toString(); - if (l.length() == 0) { - if (locale.getVariant().length() != 0) { + if (l.isEmpty()) { + if (!locale.getVariant().isEmpty()) { l = "__" + locale.getVariant(); } else { l = "\"\""; @@ -2903,7 +2903,7 @@ List bokmalList = new LinkedList<>(); for (Locale l : tmpList) { bokmalList.add(l); - if (l.getLanguage().length() == 0) { + if (l.getLanguage().isEmpty()) { break; } bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(), @@ -2921,7 +2921,7 @@ } // Special handling for Chinese else if (language.equals("zh")) { - if (script.length() == 0 && region.length() > 0) { + if (script.isEmpty() && !region.isEmpty()) { // Supply script for users who want to use zh_Hans/zh_Hant // as bundle names (recommended for Java7+) switch (region) { @@ -2944,7 +2944,7 @@ private static List getDefaultList(String language, String script, String region, String variant) { List variants = null; - if (variant.length() > 0) { + if (!variant.isEmpty()) { variants = new LinkedList<>(); int idx = variant.length(); while (idx != -1) { @@ -2960,14 +2960,14 @@ list.add(Locale.getInstance(language, script, region, v, null)); } } - if (region.length() > 0) { + if (!region.isEmpty()) { list.add(Locale.getInstance(language, script, region, "", null)); } - if (script.length() > 0) { + if (!script.isEmpty()) { list.add(Locale.getInstance(language, script, "", "", null)); // Special handling for Chinese if (language.equals("zh")) { - if (region.length() == 0) { + if (region.isEmpty()) { // Supply region(country) for users who still package Chinese // bundles using old convension. switch (script) { @@ -2988,11 +2988,11 @@ list.add(Locale.getInstance(language, "", region, v, null)); } } - if (region.length() > 0) { + if (!region.isEmpty()) { list.add(Locale.getInstance(language, "", region, "", null)); } } - if (language.length() > 0) { + if (!language.isEmpty()) { list.add(Locale.getInstance(language, "", "", "", null)); } // Add root locale at the end diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/util/Scanner.java --- a/src/java.base/share/classes/java/util/Scanner.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/util/Scanner.java Thu Dec 13 11:51:06 2018 -0800 @@ -1297,16 +1297,16 @@ nanString = "\\Q" + dfs.getNaN() + "\\E"; infinityString = "\\Q" + dfs.getInfinity() + "\\E"; positivePrefix = df.getPositivePrefix(); - if (positivePrefix.length() > 0) + if (!positivePrefix.isEmpty()) positivePrefix = "\\Q" + positivePrefix + "\\E"; negativePrefix = df.getNegativePrefix(); - if (negativePrefix.length() > 0) + if (!negativePrefix.isEmpty()) negativePrefix = "\\Q" + negativePrefix + "\\E"; positiveSuffix = df.getPositiveSuffix(); - if (positiveSuffix.length() > 0) + if (!positiveSuffix.isEmpty()) positiveSuffix = "\\Q" + positiveSuffix + "\\E"; negativeSuffix = df.getNegativeSuffix(); - if (negativeSuffix.length() > 0) + if (!negativeSuffix.isEmpty()) negativeSuffix = "\\Q" + negativeSuffix + "\\E"; // Force rebuilding and recompilation of locale dependent diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/java/util/regex/Pattern.java --- a/src/java.base/share/classes/java/util/regex/Pattern.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/java/util/regex/Pattern.java Thu Dec 13 11:51:06 2018 -0800 @@ -1390,7 +1390,7 @@ localTCNCount = 0; // if length > 0, the Pattern is lazily compiled - if (pattern.length() == 0) { + if (pattern.isEmpty()) { root = new Start(lastAccept); matchRoot = lastAccept; compiled = true; @@ -1423,7 +1423,7 @@ localCount = 0; localTCNCount = 0; - if (pattern.length() > 0) { + if (!pattern.isEmpty()) { compile(); } else { root = new Start(lastAccept); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/crypto/Cipher.java --- a/src/java.base/share/classes/javax/crypto/Cipher.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/crypto/Cipher.java Thu Dec 13 11:51:06 2018 -0800 @@ -341,7 +341,7 @@ throw new NoSuchAlgorithmException("Invalid transformation " + "format:" + transformation); } - if ((parts[0] == null) || (parts[0].length() == 0)) { + if ((parts[0] == null) || (parts[0].isEmpty())) { throw new NoSuchAlgorithmException("Invalid transformation:" + "algorithm not specified-" + transformation); @@ -445,10 +445,10 @@ String alg = parts[0]; String mode = parts[1]; String pad = parts[2]; - if ((mode != null) && (mode.length() == 0)) { + if ((mode != null) && (mode.isEmpty())) { mode = null; } - if ((pad != null) && (pad.length() == 0)) { + if ((pad != null) && (pad.isEmpty())) { pad = null; } @@ -634,7 +634,7 @@ if ((transformation == null) || transformation.isEmpty()) { throw new NoSuchAlgorithmException("Null or empty transformation"); } - if ((provider == null) || (provider.length() == 0)) { + if ((provider == null) || (provider.isEmpty())) { throw new IllegalArgumentException("Missing provider"); } Provider p = Security.getProvider(provider); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/crypto/SealedObject.java --- a/src/java.base/share/classes/javax/crypto/SealedObject.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/crypto/SealedObject.java Thu Dec 13 11:51:06 2018 -0800 @@ -337,7 +337,7 @@ if (key == null) { throw new NullPointerException("key is null"); } - if (provider == null || provider.length() == 0) { + if (provider == null || provider.isEmpty()) { throw new IllegalArgumentException("missing provider"); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java --- a/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java Thu Dec 13 11:51:06 2018 -0800 @@ -133,7 +133,7 @@ String s = java.security.Security.getProperty(name); if (s != null) { s = s.trim(); - if (s.length() == 0) { + if (s.isEmpty()) { s = null; } } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/security/auth/PrivateCredentialPermission.java --- a/src/java.base/share/classes/javax/security/auth/PrivateCredentialPermission.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/security/auth/PrivateCredentialPermission.java Thu Dec 13 11:51:06 2018 -0800 @@ -312,7 +312,7 @@ private void init(String name) { - if (name == null || name.trim().length() == 0) { + if (name == null || name.trim().isEmpty()) { throw new IllegalArgumentException("invalid empty name"); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java --- a/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/security/auth/callback/ChoiceCallback.java Thu Dec 13 11:51:06 2018 -0800 @@ -98,13 +98,13 @@ public ChoiceCallback(String prompt, String[] choices, int defaultChoice, boolean multipleSelectionsAllowed) { - if (prompt == null || prompt.length() == 0 || + if (prompt == null || prompt.isEmpty() || choices == null || choices.length == 0 || defaultChoice < 0 || defaultChoice >= choices.length) throw new IllegalArgumentException(); for (int i = 0; i < choices.length; i++) { - if (choices[i] == null || choices[i].length() == 0) + if (choices[i] == null || choices[i].isEmpty()) throw new IllegalArgumentException(); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java --- a/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/security/auth/callback/ConfirmationCallback.java Thu Dec 13 11:51:06 2018 -0800 @@ -248,7 +248,7 @@ throw new IllegalArgumentException(); for (int i = 0; i < options.length; i++) { - if (options[i] == null || options[i].length() == 0) + if (options[i] == null || options[i].isEmpty()) throw new IllegalArgumentException(); } @@ -294,7 +294,7 @@ public ConfirmationCallback(String prompt, int messageType, int optionType, int defaultOption) { - if (prompt == null || prompt.length() == 0 || + if (prompt == null || prompt.isEmpty() || messageType < INFORMATION || messageType > ERROR || optionType < YES_NO_OPTION || optionType > OK_CANCEL_OPTION) throw new IllegalArgumentException(); @@ -357,14 +357,14 @@ public ConfirmationCallback(String prompt, int messageType, String[] options, int defaultOption) { - if (prompt == null || prompt.length() == 0 || + if (prompt == null || prompt.isEmpty() || messageType < INFORMATION || messageType > ERROR || options == null || options.length == 0 || defaultOption < 0 || defaultOption >= options.length) throw new IllegalArgumentException(); for (int i = 0; i < options.length; i++) { - if (options[i] == null || options[i].length() == 0) + if (options[i] == null || options[i].isEmpty()) throw new IllegalArgumentException(); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/security/auth/callback/NameCallback.java --- a/src/java.base/share/classes/javax/security/auth/callback/NameCallback.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/security/auth/callback/NameCallback.java Thu Dec 13 11:51:06 2018 -0800 @@ -62,7 +62,7 @@ * or if {@code prompt} has a length of 0. */ public NameCallback(String prompt) { - if (prompt == null || prompt.length() == 0) + if (prompt == null || prompt.isEmpty()) throw new IllegalArgumentException(); this.prompt = prompt; } @@ -82,8 +82,8 @@ * or if {@code defaultName} has a length of 0. */ public NameCallback(String prompt, String defaultName) { - if (prompt == null || prompt.length() == 0 || - defaultName == null || defaultName.length() == 0) + if (prompt == null || prompt.isEmpty() || + defaultName == null || defaultName.isEmpty()) throw new IllegalArgumentException(); this.prompt = prompt; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java --- a/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/security/auth/callback/PasswordCallback.java Thu Dec 13 11:51:06 2018 -0800 @@ -67,7 +67,7 @@ * if {@code prompt} has a length of 0. */ public PasswordCallback(String prompt, boolean echoOn) { - if (prompt == null || prompt.length() == 0) + if (prompt == null || prompt.isEmpty()) throw new IllegalArgumentException(); this.prompt = prompt; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/security/auth/callback/TextInputCallback.java --- a/src/java.base/share/classes/javax/security/auth/callback/TextInputCallback.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/security/auth/callback/TextInputCallback.java Thu Dec 13 11:51:06 2018 -0800 @@ -63,7 +63,7 @@ * or if {@code prompt} has a length of 0. */ public TextInputCallback(String prompt) { - if (prompt == null || prompt.length() == 0) + if (prompt == null || prompt.isEmpty()) throw new IllegalArgumentException(); this.prompt = prompt; } @@ -83,8 +83,8 @@ * or if {@code defaultText} has a length of 0. */ public TextInputCallback(String prompt, String defaultText) { - if (prompt == null || prompt.length() == 0 || - defaultText == null || defaultText.length() == 0) + if (prompt == null || prompt.isEmpty() || + defaultText == null || defaultText.isEmpty()) throw new IllegalArgumentException(); this.prompt = prompt; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/security/auth/callback/TextOutputCallback.java --- a/src/java.base/share/classes/javax/security/auth/callback/TextOutputCallback.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/security/auth/callback/TextOutputCallback.java Thu Dec 13 11:51:06 2018 -0800 @@ -74,7 +74,7 @@ public TextOutputCallback(int messageType, String message) { if ((messageType != INFORMATION && messageType != WARNING && messageType != ERROR) || - message == null || message.length() == 0) + message == null || message.isEmpty()) throw new IllegalArgumentException(); this.messageType = messageType; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/security/auth/login/AppConfigurationEntry.java --- a/src/java.base/share/classes/javax/security/auth/login/AppConfigurationEntry.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/security/auth/login/AppConfigurationEntry.java Thu Dec 13 11:51:06 2018 -0800 @@ -75,7 +75,7 @@ LoginModuleControlFlag controlFlag, Map options) { - if (loginModuleName == null || loginModuleName.length() == 0 || + if (loginModuleName == null || loginModuleName.isEmpty() || (controlFlag != LoginModuleControlFlag.REQUIRED && controlFlag != LoginModuleControlFlag.REQUISITE && controlFlag != LoginModuleControlFlag.SUFFICIENT && diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/security/auth/login/Configuration.java --- a/src/java.base/share/classes/javax/security/auth/login/Configuration.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/security/auth/login/Configuration.java Thu Dec 13 11:51:06 2018 -0800 @@ -418,7 +418,7 @@ throws NoSuchProviderException, NoSuchAlgorithmException { Objects.requireNonNull(type, "null type name"); - if (provider == null || provider.length() == 0) { + if (provider == null || provider.isEmpty()) { throw new IllegalArgumentException("missing provider"); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/security/auth/login/LoginContext.java --- a/src/java.base/share/classes/javax/security/auth/login/LoginContext.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/security/auth/login/LoginContext.java Thu Dec 13 11:51:06 2018 -0800 @@ -300,7 +300,7 @@ public CallbackHandler run() throws Exception { String defaultHandler = java.security.Security.getProperty (DEFAULT_HANDLER); - if (defaultHandler == null || defaultHandler.length() == 0) + if (defaultHandler == null || defaultHandler.isEmpty()) return null; Class c = Class.forName( defaultHandler, true, diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/javax/security/cert/X509Certificate.java --- a/src/java.base/share/classes/javax/security/cert/X509Certificate.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/javax/security/cert/X509Certificate.java Thu Dec 13 11:51:06 2018 -0800 @@ -210,7 +210,7 @@ * under JDK1.1. */ String className = X509Provider; - if (className == null || className.length() == 0) { + if (className == null || className.isEmpty()) { // shouldn't happen, but assume corrupted properties file // provide access to sun implementation className = "com.sun.security.cert.internal.x509.X509V1CertImpl"; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/jimage/decompressor/SignatureParser.java --- a/src/java.base/share/classes/jdk/internal/jimage/decompressor/SignatureParser.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/jimage/decompressor/SignatureParser.java Thu Dec 13 11:51:06 2018 -0800 @@ -60,7 +60,7 @@ switch (c) { case 'L': { String pkg = arguments.get(arg_index); - if(pkg.length() > 0) { + if(!pkg.isEmpty()) { out.append(pkg).append("/"); } arg_index+=1; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/jimage/decompressor/StringSharingDecompressor.java --- a/src/java.base/share/classes/jdk/internal/jimage/decompressor/StringSharingDecompressor.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/jimage/decompressor/StringSharingDecompressor.java Thu Dec 13 11:51:06 2018 -0800 @@ -168,7 +168,7 @@ int index = indices.get(argIndex); argIndex += 1; String pkg = reader.getString(index); - if (pkg.length() > 0) { + if (!pkg.isEmpty()) { pkg = pkg + "/"; byte[] encoded = getEncoded(pkg); buffer = safeAdd(buffer, encoded); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java --- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java Thu Dec 13 11:51:06 2018 -0800 @@ -123,7 +123,7 @@ StringBuilder sb = new StringBuilder(); sb.append(first); for (String path : more) { - if (path.length() > 0) { + if (!path.isEmpty()) { if (sb.length() > 0) { sb.append('/'); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java --- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java Thu Dec 13 11:51:06 2018 -0800 @@ -88,7 +88,7 @@ @Override public final JrtPath getFileName() { - if (path.length() == 0) + if (path.isEmpty()) return this; if (path.length() == 1 && path.charAt(0) == '/') return null; @@ -210,7 +210,7 @@ if (o.equals(this)) { return new JrtPath(jrtfs, "", true); } - if (path.length() == 0) { + if (path.isEmpty()) { return o; } if (jrtfs != o.jrtfs || isAbsolute() != o.isAbsolute()) { @@ -262,16 +262,16 @@ @Override public final boolean isAbsolute() { - return path.length() > 0 && path.charAt(0) == '/'; + return !path.isEmpty() && path.charAt(0) == '/'; } @Override public final JrtPath resolve(Path other) { final JrtPath o = checkPath(other); - if (this.path.length() == 0 || o.isAbsolute()) { + if (this.path.isEmpty() || o.isAbsolute()) { return o; } - if (o.path.length() == 0) { + if (o.path.isEmpty()) { return this; } StringBuilder sb = new StringBuilder(path.length() + o.path.length() + 1); @@ -301,7 +301,7 @@ } int off = op.length(); if (off == 0) { - return tp.length() == 0; + return tp.isEmpty(); } // check match is on name boundary return tp.length() == off || tp.charAt(off) == '/' || diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java --- a/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java Thu Dec 13 11:51:06 2018 -0800 @@ -59,7 +59,7 @@ // -Xbootclasspath/a or -javaagent with Boot-Class-Path attribute String append = VM.getSavedProperty("jdk.boot.class.path.append"); BOOT_LOADER = - new BootClassLoader((append != null && append.length() > 0) + new BootClassLoader((append != null && !append.isEmpty()) ? new URLClassPath(append, true) : null); PLATFORM_LOADER = new PlatformClassLoader(BOOT_LOADER); @@ -70,7 +70,7 @@ // contrary, we drop this historic interpretation of the empty // string and instead treat it as unspecified. String cp = System.getProperty("java.class.path"); - if (cp == null || cp.length() == 0) { + if (cp == null || cp.isEmpty()) { String initialModuleName = System.getProperty("jdk.module.main"); cp = (initialModuleName == null) ? "" : null; } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/loader/URLClassPath.java --- a/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java Thu Dec 13 11:51:06 2018 -0800 @@ -190,7 +190,7 @@ String element = (next == -1) ? cp.substring(off) : cp.substring(off, next); - if (element.length() > 0 || !skipEmptyElements) { + if (!element.isEmpty() || !skipEmptyElements) { URL url = toFileURL(element); if (url != null) path.add(url); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/module/Checks.java --- a/src/java.base/share/classes/jdk/internal/module/Checks.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/module/Checks.java Thu Dec 13 11:51:06 2018 -0800 @@ -63,22 +63,6 @@ } /** - * Returns {@code true} if the given name is a legal module name. - */ - public static boolean isModuleName(String name) { - int next; - int off = 0; - while ((next = name.indexOf('.', off)) != -1) { - String id = name.substring(off, next); - if (!isJavaIdentifier(id)) - return false; - off = next+1; - } - String last = name.substring(off); - return isJavaIdentifier(last); - } - - /** * Checks a name to ensure that it's a legal package name. * * @throws IllegalArgumentException if name is null or not a legal @@ -181,20 +165,20 @@ } /** - * Returns true if the given char sequence is a legal Java identifier, + * Returns true if the given string is a legal Java identifier, * otherwise false. */ - private static boolean isJavaIdentifier(CharSequence cs) { - if (cs.length() == 0 || RESERVED.contains(cs)) + private static boolean isJavaIdentifier(String str) { + if (str.isEmpty() || RESERVED.contains(str)) return false; - int first = Character.codePointAt(cs, 0); + int first = Character.codePointAt(str, 0); if (!Character.isJavaIdentifierStart(first)) return false; int i = Character.charCount(first); - while (i < cs.length()) { - int cp = Character.codePointAt(cs, i); + while (i < str.length()) { + int cp = Character.codePointAt(str, i); if (!Character.isJavaIdentifierPart(cp)) return false; i += Character.charCount(cp); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java --- a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java Thu Dec 13 11:51:06 2018 -0800 @@ -604,7 +604,8 @@ Set modules = new HashSet<>(); while (value != null) { for (String s : value.split(",")) { - if (s.length() > 0) modules.add(s); + if (!s.isEmpty()) + modules.add(s); } index++; value = getAndRemoveProperty(prefix + index); @@ -895,7 +896,7 @@ List values = map.computeIfAbsent(key, k -> new ArrayList<>()); int ntargets = 0; for (String s : rhs.split(regex)) { - if (s.length() > 0) { + if (!s.isEmpty()) { values.add(s); ntargets++; } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/module/ModulePatcher.java --- a/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java Thu Dec 13 11:51:06 2018 -0800 @@ -552,7 +552,7 @@ public Stream list() throws IOException { return Files.walk(dir, Integer.MAX_VALUE) .map(f -> Resources.toResourceName(dir, f)) - .filter(s -> s.length() > 0); + .filter(s -> !s.isEmpty()); } } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/module/ModulePath.java --- a/src/java.base/share/classes/jdk/internal/module/ModulePath.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/module/ModulePath.java Thu Dec 13 11:51:06 2018 -0800 @@ -546,7 +546,7 @@ = new BufferedReader(new InputStreamReader(in, "UTF-8")); String cn; while ((cn = nextLine(reader)) != null) { - if (cn.length() > 0) { + if (!cn.isEmpty()) { String pn = packageName(cn); if (!packages.contains(pn)) { String msg = "Provider class " + cn + " not in module"; @@ -599,7 +599,7 @@ mn = Patterns.REPEATING_DOTS.matcher(mn).replaceAll("."); // drop leading dots - if (mn.length() > 0 && mn.charAt(0) == '.') + if (!mn.isEmpty() && mn.charAt(0) == '.') mn = Patterns.LEADING_DOTS.matcher(mn).replaceAll(""); // drop trailing dots diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/module/Resources.java --- a/src/java.base/share/classes/jdk/internal/module/Resources.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/module/Resources.java Thu Dec 13 11:51:06 2018 -0800 @@ -78,7 +78,7 @@ String s = dir.relativize(file) .toString() .replace(File.separatorChar, '/'); - if (s.length() > 0 && Files.isDirectory(file)) + if (!s.isEmpty() && Files.isDirectory(file)) s += "/"; return s; } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java --- a/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/module/SystemModuleFinders.java Thu Dec 13 11:51:06 2018 -0800 @@ -83,7 +83,7 @@ if (value == null) { USE_FAST_PATH = true; } else { - USE_FAST_PATH = (value.length() > 0) && !Boolean.parseBoolean(value); + USE_FAST_PATH = !value.isEmpty() && !Boolean.parseBoolean(value); } } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/TypePath.java Thu Dec 13 11:51:06 2018 -0800 @@ -147,7 +147,7 @@ * @return the corresponding TypePath object, or {@literal null} if the path is empty. */ public static TypePath fromString(final String typePath) { - if (typePath == null || typePath.length() == 0) { + if (typePath == null || typePath.isEmpty()) { return null; } int typePathLength = typePath.length(); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckMethodAdapter.java Thu Dec 13 11:51:06 2018 -0800 @@ -1314,7 +1314,7 @@ * @param message the message to use in case of error. */ static void checkMethodIdentifier(final int version, final String name, final String message) { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IllegalArgumentException(INVALID + message + MUST_NOT_BE_NULL_OR_EMPTY); } if ((version & 0xFFFF) >= Opcodes.V1_5) { @@ -1347,7 +1347,7 @@ * @param message the message to use in case of error. */ static void checkInternalName(final int version, final String name, final String message) { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IllegalArgumentException(INVALID + message + MUST_NOT_BE_NULL_OR_EMPTY); } if (name.charAt(0) == '[') { @@ -1457,7 +1457,7 @@ * @param descriptor the string to be checked. */ static void checkMethodDescriptor(final int version, final String descriptor) { - if (descriptor == null || descriptor.length() == 0) { + if (descriptor == null || descriptor.isEmpty()) { throw new IllegalArgumentException("Invalid method descriptor (must not be null or empty)"); } if (descriptor.charAt(0) != '(' || descriptor.length() < 3) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/util/CheckSignatureAdapter.java Thu Dec 13 11:51:06 2018 -0800 @@ -365,7 +365,7 @@ } private void checkClassName(final String name, final String message) { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IllegalArgumentException(INVALID + message + " (must not be null or empty)"); } for (int i = 0; i < name.length(); ++i) { @@ -377,7 +377,7 @@ } private void checkIdentifier(final String name, final String message) { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IllegalArgumentException(INVALID + message + " (must not be null or empty)"); } for (int i = 0; i < name.length(); ++i) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorImpl.java --- a/src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorImpl.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/reflect/UnsafeFieldAccessorImpl.java Thu Dec 13 11:51:06 2018 -0800 @@ -151,10 +151,10 @@ if (isFinal) err += " final"; err += " " + field.getType().getName() + " field " + getQualifiedFieldName() + " to "; - if (attemptedValue.length() > 0) { + if (!attemptedValue.isEmpty()) { err += "(" + attemptedType + ")" + attemptedValue; } else { - if (attemptedType.length() > 0) + if (!attemptedType.isEmpty()) err += attemptedType; else err += "null value"; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java --- a/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/util/jar/JarIndex.java Thu Dec 13 11:51:06 2018 -0800 @@ -291,7 +291,7 @@ while((line = br.readLine()) != null && !line.endsWith(".jar")); for(;line != null; line = br.readLine()) { - if (line.length() == 0) + if (line.isEmpty()) continue; if (line.endsWith(".jar")) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java --- a/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java Thu Dec 13 11:51:06 2018 -0800 @@ -103,7 +103,7 @@ writer.writeStartDocument(); writer.writeDTD(PROPS_DTD_DECL); writer.writeStartElement(ELEMENT_ROOT); - if (comment != null && comment.length() > 0) { + if (comment != null && !comment.isEmpty()) { writer.writeStartElement(ELEMENT_COMMENT); writer.writeCharacters(comment); writer.writeEndElement(); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/util/xml/impl/Parser.java --- a/src/java.base/share/classes/jdk/internal/util/xml/impl/Parser.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/util/xml/impl/Parser.java Thu Dec 13 11:51:06 2018 -0800 @@ -1591,7 +1591,7 @@ str = name(false); // PI target name may not be empty string [#2.6] // PI target name 'XML' is reserved [#2.6] - if ((str.length() == 0) + if ((str.isEmpty()) || (mXml.name.equals(str.toLowerCase()) == true)) { panic(FAULT); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java --- a/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java Thu Dec 13 11:51:06 2018 -0800 @@ -205,7 +205,7 @@ * @throws XMLStreamException */ public void writeStartElement(String localName) throws XMLStreamException { - if (localName == null || localName.length() == 0) { + if (localName == null || localName.isEmpty()) { throw new XMLStreamException("Local Name cannot be null or empty"); } @@ -420,7 +420,7 @@ } private void writeXMLContent(String content) throws XMLStreamException { - if ((content != null) && (content.length() > 0)) { + if (content != null && !content.isEmpty()) { writeXMLContent(content, _escapeCharacters, // boolean = escapeChars false); // false = escapeDoubleQuotes diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/invoke/util/BytecodeName.java --- a/src/java.base/share/classes/sun/invoke/util/BytecodeName.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/invoke/util/BytecodeName.java Thu Dec 13 11:51:06 2018 -0800 @@ -451,7 +451,7 @@ * @return true if the name is non-empty and all of its characters are safe */ public static boolean isSafeBytecodeName(String s) { - if (s.length() == 0) return false; + if (s.isEmpty()) return false; // check occurrences of each DANGEROUS char for (char xc : DANGEROUS_CHARS_A) { if (xc == ESCAPE_C) continue; // not really that dangerous @@ -476,7 +476,7 @@ } private static String mangle(String s) { - if (s.length() == 0) + if (s.isEmpty()) return NULL_ESCAPE; // build this lazily, when we first need an escape: diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/TransferProtocolClient.java --- a/src/java.base/share/classes/sun/net/TransferProtocolClient.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/TransferProtocolClient.java Thu Dec 13 11:51:06 2018 -0800 @@ -76,7 +76,7 @@ System.out.print(response); } - if (response.length() == 0) { + if (response.isEmpty()) { code = -1; } else { try { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java --- a/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java Thu Dec 13 11:51:06 2018 -0800 @@ -433,7 +433,7 @@ logger.finest("Server [" + serverAddr + "] --> " + response); } - if (response.length() == 0) { + if (response.isEmpty()) { code = -1; } else { try { @@ -1049,7 +1049,7 @@ if (!isConnected()) { throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE); } - if (user == null || user.length() == 0) { + if (user == null || user.isEmpty()) { throw new IllegalArgumentException("User name can't be null or empty"); } tryLogin(user, password); @@ -1088,7 +1088,7 @@ if (!isConnected()) { throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE); } - if (user == null || user.length() == 0) { + if (user == null || user.isEmpty()) { throw new IllegalArgumentException("User name can't be null or empty"); } tryLogin(user, password); @@ -1152,7 +1152,7 @@ * @exception FtpProtocolException */ public sun.net.ftp.FtpClient changeDirectory(String remoteDirectory) throws sun.net.ftp.FtpProtocolException, IOException { - if (remoteDirectory == null || "".equals(remoteDirectory)) { + if (remoteDirectory == null || remoteDirectory.isEmpty()) { throw new IllegalArgumentException("directory can't be null or empty"); } @@ -1738,7 +1738,7 @@ * @throws IOException if an error occurs during the transmission. */ public long getSize(String path) throws sun.net.ftp.FtpProtocolException, IOException { - if (path == null || path.length() == 0) { + if (path == null || path.isEmpty()) { throw new IllegalArgumentException("path can't be null or empty"); } issueCommandCheck("SIZE " + path); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java --- a/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java Thu Dec 13 11:51:06 2018 -0800 @@ -238,7 +238,7 @@ if (phost != null && phost.length() != 0) break; } - if (phost == null || phost.length() == 0) { + if (phost == null || phost.isEmpty()) { /** * No system property defined for that * protocol. Let's check System Proxy @@ -267,7 +267,7 @@ nprop.hostsSource = null; nprop.pattern = null; } - } else if (nphosts.length() != 0) { + } else if (!nphosts.isEmpty()) { // add the required default patterns // but only if property no set. If it // is empty, leave empty. diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/www/HeaderParser.java --- a/src/java.base/share/classes/sun/net/www/HeaderParser.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/www/HeaderParser.java Thu Dec 13 11:51:06 2018 -0800 @@ -226,7 +226,7 @@ for (int i=0; k.hasNext(); i++) { String key = k.next(); String val = findValue (i); - if (val != null && "".equals (val)) { + if (val != null && val.isEmpty()) { val = null; } sb.append(" {").append(key).append(val == null ? "" : "," + val) diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/www/MimeEntry.java --- a/src/java.base/share/classes/sun/net/www/MimeEntry.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/www/MimeEntry.java Thu Dec 13 11:51:06 2018 -0800 @@ -201,9 +201,7 @@ } private boolean isStarred(String typeName) { - return (typeName != null) - && (typeName.length() > 0) - && (typeName.endsWith("/*")); + return typeName != null && typeName.endsWith("/*"); } /** @@ -300,7 +298,7 @@ } String extensions = getExtensionsAsList(); - if (extensions.length() > 0) { + if (!extensions.isEmpty()) { sj.add("file_extensions=" + extensions); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/www/MimeLauncher.java --- a/src/java.base/share/classes/sun/net/www/MimeLauncher.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/www/MimeLauncher.java Thu Dec 13 11:51:06 2018 -0800 @@ -162,7 +162,7 @@ location the application. If a valid path is not found, it returns false else true. */ private boolean findExecutablePath(String str) { - if (str == null || str.length() == 0) { + if (str == null || str.isEmpty()) { return false; } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/www/ParseUtil.java --- a/src/java.base/share/classes/sun/net/www/ParseUtil.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/www/ParseUtil.java Thu Dec 13 11:51:06 2018 -0800 @@ -536,8 +536,7 @@ throws URISyntaxException { if (scheme != null) { - if ((path != null) - && ((path.length() > 0) && (path.charAt(0) != '/'))) + if (path != null && !path.isEmpty() && path.charAt(0) != '/') throw new URISyntaxException(s, "Relative path in absolute URI"); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/www/http/HttpClient.java --- a/src/java.base/share/classes/sun/net/www/http/HttpClient.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/www/http/HttpClient.java Thu Dec 13 11:51:06 2018 -0800 @@ -603,7 +603,7 @@ StringBuilder result = new StringBuilder(128); result.append(url.getProtocol()); result.append(":"); - if (url.getAuthority() != null && url.getAuthority().length() > 0) { + if (url.getAuthority() != null && !url.getAuthority().isEmpty()) { result.append("//"); result.append(url.getAuthority()); } @@ -619,7 +619,7 @@ } else { fileName = url.getFile(); - if ((fileName == null) || (fileName.length() == 0)) { + if ((fileName == null) || (fileName.isEmpty())) { fileName = "/"; } else if (fileName.charAt(0) == '?') { /* HTTP/1.1 spec says in 5.1.2. about Request-URI: diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java --- a/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java Thu Dec 13 11:51:06 2018 -0800 @@ -341,7 +341,7 @@ path.charAt(0) == '/') { path = path.substring(1); } - if (path == null || path.length() == 0) { + if (path == null || path.isEmpty()) { path = "./"; } if (!path.endsWith("/")) { @@ -555,7 +555,7 @@ } decodePath(url.getPath()); - if (filename == null || filename.length() == 0) { + if (filename == null || filename.isEmpty()) { throw new IOException("illegal filename for a PUT"); } try { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java --- a/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java Thu Dec 13 11:51:06 2018 -0800 @@ -248,7 +248,7 @@ this.realm = realm; String urlPath = url.getPath(); - if (urlPath.length() == 0) + if (urlPath.isEmpty()) this.path = urlPath; else { this.path = reducePath (urlPath); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java --- a/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/www/protocol/http/DigestAuthentication.java Thu Dec 13 11:51:06 2018 -0800 @@ -279,7 +279,7 @@ if (s == null || !s.equals("true")) return false; String newNonce = p.findValue ("nonce"); - if (newNonce == null || "".equals(newNonce)) { + if (newNonce == null || newNonce.isEmpty()) { return false; } params.setNonce (newNonce); @@ -323,7 +323,7 @@ + authMethod.substring(1).toLowerCase(); } String algorithm = p.findValue("algorithm"); - if (algorithm == null || "".equals(algorithm)) { + if (algorithm == null || algorithm.isEmpty()) { algorithm = "MD5"; // The default, accoriding to rfc2069 } params.setAlgorithm (algorithm); @@ -451,7 +451,7 @@ } /* Check if there is a nextnonce field */ String nextnonce = p.findValue ("nextnonce"); - if (nextnonce != null && ! "".equals(nextnonce)) { + if (nextnonce != null && !nextnonce.isEmpty()) { params.setNonce (nextnonce); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java --- a/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Thu Dec 13 11:51:06 2018 -0800 @@ -3026,7 +3026,7 @@ // Filtering only if there is a cookie handler. [Assumption: the // cookie handler will store/retrieve the HttpOnly cookies] - if (cookieHandler == null || value.length() == 0) + if (cookieHandler == null || value.isEmpty()) return value; JavaNetHttpCookieAccess access = diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java --- a/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/www/protocol/https/HttpsClient.java Thu Dec 13 11:51:06 2018 -0800 @@ -143,7 +143,7 @@ String cipherString = GetPropertyAction.privilegedGetProperty("https.cipherSuites"); - if (cipherString == null || "".equals(cipherString)) { + if (cipherString == null || cipherString.isEmpty()) { ciphers = null; } else { StringTokenizer tokenizer; @@ -167,7 +167,7 @@ String protocolString = GetPropertyAction.privilegedGetProperty("https.protocols"); - if (protocolString == null || "".equals(protocolString)) { + if (protocolString == null || protocolString.isEmpty()) { protocols = null; } else { StringTokenizer tokenizer; @@ -187,7 +187,7 @@ private String getUserAgent() { String userAgent = GetPropertyAction.privilegedGetProperty("https.agent"); - if (userAgent == null || userAgent.length() == 0) { + if (userAgent == null || userAgent.isEmpty()) { userAgent = "JSSE"; } return userAgent; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java --- a/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java Thu Dec 13 11:51:06 2018 -0800 @@ -66,7 +66,7 @@ JavaRuntimeURLConnection(URL url) throws IOException { super(url); String path = url.getPath(); - if (path.length() == 0 || path.charAt(0) != '/') + if (path.isEmpty() || path.charAt(0) != '/') throw new MalformedURLException(url + " missing path or /"); if (path.length() == 1) { this.module = null; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/nio/ch/Net.java --- a/src/java.base/share/classes/sun/nio/ch/Net.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/nio/ch/Net.java Thu Dec 13 11:51:06 2018 -0800 @@ -403,14 +403,8 @@ public static boolean isFastTcpLoopbackRequested() { String loopbackProp = GetPropertyAction - .privilegedGetProperty("jdk.net.useFastTcpLoopback"); - boolean enable; - if ("".equals(loopbackProp)) { - enable = true; - } else { - enable = Boolean.parseBoolean(loopbackProp); - } - return enable; + .privilegedGetProperty("jdk.net.useFastTcpLoopback", "false"); + return loopbackProp.isEmpty() ? true : Boolean.parseBoolean(loopbackProp); } // -- Socket operations -- diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java --- a/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/nio/fs/AbstractFileSystemProvider.java Thu Dec 13 11:51:06 2018 -0800 @@ -73,7 +73,7 @@ throws IOException { String[] s = split(attribute); - if (s[0].length() == 0) + if (s[0].isEmpty()) throw new IllegalArgumentException(attribute); DynamicFileAttributeView view = getFileAttributeView(file, s[0], options); if (view == null) @@ -86,7 +86,7 @@ throws IOException { String[] s = split(attributes); - if (s[0].length() == 0) + if (s[0].isEmpty()) throw new IllegalArgumentException(attributes); DynamicFileAttributeView view = getFileAttributeView(file, s[0], options); if (view == null) diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java --- a/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java Thu Dec 13 11:51:06 2018 -0800 @@ -83,7 +83,7 @@ names = list(); break; } else { - if (name.length() == 0) + if (name.isEmpty()) throw new IllegalArgumentException(); names.add(name); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/jca/GetInstance.java --- a/src/java.base/share/classes/sun/security/jca/GetInstance.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/jca/GetInstance.java Thu Dec 13 11:51:06 2018 -0800 @@ -75,7 +75,7 @@ public static Service getService(String type, String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException { - if ((provider == null) || (provider.length() == 0)) { + if (provider == null || provider.isEmpty()) { throw new IllegalArgumentException("missing provider"); } Provider p = Providers.getProviderList().getProvider(provider); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/jca/ProviderConfig.java --- a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java Thu Dec 13 11:51:06 2018 -0800 @@ -114,7 +114,7 @@ } private boolean hasArgument() { - return argument.length() != 0; + return !argument.isEmpty(); } // should we try to load this provider? diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/jca/ProviderList.java --- a/src/java.base/share/classes/sun/security/jca/ProviderList.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/jca/ProviderList.java Thu Dec 13 11:51:06 2018 -0800 @@ -175,7 +175,7 @@ while ((entry = Security.getProperty("security.provider." + i)) != null) { entry = entry.trim(); - if (entry.length() == 0) { + if (entry.isEmpty()) { System.err.println("invalid entry for " + "security.provider." + i); break; @@ -200,7 +200,7 @@ // Load config entries for use when getInstance is called entry = Security.getProperty("jdk.security.provider.preferred"); - if (entry != null && (entry = entry.trim()).length() > 0) { + if (entry != null && !(entry = entry.trim()).isEmpty()) { String[] entries = entry.split(","); if (ProviderList.preferredPropList == null) { ProviderList.preferredPropList = new PreferredList(); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/provider/ConfigFile.java --- a/src/java.base/share/classes/sun/security/provider/ConfigFile.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/provider/ConfigFile.java Thu Dec 13 11:51:06 2018 -0800 @@ -626,7 +626,7 @@ return url.openStream(); } catch (Exception e) { String file = url.getPath(); - if (url.getHost().length() > 0) { // For Windows UNC + if (!url.getHost().isEmpty()) { // For Windows UNC file = "//" + url.getHost() + file; } if (debugConfig != null) { @@ -651,7 +651,7 @@ return value; } String s = PropertyExpander.expand(value); - if (s == null || s.length() == 0) { + if (s == null || s.isEmpty()) { throw ioException( "Configuration.Error.Line.line.system.property.value.expanded.to.empty.value", linenum, value); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/provider/PolicyParser.java --- a/src/java.base/share/classes/sun/security/provider/PolicyParser.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/provider/PolicyParser.java Thu Dec 13 11:51:06 2018 -0800 @@ -391,9 +391,9 @@ out.print("keystore \""); out.print(keyStoreUrlString); out.print('"'); - if (keyStoreType != null && keyStoreType.length() > 0) + if (keyStoreType != null && !keyStoreType.isEmpty()) out.print(", \"" + keyStoreType + "\""); - if (keyStoreProvider != null && keyStoreProvider.length() > 0) + if (keyStoreProvider != null && !keyStoreProvider.isEmpty()) out.print(", \"" + keyStoreProvider + "\""); out.println(";"); out.println(); @@ -446,7 +446,7 @@ String alias = aliases.nextToken().trim(); if (alias.equals(",")) cctr++; - else if (alias.length() > 0) + else if (!alias.isEmpty()) actr++; } if (actr <= cctr) diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/provider/SeedGenerator.java --- a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java Thu Dec 13 11:51:06 2018 -0800 @@ -113,7 +113,7 @@ + "generator: " + e.toString()); } } - } else if (egdSource.length() != 0) { + } else if (!egdSource.isEmpty()) { try { instance = new URLSeedGenerator(egdSource); if (debug != null) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/ssl/CertificateMessage.java --- a/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/ssl/CertificateMessage.java Thu Dec 13 11:51:06 2018 -0800 @@ -440,7 +440,7 @@ // It is not necessary to check the certificate update if // endpoint identification is enabled. String identityAlg = chc.sslConfig.identificationProtocol; - if ((identityAlg == null || identityAlg.length() == 0) && + if ((identityAlg == null || identityAlg.isEmpty()) && !isIdentityEquivalent(x509Certs[0], chc.reservedServerCerts[0])) { chc.conContext.fatal(Alert.BAD_CERTIFICATE, diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/ssl/ClientHello.java --- a/src/java.base/share/classes/sun/security/ssl/ClientHello.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/ssl/ClientHello.java Thu Dec 13 11:51:06 2018 -0800 @@ -491,7 +491,7 @@ // It is fine to move on with abbreviate handshake if // endpoint identification is enabled. String identityAlg = chc.sslConfig.identificationProtocol; - if ((identityAlg == null || identityAlg.length() == 0)) { + if (identityAlg == null || identityAlg.isEmpty()) { if (isEmsAvailable) { if (!session.useExtendedMasterSecret) { // perform full handshake instead diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java --- a/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/ssl/DHKeyExchange.java Thu Dec 13 11:51:06 2018 -0800 @@ -253,7 +253,7 @@ static { String property = GetPropertyAction.privilegedGetProperty( "jdk.tls.ephemeralDHKeySize"); - if (property == null || property.length() == 0) { + if (property == null || property.isEmpty()) { useLegacyEphemeralDHKeys = false; useSmartEphemeralDHKeys = false; customizedDHKeySize = -1; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java --- a/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java Thu Dec 13 11:51:06 2018 -0800 @@ -237,7 +237,7 @@ public boolean permits(Set primitives, String algorithm, AlgorithmParameters parameters) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { throw new IllegalArgumentException( "No algorithm name specified"); } @@ -276,7 +276,7 @@ public final boolean permits(Set primitives, String algorithm, Key key, AlgorithmParameters parameters) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { throw new IllegalArgumentException( "No algorithm name specified"); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java --- a/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java Thu Dec 13 11:51:06 2018 -0800 @@ -436,7 +436,7 @@ "System property " + propertyName + " is set to '" + property + "'"); } - if (property != null && property.length() != 0) { + if (property != null && !property.isEmpty()) { // remove double quote marks from beginning/end of the property if (property.length() > 1 && property.charAt(0) == '"' && property.charAt(property.length() - 1) == '"') { @@ -444,7 +444,7 @@ } } - if (property != null && property.length() != 0) { + if (property != null && !property.isEmpty()) { String[] cipherSuiteNames = property.split(","); Collection cipherSuites = new ArrayList<>(cipherSuiteNames.length); @@ -845,7 +845,7 @@ return; } - if (property.length() != 0) { + if (!property.isEmpty()) { // remove double quote marks from beginning/end of the property if (property.length() > 1 && property.charAt(0) == '"' && property.charAt(property.length() - 1) == '"') { @@ -853,7 +853,7 @@ } } - if (property.length() != 0) { + if (!property.isEmpty()) { String[] protocols = property.split(","); for (int i = 0; i < protocols.length; i++) { protocols[i] = protocols[i].trim(); @@ -1109,7 +1109,7 @@ KeyStore ks = null; char[] passwd = null; try { - if (defaultKeyStore.length() != 0 && + if (!defaultKeyStore.isEmpty() && !NONE.equals(defaultKeyStore)) { fs = AccessController.doPrivileged( new PrivilegedExceptionAction() { @@ -1121,7 +1121,7 @@ } String defaultKeyStorePassword = props.get("keyStorePasswd"); - if (defaultKeyStorePassword.length() != 0) { + if (!defaultKeyStorePassword.isEmpty()) { passwd = defaultKeyStorePassword.toCharArray(); } @@ -1132,7 +1132,7 @@ if (SSLLogger.isOn && SSLLogger.isOn("ssl,defaultctx")) { SSLLogger.finest("init keystore"); } - if (defaultKeyStoreProvider.length() == 0) { + if (defaultKeyStoreProvider.isEmpty()) { ks = KeyStore.getInstance(defaultKeyStoreType); } else { ks = KeyStore.getInstance(defaultKeyStoreType, @@ -1561,7 +1561,7 @@ // check endpoint identity String identityAlg = sslSocket.getSSLParameters(). getEndpointIdentificationAlgorithm(); - if (identityAlg != null && identityAlg.length() != 0) { + if (identityAlg != null && !identityAlg.isEmpty()) { String hostname = session.getPeerHost(); X509TrustManagerImpl.checkIdentity( hostname, chain[0], identityAlg); @@ -1601,7 +1601,7 @@ // check endpoint identity String identityAlg = engine.getSSLParameters(). getEndpointIdentificationAlgorithm(); - if (identityAlg != null && identityAlg.length() != 0) { + if (identityAlg != null && !identityAlg.isEmpty()) { String hostname = session.getPeerHost(); X509TrustManagerImpl.checkIdentity( hostname, chain[0], identityAlg); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java --- a/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Thu Dec 13 11:51:06 2018 -0800 @@ -1203,7 +1203,7 @@ synchronized void doneConnect() throws IOException { // In server mode, it is not necessary to set host and serverNames. // Otherwise, would require a reverse DNS lookup to get the hostname. - if ((peerHost == null) || (peerHost.length() == 0)) { + if (peerHost == null || peerHost.isEmpty()) { boolean useNameService = trustNameService && conContext.sslConfig.isClientMode; useImplicitHost(useNameService); @@ -1238,8 +1238,7 @@ JavaNetInetAddressAccess jna = SharedSecrets.getJavaNetInetAddressAccess(); String originalHostname = jna.getOriginalHostName(inetAddress); - if ((originalHostname != null) && - (originalHostname.length() != 0)) { + if (originalHostname != null && !originalHostname.isEmpty()) { this.peerHost = originalHostname; if (conContext.sslConfig.serverNames.isEmpty() && diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java --- a/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java Thu Dec 13 11:51:06 2018 -0800 @@ -483,7 +483,7 @@ // default groups and preferences will be used. String property = GetPropertyAction .privilegedGetProperty("jdk.tls.namedGroups"); - if (property != null && property.length() != 0) { + if (property != null && !property.isEmpty()) { // remove double quote marks from beginning/end of the property if (property.length() > 1 && property.charAt(0) == '"' && property.charAt(property.length() - 1) == '"') { @@ -492,7 +492,7 @@ } ArrayList groupList; - if (property != null && property.length() != 0) { + if (property != null && !property.isEmpty()) { String[] groups = property.split(","); groupList = new ArrayList<>(groups.length); for (String group : groups) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java --- a/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/ssl/X509TrustManagerImpl.java Thu Dec 13 11:51:06 2018 -0800 @@ -148,7 +148,7 @@ "null or zero-length certificate chain"); } - if (authType == null || authType.length() == 0) { + if (authType == null || authType.isEmpty()) { throw new IllegalArgumentException( "null or zero-length authentication type"); } @@ -229,7 +229,7 @@ // check endpoint identity String identityAlg = sslSocket.getSSLParameters(). getEndpointIdentificationAlgorithm(); - if (identityAlg != null && identityAlg.length() != 0) { + if (identityAlg != null && !identityAlg.isEmpty()) { checkIdentity(session, trustedChain[0], identityAlg, isClient, getRequestedServerNames(socket), chainsToPublicCA); } @@ -287,7 +287,7 @@ // check endpoint identity String identityAlg = engine.getSSLParameters(). getEndpointIdentificationAlgorithm(); - if (identityAlg != null && identityAlg.length() != 0) { + if (identityAlg != null && !identityAlg.isEmpty()) { checkIdentity(session, trustedChain[0], identityAlg, isClient, getRequestedServerNames(engine), chainsToPublicCA); } @@ -448,7 +448,7 @@ private static void checkIdentity(String hostname, X509Certificate cert, String algorithm, boolean chainsToPublicCA) throws CertificateException { - if (algorithm != null && algorithm.length() != 0) { + if (algorithm != null && !algorithm.isEmpty()) { // if IPv6 strip off the "[]" if ((hostname != null) && hostname.startsWith("[") && hostname.endsWith("]")) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/tools/PathList.java --- a/src/java.base/share/classes/sun/security/tools/PathList.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/tools/PathList.java Thu Dec 13 11:51:06 2018 -0800 @@ -46,9 +46,9 @@ * @return the resulting path */ public static String appendPath(String pathTo, String pathFrom) { - if (pathTo == null || pathTo.length() == 0) { + if (pathTo == null || pathTo.isEmpty()) { return pathFrom; - } else if (pathFrom == null || pathFrom.length() == 0) { + } else if (pathFrom == null || pathFrom.isEmpty()) { return pathTo; } else { return pathTo + File.pathSeparator + pathFrom; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java --- a/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java Thu Dec 13 11:51:06 2018 -0800 @@ -75,7 +75,7 @@ static boolean checkAlgorithm(String[] algorithms, String algorithm, AlgorithmDecomposer decomposer) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { throw new IllegalArgumentException("No algorithm name specified"); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java --- a/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java Thu Dec 13 11:51:06 2018 -0800 @@ -80,7 +80,7 @@ * Please override the method if need to support more name pattern. */ public Set decompose(String algorithm) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { return new HashSet<>(); } @@ -167,7 +167,7 @@ * message digest algorithm name to avoid overly complicated checking. */ public static Set decomposeOneHash(String algorithm) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { return new HashSet<>(); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java --- a/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java Thu Dec 13 11:51:06 2018 -0800 @@ -135,7 +135,7 @@ public final boolean permits(Set primitives, String algorithm, Key key, AlgorithmParameters parameters) { - if (algorithm == null || algorithm.length() == 0) { + if (algorithm == null || algorithm.isEmpty()) { throw new IllegalArgumentException("No algorithm name specified"); } @@ -188,7 +188,7 @@ } // check the signature algorithm with parameters - if (algorithm != null && algorithm.length() != 0) { + if (algorithm != null && !algorithm.isEmpty()) { if (!permits(primitives, algorithm, parameters)) { return false; } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java --- a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java Thu Dec 13 11:51:06 2018 -0800 @@ -423,7 +423,7 @@ // This means we have an error in finding weak algorithms, run in // debug mode to see permittedAlgs map's values. - if (w.length() == 0) { + if (w.isEmpty()) { return "Unknown Algorithm(s)"; } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/x509/AVA.java --- a/src/java.base/share/classes/sun/security/x509/AVA.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/x509/AVA.java Thu Dec 13 11:51:06 2018 -0800 @@ -1245,7 +1245,7 @@ } boolean number = false; - if (keyword.length() != 0) { + if (!keyword.isEmpty()) { char ch = keyword.charAt(0); if ((ch >= '0') && (ch <= '9')) { number = true; @@ -1285,7 +1285,7 @@ return ak.keyword; } } else { - if (keywordString.length() == 0) { + if (keywordString.isEmpty()) { throw new IllegalArgumentException("keyword cannot be empty"); } keywordString = keywordString.trim(); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/x509/DNSName.java --- a/src/java.base/share/classes/sun/security/x509/DNSName.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/x509/DNSName.java Thu Dec 13 11:51:06 2018 -0800 @@ -72,7 +72,7 @@ * @throws IOException if the name is not a valid DNSName subjectAltName */ public DNSName(String name) throws IOException { - if (name == null || name.length() == 0) + if (name == null || name.isEmpty()) throw new IOException("DNSName must not be null or empty"); if (name.contains(" ")) throw new IOException("DNSName with blank components is not permitted"); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/x509/IPAddressName.java --- a/src/java.base/share/classes/sun/security/x509/IPAddressName.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/x509/IPAddressName.java Thu Dec 13 11:51:06 2018 -0800 @@ -125,7 +125,7 @@ */ public IPAddressName(String name) throws IOException { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IOException("IPAddress cannot be null or empty"); } if (name.charAt(name.length() - 1) == '/') { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/x509/RDN.java --- a/src/java.base/share/classes/sun/security/x509/RDN.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/x509/RDN.java Thu Dec 13 11:51:06 2018 -0800 @@ -121,7 +121,7 @@ * Plus sign is a separator */ String avaString = name.substring(avaOffset, nextPlus); - if (avaString.length() == 0) { + if (avaString.isEmpty()) { throw new IOException("empty AVA in RDN \"" + name + "\""); } @@ -141,7 +141,7 @@ // parse last or only AVA String avaString = name.substring(avaOffset); - if (avaString.length() == 0) { + if (avaString.isEmpty()) { throw new IOException("empty AVA in RDN \"" + name + "\""); } AVA ava = new AVA(new StringReader(avaString), keywordMap); @@ -199,7 +199,7 @@ * Plus sign is a separator */ String avaString = name.substring(avaOffset, nextPlus); - if (avaString.length() == 0) { + if (avaString.isEmpty()) { throw new IOException("empty AVA in RDN \"" + name + "\""); } @@ -217,7 +217,7 @@ // parse last or only AVA String avaString = name.substring(avaOffset); - if (avaString.length() == 0) { + if (avaString.isEmpty()) { throw new IOException("empty AVA in RDN \"" + name + "\""); } AVA ava = new AVA(new StringReader(avaString), AVA.RFC2253, keywordMap); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/x509/RFC822Name.java --- a/src/java.base/share/classes/sun/security/x509/RFC822Name.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/x509/RFC822Name.java Thu Dec 13 11:51:06 2018 -0800 @@ -79,12 +79,12 @@ * @throws IOException if name is not valid */ public void parseName(String name) throws IOException { - if (name == null || name.length() == 0) { + if (name == null || name.isEmpty()) { throw new IOException("RFC822Name may not be null or empty"); } // See if domain is a valid domain name String domain = name.substring(name.indexOf('@')+1); - if (domain.length() == 0) { + if (domain.isEmpty()) { throw new IOException("RFC822Name may not end with @"); } else { //An RFC822 NameConstraint could start with a ., although diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/x509/X500Name.java --- a/src/java.base/share/classes/sun/security/x509/X500Name.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/x509/X500Name.java Thu Dec 13 11:51:06 2018 -0800 @@ -865,7 +865,7 @@ */ private void parseDN(String input, Map keywordMap) throws IOException { - if (input == null || input.length() == 0) { + if (input == null || input.isEmpty()) { names = new RDN[0]; return; } @@ -937,7 +937,7 @@ } private void parseRFC2253DN(String dnString) throws IOException { - if (dnString.length() == 0) { + if (dnString.isEmpty()) { names = new RDN[0]; return; } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/x509/X509CRLImpl.java --- a/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java Thu Dec 13 11:51:06 2018 -0800 @@ -370,7 +370,7 @@ throw new CRLException("Uninitialized CRL"); } Signature sigVerf = null; - if (sigProvider.length() == 0) { + if (sigProvider.isEmpty()) { sigVerf = Signature.getInstance(sigAlgId.getName()); } else { sigVerf = Signature.getInstance(sigAlgId.getName(), sigProvider); @@ -495,7 +495,7 @@ if (readOnly) throw new CRLException("cannot over-write existing CRL"); Signature sigEngine = null; - if ((provider == null) || (provider.length() == 0)) + if (provider == null || provider.isEmpty()) sigEngine = Signature.getInstance(algorithm); else sigEngine = Signature.getInstance(algorithm, provider); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/security/x509/X509CertImpl.java --- a/src/java.base/share/classes/sun/security/x509/X509CertImpl.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/security/x509/X509CertImpl.java Thu Dec 13 11:51:06 2018 -0800 @@ -429,7 +429,7 @@ } // Verify the signature ... Signature sigVerf = null; - if (sigProvider.length() == 0) { + if (sigProvider.isEmpty()) { sigVerf = Signature.getInstance(algId.getName()); } else { sigVerf = Signature.getInstance(algId.getName(), sigProvider); @@ -598,7 +598,7 @@ throw new CertificateEncodingException( "cannot over-write existing certificate"); Signature sigEngine = null; - if ((provider == null) || (provider.length() == 0)) + if (provider == null || provider.isEmpty()) sigEngine = Signature.getInstance(algorithm); else sigEngine = Signature.getInstance(algorithm, provider); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/util/locale/InternalLocaleBuilder.java --- a/src/java.base/share/classes/sun/util/locale/InternalLocaleBuilder.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/util/locale/InternalLocaleBuilder.java Thu Dec 13 11:51:06 2018 -0800 @@ -331,7 +331,7 @@ done.add(key); } } - if (privateuse != null && privateuse.length() > 0) { + if (privateuse != null && !privateuse.isEmpty()) { // privateuse string contains prefix, e.g. "x-abc-def" if (extensions == null) { extensions = new HashMap<>(1); @@ -406,19 +406,19 @@ // Validate base locale fields before updating internal state. // LocaleExtensions always store validated/canonicalized values, // so no checks are necessary. - if (language.length() > 0 && !LanguageTag.isLanguage(language)) { + if (!language.isEmpty() && !LanguageTag.isLanguage(language)) { throw new LocaleSyntaxException("Ill-formed language: " + language); } - if (script.length() > 0 && !LanguageTag.isScript(script)) { + if (!script.isEmpty() && !LanguageTag.isScript(script)) { throw new LocaleSyntaxException("Ill-formed script: " + script); } - if (region.length() > 0 && !LanguageTag.isRegion(region)) { + if (!region.isEmpty() && !LanguageTag.isRegion(region)) { throw new LocaleSyntaxException("Ill-formed region: " + region); } - if (variant.length() > 0) { + if (!variant.isEmpty()) { int errIdx = checkVariants(variant, BaseLocale.SEP); if (errIdx != -1) { throw new LocaleSyntaxException("Ill-formed variant: " + variant, errIdx); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/util/locale/LanguageTag.java --- a/src/java.base/share/classes/sun/util/locale/LanguageTag.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/util/locale/LanguageTag.java Thu Dec 13 11:51:06 2018 -0800 @@ -212,7 +212,7 @@ if (!itr.isDone() && !sts.isError()) { String s = itr.current(); sts.errorIndex = itr.currentStart(); - if (s.length() == 0) { + if (s.isEmpty()) { sts.errorMsg = "Empty subtag"; } else { sts.errorMsg = "Invalid subtag: " + s; @@ -454,7 +454,7 @@ variant = ""; } - if (variant.length() > 0) { + if (!variant.isEmpty()) { List variants = null; StringTokenIterator varitr = new StringTokenIterator(variant, BaseLocale.SEP); while (!varitr.isDone()) { @@ -527,7 +527,7 @@ tag.privateuse = privateuse; } - if (tag.language.length() == 0 && (hasSubtag || privateuse == null)) { + if (tag.language.isEmpty() && (hasSubtag || privateuse == null)) { // use lang "und" when 1) no language is available AND // 2) any of other subtags other than private use are available or // no private use tag is available @@ -712,18 +712,18 @@ public String toString() { StringBuilder sb = new StringBuilder(); - if (language.length() > 0) { + if (!language.isEmpty()) { sb.append(language); for (String extlang : extlangs) { sb.append(SEP).append(extlang); } - if (script.length() > 0) { + if (!script.isEmpty()) { sb.append(SEP).append(script); } - if (region.length() > 0) { + if (!region.isEmpty()) { sb.append(SEP).append(region); } @@ -735,7 +735,7 @@ sb.append(SEP).append(extension); } } - if (privateuse.length() > 0) { + if (!privateuse.isEmpty()) { if (sb.length() > 0) { sb.append(SEP); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/util/locale/LocaleMatcher.java --- a/src/java.base/share/classes/sun/util/locale/LocaleMatcher.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/util/locale/LocaleMatcher.java Thu Dec 13 11:51:06 2018 -0800 @@ -402,7 +402,7 @@ } String rangeForRegex = range.replace("*", "\\p{Alnum}*"); - while (rangeForRegex.length() > 0) { + while (!rangeForRegex.isEmpty()) { for (String tag : tags) { // change to lowercase for case-insensitive matching String lowerCaseTag = tag.toLowerCase(Locale.ROOT); @@ -437,7 +437,7 @@ } String rangeForRegex = range.replace("*", "\\p{Alnum}*"); - while (rangeForRegex.length() > 0) { + while (!rangeForRegex.isEmpty()) { if (tag.matches(rangeForRegex)) { return true; } @@ -591,7 +591,7 @@ private static String[] getEquivalentsForLanguage(String range) { String r = range; - while (r.length() > 0) { + while (!r.isEmpty()) { if (LocaleEquivalentMaps.singleEquivMap.containsKey(r)) { String equiv = LocaleEquivalentMaps.singleEquivMap.get(r); // Return immediately for performance if the first matching @@ -680,7 +680,7 @@ String r = range; boolean hasEquivalent = false; - while (r.length() > 0) { + while (!r.isEmpty()) { if (keyMap.containsKey(r)) { hasEquivalent = true; List equivalents = map.get(keyMap.get(r)); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/util/locale/LocaleUtils.java --- a/src/java.base/share/classes/sun/util/locale/LocaleUtils.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/util/locale/LocaleUtils.java Thu Dec 13 11:51:06 2018 -0800 @@ -207,7 +207,7 @@ } static boolean isEmpty(String str) { - return str == null || str.length() == 0; + return str == null || str.isEmpty(); } static boolean isEmpty(Set set) { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java --- a/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java Thu Dec 13 11:51:06 2018 -0800 @@ -80,7 +80,7 @@ String value = keyword.getValue(); sj.add(key); - if (value.length() > 0) { + if (!value.isEmpty()) { sj.add(value); } } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java --- a/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/util/locale/provider/CalendarNameProviderImpl.java Thu Dec 13 11:51:06 2018 -0800 @@ -117,7 +117,7 @@ } name = strings[value]; // If name is empty in standalone, try its `format' style. - if (name.length() == 0 + if (name.isEmpty() && (style == SHORT_STANDALONE || style == LONG_STANDALONE || style == NARROW_STANDALONE)) { name = getDisplayName(calendarType, field, value, @@ -183,7 +183,7 @@ String name = strings[i]; // Ignore any empty string (some standalone month names // are not defined) - if (name.length() == 0) { + if (name.isEmpty()) { continue; } map.put(name, base + i); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java --- a/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java Thu Dec 13 11:51:06 2018 -0800 @@ -503,7 +503,7 @@ */ String supportedLocaleString = createSupportedLocaleString("AvailableLocales"); - if (supportedLocaleString.length() == 0) { + if (supportedLocaleString.isEmpty()) { throw new InternalError("No available locales for JRE"); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java Thu Dec 13 11:51:06 2018 -0800 @@ -121,7 +121,7 @@ List typeList = new ArrayList<>(); // Check user specified adapter preference - if (order != null && order.length() != 0) { + if (order != null && !order.isEmpty()) { String[] types = order.split(","); for (String type : types) { type = type.trim().toUpperCase(Locale.ROOT); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/unix/classes/java/io/UnixFileSystem.java --- a/src/java.base/unix/classes/java/io/UnixFileSystem.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/unix/classes/java/io/UnixFileSystem.java Thu Dec 13 11:51:06 2018 -0800 @@ -98,7 +98,7 @@ } public int prefixLength(String pathname) { - if (pathname.length() == 0) return 0; + if (pathname.isEmpty()) return 0; return (pathname.charAt(0) == '/') ? 1 : 0; } @@ -249,7 +249,7 @@ public int getBooleanAttributes(File f) { int rv = getBooleanAttributes0(f); String name = f.getName(); - boolean hidden = (name.length() > 0) && (name.charAt(0) == '.'); + boolean hidden = !name.isEmpty() && name.charAt(0) == '.'; return rv | (hidden ? BA_HIDDEN : 0); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/unix/classes/jdk/internal/loader/FileURLMapper.java --- a/src/java.base/unix/classes/jdk/internal/loader/FileURLMapper.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/unix/classes/jdk/internal/loader/FileURLMapper.java Thu Dec 13 11:51:06 2018 -0800 @@ -59,9 +59,9 @@ return path; } String host = url.getHost(); - if (host == null || "".equals(host) || "localhost".equalsIgnoreCase (host)) { + if (host == null || host.isEmpty() || "localhost".equalsIgnoreCase(host)) { path = url.getFile(); - path = ParseUtil.decode (path); + path = ParseUtil.decode(path); } return path; } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java --- a/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java Thu Dec 13 11:51:06 2018 -0800 @@ -68,14 +68,14 @@ String line; while ((line = in.readLine()) != null) { int maxvalues = maxperkeyword; - if (line.length() == 0) + if (line.isEmpty()) continue; if (line.charAt(0) == '#' || line.charAt(0) == ';') continue; if (!line.startsWith(keyword)) continue; String value = line.substring(keyword.length()); - if (value.length() == 0) + if (value.isEmpty()) continue; if (value.charAt(0) != ' ' && value.charAt(0) != '\t') continue; @@ -181,7 +181,7 @@ // LOCALDOMAIN has absolute priority on Solaris String localDomain = localDomain0(); - if (localDomain != null && localDomain.length() > 0) { + if (localDomain != null && !localDomain.isEmpty()) { sl = new LinkedList<>(); sl.add(localDomain); return sl; @@ -211,7 +211,7 @@ sl = new LinkedList<>(); String domain = fallbackDomain0(); - if (domain != null && domain.length() > 0) { + if (domain != null && !domain.isEmpty()) { sl.add(domain); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/unix/classes/sun/net/sdp/SdpProvider.java --- a/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java Thu Dec 13 11:51:06 2018 -0800 @@ -77,7 +77,7 @@ String logfile = props.getProperty("com.sun.sdp.debug"); if (logfile != null) { out = System.out; - if (logfile.length() > 0) { + if (!logfile.isEmpty()) { try { out = new PrintStream(logfile); } catch (IOException ignore) { } @@ -167,9 +167,9 @@ result[1] = all ? MAX_PORT : result[0]; } else { String low = s.substring(0, pos); - if (low.length() == 0) low = "*"; + if (low.isEmpty()) low = "*"; String high = s.substring(pos+1); - if (high.length() == 0) high = "*"; + if (high.isEmpty()) high = "*"; result[0] = low.equals("*") ? 0 : Integer.parseInt(low); result[1] = high.equals("*") ? MAX_PORT : Integer.parseInt(high); } @@ -199,7 +199,7 @@ String line = scanner.nextLine().trim(); // skip blank lines and comments - if (line.length() == 0 || line.charAt(0) == '#') + if (line.isEmpty() || line.charAt(0) == '#') continue; // must have 3 fields diff -r fd6de53a0d6e -r b94283cb226b src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java --- a/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java Thu Dec 13 11:51:06 2018 -0800 @@ -127,9 +127,9 @@ */ String s1 = u1.getHost(); String s2 = u2.getHost(); - if ("localhost".equalsIgnoreCase(s1) && ( s2 == null || "".equals(s2))) + if ("localhost".equalsIgnoreCase(s1) && (s2 == null || s2.isEmpty())) return true; - if ("localhost".equalsIgnoreCase(s2) && ( s1 == null || "".equals(s1))) + if ("localhost".equalsIgnoreCase(s2) && (s1 == null || s1.isEmpty())) return true; return super.hostsEqual(u1, u2); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java --- a/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/unix/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java Thu Dec 13 11:51:06 2018 -0800 @@ -49,8 +49,8 @@ static { String propValue = GetPropertyAction.privilegedGetProperty( "sun.nio.ch.disableSynchronousRead", "false"); - disableSynchronousRead = (propValue.length() == 0) ? - true : Boolean.valueOf(propValue); + disableSynchronousRead = propValue.isEmpty() ? + true : Boolean.parseBoolean(propValue); } private final Port port; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java --- a/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java Thu Dec 13 11:51:06 2018 -0800 @@ -58,8 +58,7 @@ // default directory. String propValue = GetPropertyAction .privilegedGetProperty("sun.nio.fs.chdirAllowed", "false"); - boolean chdirAllowed = (propValue.length() == 0) ? - true : Boolean.valueOf(propValue); + boolean chdirAllowed = propValue.isEmpty() ? true : Boolean.parseBoolean(propValue); if (chdirAllowed) { this.needToResolveAgainstDefaultDirectory = true; } else { @@ -269,7 +268,7 @@ StringBuilder sb = new StringBuilder(); sb.append(first); for (String segment: more) { - if (segment.length() > 0) { + if (!segment.isEmpty()) { if (sb.length() > 0) sb.append('/'); sb.append(segment); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/windows/classes/java/io/WinNTFileSystem.java --- a/src/java.base/windows/classes/java/io/WinNTFileSystem.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/windows/classes/java/io/WinNTFileSystem.java Thu Dec 13 11:51:06 2018 -0800 @@ -64,7 +64,7 @@ } private String slashify(String p) { - if ((p.length() > 0) && (p.charAt(0) != slash)) return slash + p; + if (!p.isEmpty() && p.charAt(0) != slash) return slash + p; else return p; } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java --- a/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java Thu Dec 13 11:51:06 2018 -0800 @@ -145,9 +145,9 @@ */ String s1 = u1.getHost(); String s2 = u2.getHost(); - if ("localhost".equalsIgnoreCase(s1) && ( s2 == null || "".equals(s2))) + if ("localhost".equalsIgnoreCase(s1) && (s2 == null || s2.isEmpty())) return true; - if ("localhost".equalsIgnoreCase(s2) && ( s1 == null || "".equals(s1))) + if ("localhost".equalsIgnoreCase(s2) && (s1 == null || s1.isEmpty())) return true; return super.hostsEqual(u1, u2); } diff -r fd6de53a0d6e -r b94283cb226b src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java --- a/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java Thu Dec 13 11:51:06 2018 -0800 @@ -141,14 +141,8 @@ static boolean isFastFileTransferRequested() { String fileTransferProp = GetPropertyAction - .privilegedGetProperty("jdk.nio.enableFastFileTransfer"); - boolean enable; - if ("".equals(fileTransferProp)) { - enable = true; - } else { - enable = Boolean.parseBoolean(fileTransferProp); - } - return enable; + .privilegedGetProperty("jdk.nio.enableFastFileTransfer", "false"); + return fileTransferProp.isEmpty() ? true : Boolean.parseBoolean(fileTransferProp); } static { diff -r fd6de53a0d6e -r b94283cb226b src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java --- a/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java Thu Dec 13 11:51:06 2018 -0800 @@ -116,8 +116,7 @@ static { String propValue = GetPropertyAction.privilegedGetProperty( "sun.nio.fs.ensureAccurateMetadata", "false"); - ensureAccurateMetadata = (propValue.length() == 0) ? - true : Boolean.valueOf(propValue); + ensureAccurateMetadata = propValue.isEmpty() ? true : Boolean.parseBoolean(propValue); } // attributes diff -r fd6de53a0d6e -r b94283cb226b src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java --- a/src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/windows/classes/sun/nio/fs/WindowsFileStore.java Thu Dec 13 11:51:06 2018 -0800 @@ -52,7 +52,7 @@ // file store "display name" is the volume name if available String vol = volInfo.volumeName(); - if (vol.length() > 0) { + if (!vol.isEmpty()) { this.displayName = vol; } else { // TBD - should we map all types? Does this need to be localized? diff -r fd6de53a0d6e -r b94283cb226b src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java --- a/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystem.java Thu Dec 13 11:51:06 2018 -0800 @@ -218,7 +218,7 @@ StringBuilder sb = new StringBuilder(); sb.append(first); for (String segment: more) { - if (segment.length() > 0) { + if (!segment.isEmpty()) { if (sb.length() > 0) sb.append('\\'); sb.append(segment); diff -r fd6de53a0d6e -r b94283cb226b src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java --- a/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/windows/classes/sun/nio/fs/WindowsLinkSupport.java Thu Dec 13 11:51:06 2018 -0800 @@ -329,7 +329,7 @@ // remove special prefix String target = stripPrefix(new String(name)); - if (target.length() == 0) { + if (target.isEmpty()) { throw new IOException("Symbolic link target is invalid"); } return target; diff -r fd6de53a0d6e -r b94283cb226b src/java.base/windows/classes/sun/nio/fs/WindowsPath.java --- a/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java Thu Dec 13 11:51:06 2018 -0800 @@ -243,7 +243,7 @@ // relative to default directory String remaining = path.substring(root.length()); String defaultDirectory = getFileSystem().defaultDirectory(); - if (remaining.length() == 0) { + if (remaining.isEmpty()) { return defaultDirectory; } else if (defaultDirectory.endsWith("\\")) { return defaultDirectory + remaining; @@ -299,7 +299,7 @@ // -- Path operations -- private boolean isEmpty() { - return path.length() == 0; + return path.isEmpty(); } private WindowsPath emptyPath() { @@ -340,7 +340,7 @@ @Override public WindowsPath getRoot() { - if (root.length() == 0) + if (root.isEmpty()) return null; return new WindowsPath(getFileSystem(), type, root, root); } @@ -556,7 +556,7 @@ // corner case - all names removed if (remaining == 0) { - return (root.length() == 0) ? emptyPath() : getRoot(); + return root.isEmpty() ? emptyPath() : getRoot(); } // re-constitute the path from the remaining names. diff -r fd6de53a0d6e -r b94283cb226b src/jdk.jfr/share/classes/jdk/jfr/Recording.java --- a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java Thu Dec 13 11:51:06 2018 -0800 @@ -54,7 +54,7 @@ * System.gc(); * Thread.sleep(5000); * r.stop(); - * r.copyTo(Files.createTempFile("my-recording", ".jfr")); + * r.dump(Files.createTempFile("my-recording", ".jfr")); * * * diff -r fd6de53a0d6e -r b94283cb226b src/jdk.jfr/share/classes/jdk/jfr/consumer/package-info.java --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/package-info.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/package-info.java Thu Dec 13 11:51:06 2018 -0800 @@ -29,40 +29,27 @@ * In the following example, the program prints a histogram of all method samples in a recording. *
  * 
- *   public static void main(String[] args) {
- *     if (args.length != 0) {
- *       System.out.println("Must specify recording file.");
- *       return;
+ * public static void main(String[] args) throws IOException {
+ *     if (args.length != 1) {
+ *         System.err.println("Must specify a recording file.");
+ *         return;
  *     }
- *     try (RecordingFile f = new RecordingFile(Paths.get(args[0]))) {
- *       Map{@literal <}String, SimpleEntry{@literal <}String, Integer{@literal >}{@literal >} histogram = new HashMap{@literal <}{@literal >}();
- *       int total = 0;
- *       while (f.hasMoreEvents()) {
- *         RecordedEvent event = f.readEvent();
- *         if (event.getEventType().getName().equals("jdk.ExecutionSample")) {
- *           RecordedStackTrace s = event.getStackTrace();
- *           if (s != null) {
- *             RecordedFrame topFrame= s.getFrames().get(0);
- *             if (topFrame.isJavaFrame())  {
- *               RecordedMethod method = topFrame.getMethod();
- *               String methodName = method.getType().getName() + "#" + method.getName() + " " + method.getDescriptor();
- *               Entry entry = histogram.computeIfAbsent(methodName, u -{@literal >} new SimpleEntry{@literal <}String, Integer{@literal >}(methodName, 0));
- *               entry.setValue(entry.getValue() + 1);
- *               total++;
- *             }
- *           }
- *         }
- *       }
- *       List{@literal <}SimpleEntry{@literal <}String, Integer{@literal >}{@literal >} entries = new ArrayList{@literal <}{@literal >}(histogram.values());
- *       entries.sort((u, v) -{@literal >} v.getValue().compareTo(u.getValue()));
- *       for (SimpleEntry{@literal <}String, Integer{@literal >} c : entries) {
- *         System.out.printf("%2.0f%% %s\n", 100 * (float) c.getValue() / total, c.getKey());
- *       }
- *       System.out.println("\nSample count: " + total);
- *     } catch (IOException ioe) {
- *       System.out.println("Error reading file " + args[0] + ". " + ioe.getMessage());
- *     }
- *   }
+ *
+ *     RecordingFile.readAllEvents(Path.of(args[0])).stream()
+ *         .filter(e -> e.getEventType().getName().equals("jdk.ExecutionSample"))
+ *         .map(e -> e.getStackTrace())
+ *         .filter(s -> s != null)
+ *         .map(s -> s.getFrames().get(0))
+ *         .filter(f -> f.isJavaFrame())
+ *         .map(f -> f.getMethod())
+ *         .collect(
+ *             Collectors.groupingBy(m -> m.getType().getName() + "." + m.getName() + " " + m.getDescriptor(),
+ *             Collectors.counting()))
+ *         .entrySet()
+ *         .stream()
+ *         .sorted((a, b) -> b.getValue().compareTo(a.getValue()))
+ *         .forEach(e -> System.out.printf("%8d %s\n", e.getValue(), e.getKey()));
+ * }
  * 
  * 
*

diff -r fd6de53a0d6e -r b94283cb226b src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/JVM.java Thu Dec 13 11:51:06 2018 -0800 @@ -516,4 +516,11 @@ * @param emitAll emit all samples in old object queue */ public native void emitOldObjectSamples(long cutoff, boolean emitAll); + + /** + * Test if a chunk rotation is warranted. + * + * @return if it is time to perform a chunk rotation + */ + public native boolean shouldRotateDisk(); } diff -r fd6de53a0d6e -r b94283cb226b src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataHandler.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataHandler.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataHandler.java Thu Dec 13 11:51:06 2018 -0800 @@ -100,7 +100,7 @@ final Map types = new LinkedHashMap<>(200); final Map xmlTypes = new HashMap<>(20); - final Map xmlContentTypes = new HashMap<>(20); + final Map> xmlContentTypes = new HashMap<>(20); final List relations = new ArrayList<>(); long eventTypeId = 255; long structTypeId = 33; @@ -148,11 +148,8 @@ break; case "XmlContentType": String name = attributes.getValue("name"); - String type = attributes.getValue("annotationType"); - String value = attributes.getValue("annotationValue"); - Class annotationType = createAnnotationClass(type); - AnnotationElement ae = value == null ? new AnnotationElement(annotationType) : new AnnotationElement(annotationType, value); - xmlContentTypes.put(name, ae); + String annotation = attributes.getValue("annotation"); + xmlContentTypes.put(name, createAnnotationElements(annotation)); break; case "Relation": String n = attributes.getValue("name"); @@ -161,6 +158,27 @@ } } + private List createAnnotationElements(String annotation) throws InternalError { + String[] annotations = annotation.split(","); + List annotationElements = new ArrayList<>(); + for (String a : annotations) { + a = a.trim(); + int leftParenthesis = a.indexOf("("); + if (leftParenthesis == -1) { + annotationElements.add(new AnnotationElement(createAnnotationClass(a))); + } else { + int rightParenthesis = a.lastIndexOf(")"); + if (rightParenthesis == -1) { + throw new InternalError("Expected closing parenthesis for 'XMLContentType'"); + } + String value = a.substring(leftParenthesis + 1, rightParenthesis); + String type = a.substring(0, leftParenthesis); + annotationElements.add(new AnnotationElement(createAnnotationClass(type), value)); + } + } + return annotationElements; + } + @SuppressWarnings("unchecked") private Class createAnnotationClass(String type) { try { @@ -255,7 +273,7 @@ aes.add(new AnnotationElement(Unsigned.class)); } if (f.contentType != null) { - aes.add(Objects.requireNonNull(xmlContentTypes.get(f.contentType))); + aes.addAll(Objects.requireNonNull(xmlContentTypes.get(f.contentType))); } if (f.relation != null) { aes.add(Objects.requireNonNull(relationMap.get(f.relation))); diff -r fd6de53a0d6e -r b94283cb226b src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java Thu Dec 13 11:51:06 2018 -0800 @@ -427,19 +427,13 @@ } private void periodicTask() { + if (!jvm.hasNativeJFR()) { + return; + } while (true) { synchronized (this) { - if (!jvm.hasNativeJFR()) { - return; - } - if (currentChunk != null) { - try { - if (SecuritySupport.getFileSize(currentChunk.getUnfishedFile()) > Options.getMaxChunkSize()) { - rotateDisk(); - } - } catch (IOException e) { - Logger.log(JFR_SYSTEM, WARN, "Could not check file size to determine chunk rotation"); - } + if (jvm.shouldRotateDisk()) { + rotateDisk(); } } long minDelta = RequestEngine.doPeriodic(); diff -r fd6de53a0d6e -r b94283cb226b src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecording.java Thu Dec 13 11:51:06 2018 -0800 @@ -123,7 +123,7 @@ options.add("maxage=" + Utils.formatTimespan(maxAge, "")); } if (maxSize != 0) { - options.add("maxsize=" + Utils.formatBytes(maxSize, "")); + options.add("maxsize=" + Utils.formatBytesCompact(maxSize)); } if (dumpOnExit) { options.add("dumponexit=true"); diff -r fd6de53a0d6e -r b94283cb226b src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java Thu Dec 13 11:51:06 2018 -0800 @@ -103,18 +103,53 @@ } } - public static String formatBytes(long bytes, String separation) { - if (bytes == 1) { - return "1 byte"; + // Tjis method can't handle Long.MIN_VALUE because absolute value is negative + private static String formatDataAmount(String formatter, long amount) { + int exp = (int) (Math.log(Math.abs(amount)) / Math.log(1024)); + char unitPrefix = "kMGTPE".charAt(exp - 1); + return String.format(formatter, amount / Math.pow(1024, exp), unitPrefix); + } + + public static String formatBytesCompact(long bytes) { + if (bytes < 1024) { + return String.valueOf(bytes); } - if (bytes < 1024) { + return formatDataAmount("%.1f%cB", bytes); + } + + public static String formatBits(long bits) { + if (bits == 1 || bits == -1) { + return bits + " bit"; + } + if (bits < 1024 && bits > -1024) { + return bits + " bits"; + } + return formatDataAmount("%.1f %cbit", bits); + } + + public static String formatBytes(long bytes) { + if (bytes == 1 || bytes == -1) { + return bytes + " byte"; + } + if (bytes < 1024 && bytes > -1024) { return bytes + " bytes"; } - int exp = (int) (Math.log(bytes) / Math.log(1024)); - char bytePrefix = "kMGTPE".charAt(exp - 1); - return String.format("%.1f%s%cB", bytes / Math.pow(1024, exp), separation, bytePrefix); + return formatDataAmount("%.1f %cB", bytes); } + public static String formatBytesPerSecond(long bytes) { + if (bytes < 1024 && bytes > -1024) { + return bytes + " byte/s"; + } + return formatDataAmount("%.1f %cB/s", bytes); + } + + public static String formatBitsPerSecond(long bits) { + if (bits < 1024 && bits > -1024) { + return bits + " bps"; + } + return formatDataAmount("%.1f %cbps", bits); + } public static String formatTimespan(Duration dValue, String separation) { if (dValue == null) { return "0"; diff -r fd6de53a0d6e -r b94283cb226b src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java Thu Dec 13 11:51:06 2018 -0800 @@ -109,7 +109,7 @@ try { print(" "); long bytes = SecuritySupport.getFileSize(file); - printBytes(bytes, " "); + printBytes(bytes); } catch (IOException e) { // Ignore, not essential } @@ -152,8 +152,8 @@ println(); } - protected final void printBytes(long bytes, String separation) { - print(Utils.formatBytes(bytes, separation)); + protected final void printBytes(long bytes) { + print(Utils.formatBytes(bytes)); } protected final void printTimespan(Duration timespan, String separator) { diff -r fd6de53a0d6e -r b94283cb226b src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdCheck.java Thu Dec 13 11:51:06 2018 -0800 @@ -39,6 +39,7 @@ import jdk.jfr.internal.LogLevel; import jdk.jfr.internal.LogTag; import jdk.jfr.internal.Logger; +import jdk.jfr.internal.Utils; /** * JFR.check - invoked from native @@ -117,7 +118,7 @@ long maxSize = recording.getMaxSize(); if (maxSize != 0) { print(" maxsize="); - printBytes(maxSize, ""); + print(Utils.formatBytesCompact(maxSize)); } Duration maxAge = recording.getMaxAge(); if (maxAge != null) { diff -r fd6de53a0d6e -r b94283cb226b src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdConfigure.java Thu Dec 13 11:51:06 2018 -0800 @@ -193,25 +193,25 @@ private void printGlobalBufferSize() { print("Global buffer size: "); - printBytes(Options.getGlobalBufferSize(), " "); + printBytes(Options.getGlobalBufferSize()); println(); } private void printThreadBufferSize() { print("Thread buffer size: "); - printBytes(Options.getThreadBufferSize(), " "); + printBytes(Options.getThreadBufferSize()); println(); } private void printMemorySize() { print("Memory size: "); - printBytes(Options.getMemorySize(), " "); + printBytes(Options.getMemorySize()); println(); } private void printMaxChunkSize() { print("Max chunk size: "); - printBytes(Options.getMaxChunkSize(), " "); + printBytes(Options.getMaxChunkSize()); println(); } } diff -r fd6de53a0d6e -r b94283cb226b src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java Thu Dec 13 11:47:35 2018 -0800 +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/tool/PrettyWriter.java Thu Dec 13 11:51:06 2018 -0800 @@ -315,11 +315,7 @@ printArray((Object[]) value); return; } - if (field.getContentType() != null) { - if (printFormatted(field, value)) { - return; - } - } + if (value instanceof Double) { Double d = (Double) value; if (Double.isNaN(d) || d == Double.NEGATIVE_INFINITY) { @@ -349,6 +345,12 @@ } } + if (field.getContentType() != null) { + if (printFormatted(field, value)) { + return; + } + } + String text = String.valueOf(value); if (value instanceof String) { text = "\"" + text + "\""; @@ -472,7 +474,7 @@ private boolean printFormatted(ValueDescriptor field, Object value) { if (value instanceof Duration) { Duration d = (Duration) value; - if (d.getSeconds() == Long.MIN_VALUE) { + if (d.getSeconds() == Long.MIN_VALUE && d.getNano() == 0) { println("N/A"); return true; } @@ -513,12 +515,26 @@ if (dataAmount != null) { if (value instanceof Number) { Number n = (Number) value; - String bytes = Utils.formatBytes(n.longValue(), " "); + long amount = n.longValue(); if (field.getAnnotation(Frequency.class) != null) { - bytes += "/s"; + if (dataAmount.value().equals(DataAmount.BYTES)) { + println(Utils.formatBytesPerSecond(amount)); + return true; + } + if (dataAmount.value().equals(DataAmount.BITS)) { + println(Utils.formatBitsPerSecond(amount)); + return true; + } + } else { + if (dataAmount.value().equals(DataAmount.BYTES)) { + println(Utils.formatBytes(amount)); + return true; + } + if (dataAmount.value().equals(DataAmount.BITS)) { + println(Utils.formatBits(amount)); + return true; + } } - println(bytes); - return true; } } MemoryAddress memoryAddress = field.getAnnotation(MemoryAddress.class); @@ -529,6 +545,14 @@ return true; } } + Frequency frequency = field.getAnnotation(Frequency.class); + if (frequency != null) { + if (value instanceof Number) { + println(value + " Hz"); + return true; + } + } + return false; } diff -r fd6de53a0d6e -r b94283cb226b test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/runtime/Safepoint/TestAbortOnVMOperationTimeout.java Thu Dec 13 11:51:06 2018 -0800 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2018, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.*; +import jdk.test.lib.process.*; + +/* + * @test TestAbortOnVMOperationTimeout + * @bug 8181143 + * @summary Check abort on VM timeout is working + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + */ + +public class TestAbortOnVMOperationTimeout { + + public static void main(String[] args) throws Exception { + if (args.length > 0) { + Object[] arr = new Object[10_000_000]; + for (int i = 0; i < arr.length; i++) { + arr[i] = new Object(); + } + return; + } + + // These should definitely pass: more than a minute is enough for Serial to act. + // The values are deliberately non-round to trip off periodic task granularity. + for (int delay : new int[]{63423, 12388131}) { + testWith(delay, true); + } + + // These should fail: Serial is not very fast. Traversing 10M objects in 5 ms + // means less than 0.5 ns per object, which is not doable. + for (int delay : new int[]{0, 1, 5}) { + testWith(delay, false); + } + } + + public static void testWith(int delay, boolean shouldPass) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+AbortVMOnVMOperationTimeout", + "-XX:AbortVMOnVMOperationTimeoutDelay=" + delay, + "-Xmx256m", + "-XX:+UseSerialGC", + "-XX:-CreateCoredumpOnCrash", + "TestAbortOnVMOperationTimeout", + "foo" + ); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + if (shouldPass) { + output.shouldHaveExitValue(0); + } else { + output.shouldMatch("VM operation took too long"); + output.shouldNotHaveExitValue(0); + } + } +} + diff -r fd6de53a0d6e -r b94283cb226b test/jdk/java/lang/constant/ClassDescTest.java --- a/test/jdk/java/lang/constant/ClassDescTest.java Thu Dec 13 11:47:35 2018 -0800 +++ b/test/jdk/java/lang/constant/ClassDescTest.java Thu Dec 13 11:51:06 2018 -0800 @@ -244,6 +244,29 @@ testBadNestedClasses(ClassDesc.ofDescriptor(p.descriptor), "any"); testBadNestedClasses(ClassDesc.ofDescriptor(p.descriptor), "any", "other"); } + + ClassDesc stringDesc = ClassDesc.ofDescriptor("Ljava/lang/String;"); + ClassDesc stringArrDesc = stringDesc.arrayType(255); + try { + ClassDesc arrGreaterThan255 = stringArrDesc.arrayType(); + fail("can't create an array type descriptor with more than 255 dimensions"); + } catch (IllegalStateException e) { + // good + } + String descWith255ArrayDims = new String(new char[255]).replace('\0', '['); + try { + ClassDesc arrGreaterThan255 = ClassDesc.ofDescriptor(descWith255ArrayDims + "[Ljava/lang/String;"); + fail("can't create an array type descriptor with more than 255 dimensions"); + } catch (IllegalArgumentException e) { + // good + } + try { + ClassDesc arrWith255Dims = ClassDesc.ofDescriptor(descWith255ArrayDims + "Ljava/lang/String;"); + arrWith255Dims.arrayType(1); + fail("can't create an array type descriptor with more than 255 dimensions"); + } catch (IllegalArgumentException e) { + // good + } } private void testBadNestedClasses(ClassDesc cr, String firstNestedName, String... moreNestedNames) { diff -r fd6de53a0d6e -r b94283cb226b test/jdk/jdk/jfr/api/metadata/annotations/TestFormatMissingValue.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/jdk/jfr/api/metadata/annotations/TestFormatMissingValue.java Thu Dec 13 11:51:06 2018 -0800 @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.jfr.api.metadata.annotations; + +import jdk.jfr.DataAmount; +import jdk.jfr.Event; +import jdk.jfr.Frequency; +import jdk.jfr.Recording; +import jdk.jfr.StackTrace; +import jdk.jfr.consumer.RecordedEvent; +import jdk.test.lib.Asserts; +import jdk.test.lib.jfr.Events; + +/** + * @test + * @key jfr + * @summary Check that event values are properly formatted and sanity check + * that extreme values don't throws exceptions + * @requires vm.hasJFR + * @library /test/lib + * @run main/othervm jdk.jfr.api.metadata.annotations.TestFormatMissingValue + */ +public class TestFormatMissingValue { + + @StackTrace(false) + static class MultiContentTypeEvent extends Event { + @DataAmount(DataAmount.BYTES) + @Frequency + long a = Long.MIN_VALUE; + + @DataAmount(DataAmount.BYTES) + @Frequency + long b = Long.MAX_VALUE; + + @DataAmount(DataAmount.BYTES) + @Frequency + int c = Integer.MIN_VALUE; + + @DataAmount(DataAmount.BYTES) + @Frequency + int d = Integer.MAX_VALUE; + + @DataAmount(DataAmount.BYTES) + @Frequency + double e = Double.NEGATIVE_INFINITY; + + @DataAmount(DataAmount.BYTES) + @Frequency + double f = Double.POSITIVE_INFINITY; + + @DataAmount(DataAmount.BYTES) + @Frequency + double g = Double.NaN; + + @DataAmount(DataAmount.BYTES) + @Frequency + float h = Float.NEGATIVE_INFINITY; + + @DataAmount(DataAmount.BYTES) + @Frequency + float i = Float.POSITIVE_INFINITY; + + @DataAmount(DataAmount.BYTES) + @Frequency + float j = Float.NaN; + } + + public static void main(String[] args) throws Exception { + try (Recording r = new Recording()) { + r.start(); + MultiContentTypeEvent m = new MultiContentTypeEvent(); + m.commit(); + r.stop(); + for (RecordedEvent e : Events.fromRecording(r)) { + String t = e.toString(); + assertContains(t, "a = N/A"); + assertContains(t, "c = N/A"); + assertContains(t, "e = N/A"); + assertContains(t, "g = N/A"); + assertContains(t, "h = N/A"); + assertContains(t, "j = N/A"); + + assertNotContains(t, "b = N/A"); + assertNotContains(t, "d = N/A"); + assertNotContains(t, "f = N/A"); + assertNotContains(t, "i = N/A"); + } + } + } + + private static void assertContains(String t, String text) { + if (!t.contains(text)) { + Asserts.fail("Expected '" + t + "' to contain text '" + text + "'"); + } + } + + private static void assertNotContains(String t, String text) { + if (t.contains(text)) { + Asserts.fail("Found unexpected value '" + text + "' in text '" + t + "'"); + } + } +}