This is a failure introduced by the fix
6530420: remove unnecessary fields in Color class
The javadoc for Color.createContext(ColorModel cm, Rectangle r,
Rectangle2D r2d, AffineTransform xform, RenderingHints hints)
states
* The same <code>PaintContext</code> is returned, regardless of
1166 * whether or not <code>r</code>, <code>r2d</code>,
1167 * <code>xform</code>, or <code>hints</code> are <code>null</code>.
A JCK test apparently tests for this by creating contexts which differ
in small ways, such as passing in a Rectangle in one case, and null in the other,
similar to this code :
import java.awt.*;
import java.awt.geom.*;
import java.awt.image.*;
public class tc4 {
public static void main(String args[]) {
float[] cp = { 0.5f, 0.5f, 0.5f, 0.5f };
ColorModel cm = ColorModel.getRGBdefault();
Rectangle r = new Rectangle(0, 0, 200, 200);
Rectangle2D.Float r2d = new Rectangle2D.Float(0f, 0f, 100f, 100f);
AffineTransform af = new AffineTransform();
Color c = new Color(cp[0], cp[1], cp[2], cp[3]);
PaintContext pContext1 = c.createContext(cm, null, r2d, af,
new RenderingHints(RenderingHints.KEY_ALPHA_INTERPOLATION,
RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT));
PaintContext pContext2 = c.createContext(cm, r, r2d, af,
new RenderingHints(RenderingHints.KEY_ALPHA_INTERPOLATION,
RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT));
System.out.println(pContext1.equals(pContext2));
}
}
Prior to 1.7 b14 this would print "true" now it prints "false"
The reason for this is that previously the code "cached" a PaintContext.
Now it always returns a new instance, which would be "equal" except that
the implementing class does not over-ride equals.
Also the text "the same PaintContext" is not specific as to whether it means
"equal" or the stronger "==".
There is also the question of the "cm" parameter. Although the test uses the
same "cm" parameter, it seems a bit odd and unreasonable to expect that the
Color instance caches a PaintContext for each ColorModel, so as to always
return the same instance. However a strict reading of the spec might require this.
But in practice this doesn't matter as although the "cm" instance is passed
to the constructor of the class which implements PaintContext, that class
discards it. So in fact you really do always get equivalent PaintContext
instances regardless of the cm parameter.
Perhaps the most pragmatic way to resolve this is for the PaintContext
to override equals, but it would be good to also update the doc to
use the word "equal" rather than "the same".