JDK-8187253 : The "com.sun.awt.AWTUtilities" class can be dropped in favour of public API
  • Type: CSR
  • Component: client-libs
  • Sub-Component: java.awt
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 10
  • Submitted: 2017-09-05
  • Updated: 2018-06-25
  • Resolved: 2017-10-27
Related Reports
CSR :  
Relates :  
Description
Summary
-------

Deprecate for removal com.sun.awt.AWTUtilities.

Problem
-------

The client code has a "com.sun.awt.AWTUtilities" class which at some point in the past, JDK 6u10, was used as a kind of "public" API.

    Notes:
     - In the latest version of jdk9 the default value of "--illegal-access" was changed, so this class is accessible at runtime,
       but still is not accessible at compile time or when the option "--illegal-access=deny" is specified.
     - jdeps is also reports this package as internal " -> com.sun.awt  JDK internal API (java.desktop)"


    In jdk9 the "src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java" is inaccessible and all its functionality was already provided by the public API:

    AWTUtilities.isTranslucencySupported()/AWTUtilities.isWindowShapingSupported()
        -> java.awt.GraphicsDevice.isWindowTranslucencySupported()

    AWTUtilities.setWindowOpacity()/AWTUtilities.getWindowOpacity()
        -> java.awt.Window.setOpacity/getOpacity

    AWTUtilities.getWindowShape()/AWTUtilities.setWindowShape()
        -> java.awt.Window.setShape()/getShape()

    AWTUtilities.setWindowOpaque/AWTUtilities.isWindowOpaque
        -> java.awt.Window.setBackground()/isOpaque()

    AWTUtilities.isTranslucencyCapable
        -> java.awt.GraphicsConfiguration.isTranslucencyCapable()

    AWTUtilities.setComponentMixingCutoutShape
        -> java.awt.Component.setMixingCutoutShape() 


Solution
--------

The solutions is to deprecate this APi in jdk10 and remove later.

Specification: http://cr.openjdk.java.net/~serb/8186617/webrev.01/src/java.desktop/share/classes/com/sun/awt/AWTUtilities.java.udiff.html

    =====================
     * <b>WARNING</b>: This class is an implementation detail and only meant
     * for limited use outside of the core platform. This API may change
     * drastically between update release, and it may even be
     * removed or be moved in some other package(s)/class(es).
     */
    +@Deprecated(forRemoval = true, since = "10")
     public final class AWTUtilities {

    =====================
    +* @deprecated use {@link GraphicsDevice#isWindowTranslucencySupported}
    +*             instead
     */
    +@Deprecated(forRemoval = true, since = "10")
     public static boolean isTranslucencySupported(Translucency translucencyKind) {

     =====================
    +* @deprecated use {@link Window#setOpacity} instead
     */
    +@Deprecated(forRemoval = true, since = "10")
     public static void setWindowOpacity(Window window, float opacity) {

     =====================
    +* @deprecated use {@link Window#getOpacity} instead
     */
    +@Deprecated(forRemoval = true, since = "10")
     public static float getWindowOpacity(Window window) {

     =====================
    +* @deprecated use {@link GraphicsDevice#isWindowTranslucencySupported}
    +*             instead
     */
    +@Deprecated(forRemoval = true, since = "10")
     public static boolean isWindowShapingSupported() {

     =====================
    +* @deprecated use {@link Window#getShape} instead
     */
    +@Deprecated(forRemoval = true, since = "10")
     public static Shape getWindowShape(Window window) {

     =====================
    +* @deprecated use {@link Window#setShape} instead
     */
    +@Deprecated(forRemoval = true, since = "10")
     public static void setWindowShape(Window window, Shape shape) {

     =====================
    +* @deprecated use {@link Window#setBackground} instead
     */
    +@Deprecated(forRemoval = true, since = "10")
     public static void setWindowOpaque(Window window, boolean isOpaque) {

     =====================
    +* @deprecated use {@link Window#isOpaque} instead
     */
    +@Deprecated(forRemoval = true, since = "10")
     public static boolean isWindowOpaque(Window window) {

     =====================
    +* @deprecated use {@link GraphicsConfiguration#isTranslucencyCapable}
    +*             instead
     */
    +@Deprecated(forRemoval = true, since = "10")
     public static boolean isTranslucencyCapable(GraphicsConfiguration gc) {

     =====================
    +* @deprecated use {@link Component#setMixingCutoutShape} instead
     */
    -@Deprecated(since = "9")
    +@Deprecated(forRemoval = true, since = "9")
     public static void setComponentMixingCutoutShape(Component component,
         Shape shape)

Comments
Moving to approved.
27-10-2017

CSR is updated as requested.
20-10-2017

@Sergey, please withdraw the request, update it as Phil has suggested, and re-finalized it.
04-10-2017

We have no compelling reason to rush to remove it in JDK 10, and since JDK 10 is going to be just 6 months after 9 .. not 2-3 years ... it should be OK to deprecate it for removal for a release before it is removed. Either way a release note should be added.
22-09-2017

Pending until hearing back from Phil and a response to the suggestion for a more phased removal.
22-09-2017

It may be a gentler path to deprecate this for removal in JDK 10/18.3 and then remove it in JDK 11/18.9. In any case, a release note should be created on the parent issue. Please also have Phil Race review this request.
18-09-2017

In JDK 9, the classes in com.sun.awt are not accessible at compile-time but are accessible at run-time. So I think this CSR needs to say a bit more about the potential users of API, esp. as it hasn't been deprecated-for-removal in advance.
15-09-2017