-
CSR
-
Resolution: Unresolved
-
P5
-
None
-
source, binary, behavioral
-
minimal
-
Removing the synchronized modifier from Color.createContext() has no impact on existing callers, as the method does not access any shared mutable state.
-
Java API
-
SE
Summary
At some point java.awt.Color.createContext() was marked as synchronized to support caching of a ColorPaintContext instance. Although the caching logic was removed, the synchronized modifier remained in place.
Problem
The method is still marked as synchronized despite no longer accessing shared mutable state. This introduces unnecessary synchronization overhead which can degrade performance in multi-threaded rendering scenarios.
Solution
Drop the "synchronized" keyword from the java.awt.Color#createContext() method to reduce the overhead of the method in multi-core environments.
Specification
java/awt/Color.java
- public synchronized PaintContext createContext(ColorModel cm, Rectangle r,
- Rectangle2D r2d,
- AffineTransform xform,
- RenderingHints hints) {
+ public PaintContext createContext(ColorModel cm, Rectangle r,
+ Rectangle2D r2d, AffineTransform xform,
+ RenderingHints hints) {
- csr of
-
JDK-8355078 java.awt.Color.createContext() uses unnecessary synchronization
-
- Open
-