JDK-4787241 : java.awt.Color caches context objects permanently
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.2.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2002-12-03
  • Updated: 2020-02-23
  • Resolved: 2020-02-23
Related Reports
Duplicate :  
Description
The java.awt.Color class caches instances of its PaintContext when anyone
calls the createContext method.  While this does not normally occur during
typical rendering operations since the underlying graphics code special
cases the Color object, it could potentially lead to excess resource
consumption in an application that either invokes the createContext method
directly or which uses a-typical rendering modes that don't special case
the Color object.

Comments
EVALUATION This is clearly the wrong level of caching for this type of object. The cost of constructing the ColorPaintContext object should be almost unnoticeable with the HotSpot VM. The object itself also caches a raster filled with the color and that may be somewhat expensive to create, but the relative rarity that this method would be called during normal operations does not justify caching one of these Raster objects per ColorPaintContext. The cached raster should be held in some sort of non-strong Reference and it should be shared among all instances of CPC... ###@###.### 2004-01-20
20-01-2004