--- old/modules/graphics/src/main/java/com/sun/prism/impl/paint/MultipleGradientContext.java 2016-05-05 14:08:38.280749809 +0530 +++ new/modules/graphics/src/main/java/com/sun/prism/impl/paint/MultipleGradientContext.java 2016-05-05 14:08:38.096752122 +0530 @@ -202,14 +202,18 @@ normalizedIntervals[i] : Imin; } + // Is Imin zero? + final boolean canDivideByImin = Float.isFinite(1.0f/Imin); // Estimate the size of the entire gradients array. // This is to prevent a tiny interval from causing the size of array // to explode. If the estimated size is too large, break to using // separate arrays for each interval, and using an indexing scheme at // look-up time. int estimatedSize = 0; - for (int i = 0; i < normalizedIntervals.length; i++) { - estimatedSize += (normalizedIntervals[i]/Imin) * GRADIENT_SIZE; + if (canDivideByImin) { + for (int i = 0; i < normalizedIntervals.length; i++) { + estimatedSize += (normalizedIntervals[i]/Imin) * GRADIENT_SIZE; + } } if (estimatedSize > MAX_GRADIENT_ARRAY_SIZE) { @@ -254,11 +258,14 @@ //the eventual size of the single array int gradientsTot = 1; + // Is Imin zero? + final boolean canDivideByImin = Float.isFinite(1.0f/Imin); // for every interval (transition between 2 colors) for (int i = 0; i < gradients.length; i++) { // create an array whose size is based on the ratio to the // smallest interval - int nGradients = (int)((normalizedIntervals[i]/Imin)*255f); + int nGradients = canDivideByImin + ? (int)((normalizedIntervals[i]/Imin)*255f) : 0; gradientsTot += nGradients; gradients[i] = new int[nGradients];