diff -r 6064cd8725fa -r 793e481c7641 src/java.desktop/share/classes/sun/java2d/marlin/DDasher.java --- a/src/java.desktop/share/classes/sun/java2d/marlin/DDasher.java Mon May 07 13:36:36 2018 -0700 +++ b/src/java.desktop/share/classes/sun/java2d/marlin/DDasher.java Tue May 08 10:13:21 2018 +0200 @@ -137,8 +137,8 @@ * @param recycleDashes true to indicate to recycle the given dash array * @return this instance */ - DDasher init(final DPathConsumer2D out, double[] dash, int dashLen, - double phase, boolean recycleDashes) + DDasher init(final DPathConsumer2D out, final double[] dash, final int dashLen, + double phase, final boolean recycleDashes) { this.out = out; @@ -146,9 +146,10 @@ int sidx = 0; dashOn = true; + // note: BasicStroke constructor checks dash elements and sum > 0 double sum = 0.0d; - for (double d : dash) { - sum += d; + for (int i = 0; i < dashLen; i++) { + sum += dash[i]; } this.cycleLen = sum; @@ -158,13 +159,13 @@ phase = 0.0d; } else { int fullcycles = FloatMath.floor_int(-cycles); - if ((fullcycles & dash.length & 1) != 0) { + if ((fullcycles & dashLen & 1) != 0) { dashOn = !dashOn; } phase += fullcycles * sum; while (phase < 0.0d) { if (--sidx < 0) { - sidx = dash.length - 1; + sidx = dashLen - 1; } phase += dash[sidx]; dashOn = !dashOn; @@ -175,14 +176,14 @@ phase = 0.0d; } else { int fullcycles = FloatMath.floor_int(cycles); - if ((fullcycles & dash.length & 1) != 0) { + if ((fullcycles & dashLen & 1) != 0) { dashOn = !dashOn; } phase -= fullcycles * sum; double d; while (phase >= (d = dash[sidx])) { phase -= d; - sidx = (sidx + 1) % dash.length; + sidx = (sidx + 1) % dashLen; dashOn = !dashOn; } }