8232225: Rework the fix for JDK-8071483
authorserb
Tue, 15 Oct 2019 22:42:23 -0700
changeset 59167 2cf90f3e8195
parent 58602 d97e1ee31e2b
child 59168 8612b8012718
8232225: Rework the fix for JDK-8071483 Reviewed-by: prr
test/jdk/java/awt/Color/AlphaColorTest.java
test/jdk/java/awt/Color/GetMinMaxValue_ICC_ColorSpace.java
test/jdk/java/awt/Color/HeadlessColor.java
test/jdk/java/awt/Color/LoadProfileWithSM.java
test/jdk/java/awt/Color/LoadStandardProfilesTest.java
test/jdk/java/awt/Color/OpacityChange/OpacityChange.java
test/jdk/java/awt/Color/XRenderTranslucentColorDrawTest.java
test/jdk/java/awt/ColorClass/AlphaColorTest.java
test/jdk/java/awt/ColorClass/HeadlessColor.java
test/jdk/java/awt/ColorClass/OpacityChange/OpacityChange.java
test/jdk/java/awt/ColorClass/XRenderTranslucentColorDrawTest.java
test/jdk/java/awt/color/GetMinMaxValue_ICC_ColorSpace.java
test/jdk/java/awt/color/LoadProfileWithSM.java
test/jdk/java/awt/color/LoadStandardProfilesTest.java
--- a/test/jdk/java/awt/Color/AlphaColorTest.java	Tue Oct 15 14:19:55 2019 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * @test
- * @key headful
- * @bug 8204931 8227392 8224825
- * @summary test alpha colors are blended with background.
- */
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.Robot;
-import javax.swing.SwingUtilities;
-
-public class AlphaColorTest extends Component {
-
-    private Color color;
-
-    public AlphaColorTest(Color c) {
-       this.color = c;
-    }
-
-    public void paint(Graphics g) {
-        g.setColor(color);
-        g.fillRect(0, 0, getSize().width, getSize().height);
-    }
-
-    public Dimension getPreferredSize() {
-        return getSize();
-    }
-
-    public Dimension getSize() {
-        return new Dimension(200, 200);
-    }
-
-    public static void main(String args[]) throws Exception {
-        SwingUtilities.invokeAndWait(() -> createAndShowGUI());
-        Robot robot = new Robot();
-        robot.delay(5000);
-        robot.waitForIdle();
-        Color c = robot.getPixelColor(frame.getX() + 100, frame.getY() + 100);
-        int red = c.getRed();
-        frame.dispose();
-        // Should be 126-128, but be tolerant of gamma correction.
-        if (red < 122 || red > 132) {
-            throw new RuntimeException("Color is not as expected. Got " + c);
-        }
-     }
-
-    static Frame frame;
-    private static void createAndShowGUI() {
-        frame = new Frame("Alpha Color Test") {
-            @Override
-            public void paint(Graphics g) {
-                g.setColor(Color.black);
-                g.fillRect(0, 0, getWidth(), getHeight());
-                super.paint(g);
-            }
-        };
-        Color color = new Color(255, 255, 255, 127);
-        frame.add("Center", new AlphaColorTest(color));
-        frame.pack();
-        frame.setVisible(true);
-    }
-}
--- a/test/jdk/java/awt/Color/GetMinMaxValue_ICC_ColorSpace.java	Tue Oct 15 14:19:55 2019 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-import java.awt.color.ColorSpace;
-import java.awt.color.ICC_ColorSpace;
-import java.awt.color.ICC_Profile;
-import java.io.IOException;
-
-/**
-  * @test
-  * @bug 8072678
-  * @author Prasanta Sadhukhan
-  */
-
-public class GetMinMaxValue_ICC_ColorSpace {
-
-    public static void main(String[] a) throws Exception {
-        ICC_Profile cmyk_profile = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
-        ICC_ColorSpace colorSpace = new ICC_ColorSpace(cmyk_profile);
-        String minstr = null;
-        String maxstr = null;
-
-        colorSpace.fromRGB(new float[]{4.3f,3.1f,2.2f});
-        try {
-            System.out.println("minvalue " + colorSpace.getMinValue(3));
-        } catch (IllegalArgumentException iae) {
-            minstr = iae.toString();
-        }
-        try {
-            System.out.println("maxvalue " + colorSpace.getMaxValue(3));
-        } catch (IllegalArgumentException iae) {
-            maxstr = iae.toString();
-        }
-
-        if (minstr.endsWith("+ component") || maxstr.endsWith("+ component")) {
-            System.out.println("Test failed");
-            throw new RuntimeException("IllegalArgumentException contains incorrect text message");
-        } else {
-            System.out.println("Test passed");
-        }
-    }
-}
--- a/test/jdk/java/awt/Color/HeadlessColor.java	Tue Oct 15 14:19:55 2019 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,225 +0,0 @@
-/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.awt.*;
-import java.awt.color.ColorSpace;
-
-/*
- * @test
- * @summary Check Color constructors and methods works correctly in headless mode
- * @run main/othervm -Djava.awt.headless=true HeadlessColor
- */
-
-public class HeadlessColor {
-    public static void main(String args[]) {
-        Color c;
-
-        // Constructors without exceptions
-        c = new Color(1, 2, 3);
-        c = new Color(1, 2, 3, 4);
-        c = new Color((1 << 16) | (2 << 8) | (3));
-        c = new Color((1 << 24) | (1 << 16) | (2 << 8) | (3));
-        c = new Color((1 << 24) | (2 << 16) | (3 << 8) | (4), true);
-        c = new Color((2 << 16) | (3 << 8) | (4), false);
-        c = new Color(0.8f, 0.8f, 0.3f);
-        c = new Color(0.999f, 0.8f, 0.8f, 0.3f);
-        c = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB),
-                new float[]{0.8f, 0.8f, 0.3f}, 1f);
-
-        // Constructors with exceptions
-        boolean exceptions = false;
-        try {
-            c = new Color(409, 400, 400);
-        } catch (IllegalArgumentException e) {
-            exceptions = true;
-        }
-        if (!exceptions)
-            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
-                    "when expected in headless mode");
-
-        exceptions = false;
-        try {
-            c = new Color(400, 3003, 400, 400);
-        } catch (IllegalArgumentException e) {
-            exceptions = true;
-        }
-        if (!exceptions)
-            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
-                    "when expected in headless mode");
-
-        exceptions = false;
-        try {
-            c = new Color(8f, 8f, 3f);
-        } catch (IllegalArgumentException e) {
-            exceptions = true;
-        }
-        if (!exceptions)
-            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
-                    "when expected in headless mode");
-
-        exceptions = false;
-        try {
-            c = new Color(-8f, -8f, -3f);
-        } catch (IllegalArgumentException e) {
-            exceptions = true;
-        }
-        if (!exceptions)
-            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
-                    "when expected in headless mode");
-
-        exceptions = false;
-        try {
-            c = new Color(0.999f, 8f, 8f, 3f);
-        } catch (IllegalArgumentException e) {
-            exceptions = true;
-        }
-        if (!exceptions)
-            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
-                    "when expected in headless mode");
-
-        exceptions = false;
-        try {
-            c = new Color(20f, 8f, 8f, 3f);
-        } catch (IllegalArgumentException e) {
-            exceptions = true;
-        }
-        if (!exceptions)
-            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
-                    "when expected in headless mode");
-
-        exceptions = false;
-        try {
-            c = new Color(-20f, -8f, -8f, -3f);
-        } catch (IllegalArgumentException e) {
-            exceptions = true;
-        }
-        if (!exceptions)
-            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
-                    "when expected in headless mode");
-
-        exceptions = false;
-        try {
-            c = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB),
-                    new float[]{-8f, -8f, -3f}, 1f);
-        } catch (IllegalArgumentException e) {
-            exceptions = true;
-        }
-        if (!exceptions)
-            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
-                    "when expected in headless mode");
-
-        exceptions = false;
-        try {
-            c = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB),
-                    new float[]{-8f, -8f, -3f}, -1f);
-        } catch (IllegalArgumentException e) {
-            exceptions = true;
-        }
-        if (!exceptions)
-            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
-                    "when expected in headless mode");
-
-
-        c = new Color(1, 2, 3);
-        c.hashCode();
-        c.toString();
-        if (c.getRed() != 1)
-            throw new RuntimeException("Incorrect red value");
-        if (c.getGreen() != 2)
-            throw new RuntimeException("Incorrect green value");
-        if (c.getBlue() != 3)
-            throw new RuntimeException("Incorrect bluevalue");
-        if (c.getAlpha() != 255)
-            throw new RuntimeException("Incorrect alpha value");
-        if (c.getRGB() != ((255 << 24) | (1 << 16) | (2 << 8) | (3)))
-            throw new RuntimeException("Incorrect rgb value");
-
-        int rgb = c.getRGB();
-        c.brighter();
-        if (rgb != c.getRGB())
-            throw new RuntimeException("Color object changed RGB value after brighter() called");
-
-        rgb = c.getRGB();
-        c.darker();
-        if (rgb != c.getRGB())
-            throw new RuntimeException("Color object changed RGB value after brighter() called");
-
-        c = new Color(1, 2, 3, 4);
-        c.hashCode();
-        c.toString();
-        if (c.getRed() != 1)
-            throw new RuntimeException("Incorrect red value");
-        if (c.getGreen() != 2)
-            throw new RuntimeException("Incorrect green value");
-        if (c.getBlue() != 3)
-            throw new RuntimeException("Incorrect bluevalue");
-        if (c.getAlpha() != 4)
-            throw new RuntimeException("Incorrect alpha value");
-        if (c.getRGB() != ((4 << 24) | (1 << 16) | (2 << 8) | (3)))
-            throw new RuntimeException("Incorrect rgb value");
-
-        rgb = c.getRGB();
-        c.brighter();
-        if (rgb != c.getRGB())
-            throw new RuntimeException("Color object changed RGB value after brighter() called");
-
-        rgb = c.getRGB();
-        c.darker();
-        if (rgb != c.getRGB())
-            throw new RuntimeException("Color object changed RGB value after brighter() called");
-
-
-        if (!(new Color(1, 2, 3).equals(new Color(1, 2, 3))))
-            throw new RuntimeException("Inequality in colors when equality expected");
-        if (new Color(1, 2, 3).equals(new Color(3, 2, 1)))
-            throw new RuntimeException("Equality in colors when NO equality expected");
-
-        if (!(new Color(1, 2, 3, 4).equals(new Color(1, 2, 3, 4))))
-            throw new RuntimeException("Inequality in colors when equality expected");
-        if (new Color(1, 2, 3, 4).equals(new Color(4, 3, 2, 1)))
-            throw new RuntimeException("Equality in colors when NO equality expected");
-
-        c = Color.decode("0xffffff");
-        c = Color.getColor("65535");
-        c = Color.getColor("65535", Color.black);
-        c = Color.getColor("65535", 0xffffff);
-
-        int hsb_value = Color.HSBtoRGB(0.1f, 0.2f, 0.3f);
-        float[] rgb_value = Color.RGBtoHSB(1, 2, 3, null);
-
-        c = Color.getHSBColor(0.3f, 0.4f, 0.6f);
-        c = Color.getHSBColor(-0.3f, -0.4f, -0.6f);
-        c = Color.getHSBColor(30, 40, 60);
-
-        float[] comps;
-        comps = Color.black.getRGBComponents(null);
-        comps = Color.black.getRGBColorComponents(null);
-        comps = Color.black.getComponents(null);
-        comps = Color.black.getColorComponents(null);
-        comps = Color.black.getComponents(ColorSpace.getInstance(ColorSpace.CS_sRGB), null);
-        comps = Color.black.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_sRGB), null);
-
-        Color.black.getColorSpace();
-        Color.black.getTransparency();
-    }
-}
--- a/test/jdk/java/awt/Color/LoadProfileWithSM.java	Tue Oct 15 14:19:55 2019 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.awt.color.*;
-
-/*
- * @test
- * @bug 8058969 8178708
- * @summary test standard profiles loads with SecurityManager installed.
- * @run main/othervm LoadProfileWithSM
- */
-
-public class LoadProfileWithSM {
-
-    public static void main(String[] args) {
-        System.setSecurityManager(new SecurityManager());
-        ICC_Profile profile =
-            ((ICC_ColorSpace)(ColorSpace.getInstance(
-                ColorSpace.CS_GRAY))).getProfile();
-        /* request profile data in order to force profile loading */
-        profile.getData();
-   }
-}
--- a/test/jdk/java/awt/Color/LoadStandardProfilesTest.java	Tue Oct 15 14:19:55 2019 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8039271
- * @summary test all standard profiles load correctly.
- */
-
-import java.awt.color.ICC_Profile;
-
-public class LoadStandardProfilesTest {
-
-    public static void main(String args[]) {
-        try {
-            ICC_Profile sRGB      = ICC_Profile.getInstance("sRGB.pf");
-            ICC_Profile gray      = ICC_Profile.getInstance("GRAY.pf");
-            ICC_Profile pycc      = ICC_Profile.getInstance("PYCC.pf");
-            ICC_Profile ciexyz    = ICC_Profile.getInstance("CIEXYZ.pf");
-            ICC_Profile linearRGB = ICC_Profile.getInstance("LINEAR_RGB.pf");
-
-            if (sRGB == null ||
-                gray == null ||
-                pycc == null ||
-                ciexyz == null ||
-                linearRGB == null)
-            {
-                throw new RuntimeException("null profile.");
-            }
-        } catch (Exception e) {
-           throw new RuntimeException(e);
-        }
-    }
-}
--- a/test/jdk/java/awt/Color/OpacityChange/OpacityChange.java	Tue Oct 15 14:19:55 2019 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
-  @test
-  @bug 6783910
-  @summary java.awt.Color.brighter()/darker() methods make color opaque
-  @author Andrei Dmitriev: area=awt-color
-  @run main OpacityChange
-*/
-
-import java.awt.*;
-
-public class OpacityChange {
-    private final static int INITIAL_ALPHA = 125;
-
-    public static void main(String argv[]) {
-        Color color = new Color(20, 20, 20, INITIAL_ALPHA);
-        System.out.println("Initial alpha: " + color.getAlpha());
-        Color colorBrighter = color.brighter();
-        System.out.println("New alpha (after brighter): " + colorBrighter.getAlpha());
-
-        Color colorDarker = color.darker();
-        System.out.println("New alpha (after darker): " + colorDarker.getAlpha());
-
-
-        if (INITIAL_ALPHA != colorBrighter.getAlpha()) {
-            throw new RuntimeException("Brighter color alpha has changed from : " +INITIAL_ALPHA + " to " + colorBrighter.getAlpha());
-        }
-        if (INITIAL_ALPHA != colorDarker.getAlpha()) {
-            throw new RuntimeException("Darker color alpha has changed from : " +INITIAL_ALPHA + " to " + colorDarker.getAlpha());
-        }
-    }
-}
--- a/test/jdk/java/awt/Color/XRenderTranslucentColorDrawTest.java	Tue Oct 15 14:19:55 2019 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @key headful
- * @bug      8176795
- * @summary  Test verifies that we get proper color when we draw translucent
- *           color over an opaque color using X Render extension in Linux.
- * @requires (os.family == "linux")
- * @run      main XRenderTranslucentColorDrawTest -Dsun.java2d.xrender=true
- */
-
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
-import java.awt.image.BufferedImage;
-import java.awt.image.VolatileImage;
-
-public class XRenderTranslucentColorDrawTest {
-
-    public static void main(String[] args) throws Exception {
-        GraphicsEnvironment env = GraphicsEnvironment.
-                getLocalGraphicsEnvironment();
-        GraphicsConfiguration translucentGC = null;
-        SCREENS: for (GraphicsDevice screen : env.getScreenDevices()) {
-            for (GraphicsConfiguration gc : screen.getConfigurations()) {
-                if (gc.isTranslucencyCapable()) {
-                    translucentGC = gc;
-                    break SCREENS;
-                }
-            }
-        }
-        if (translucentGC == null) {
-            throw new RuntimeException("No suitable gc found.");
-        }
-        int width = 10;
-        int height = 10;
-        VolatileImage image = translucentGC.
-                createCompatibleVolatileImage(width, height);
-        Graphics2D g = image.createGraphics();
-        // draw opaque black color
-        g.setColor(new Color(0xff000000, true));
-        g.fillRect(0, 0, width, height);
-        // draw translucent white color over opaque black color
-        g.setColor(new Color(0x80ffffff, true));
-        g.fillRect(0, 0, width, height);
-        g.dispose();
-        // Get snapshot of VolatileImage to pick color and verify the same
-        BufferedImage snapshot = image.getSnapshot();
-        int argb = snapshot.getRGB(width / 2, height / 2);
-        // we expect the resultant rgb hex value to be ff808080
-        if (!(Integer.toHexString(argb).equals("ff808080"))) {
-            throw new RuntimeException("Using X Render extension for drawing"
-                    + " translucent color is not giving expected results.");
-        }
-    }
-}
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/ColorClass/AlphaColorTest.java	Tue Oct 15 22:42:23 2019 -0700
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @key headful
+ * @bug 8204931 8227392 8224825
+ * @summary test alpha colors are blended with background.
+ */
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Robot;
+import javax.swing.SwingUtilities;
+
+public class AlphaColorTest extends Component {
+
+    private Color color;
+
+    public AlphaColorTest(Color c) {
+       this.color = c;
+    }
+
+    public void paint(Graphics g) {
+        g.setColor(color);
+        g.fillRect(0, 0, getSize().width, getSize().height);
+    }
+
+    public Dimension getPreferredSize() {
+        return getSize();
+    }
+
+    public Dimension getSize() {
+        return new Dimension(200, 200);
+    }
+
+    public static void main(String args[]) throws Exception {
+        SwingUtilities.invokeAndWait(() -> createAndShowGUI());
+        Robot robot = new Robot();
+        robot.delay(5000);
+        robot.waitForIdle();
+        Color c = robot.getPixelColor(frame.getX() + 100, frame.getY() + 100);
+        int red = c.getRed();
+        frame.dispose();
+        // Should be 126-128, but be tolerant of gamma correction.
+        if (red < 122 || red > 132) {
+            throw new RuntimeException("Color is not as expected. Got " + c);
+        }
+     }
+
+    static Frame frame;
+    private static void createAndShowGUI() {
+        frame = new Frame("Alpha Color Test") {
+            @Override
+            public void paint(Graphics g) {
+                g.setColor(Color.black);
+                g.fillRect(0, 0, getWidth(), getHeight());
+                super.paint(g);
+            }
+        };
+        Color color = new Color(255, 255, 255, 127);
+        frame.add("Center", new AlphaColorTest(color));
+        frame.pack();
+        frame.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/ColorClass/HeadlessColor.java	Tue Oct 15 22:42:23 2019 -0700
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+import java.awt.color.ColorSpace;
+
+/*
+ * @test
+ * @summary Check Color constructors and methods works correctly in headless mode
+ * @run main/othervm -Djava.awt.headless=true HeadlessColor
+ */
+
+public class HeadlessColor {
+    public static void main(String args[]) {
+        Color c;
+
+        // Constructors without exceptions
+        c = new Color(1, 2, 3);
+        c = new Color(1, 2, 3, 4);
+        c = new Color((1 << 16) | (2 << 8) | (3));
+        c = new Color((1 << 24) | (1 << 16) | (2 << 8) | (3));
+        c = new Color((1 << 24) | (2 << 16) | (3 << 8) | (4), true);
+        c = new Color((2 << 16) | (3 << 8) | (4), false);
+        c = new Color(0.8f, 0.8f, 0.3f);
+        c = new Color(0.999f, 0.8f, 0.8f, 0.3f);
+        c = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB),
+                new float[]{0.8f, 0.8f, 0.3f}, 1f);
+
+        // Constructors with exceptions
+        boolean exceptions = false;
+        try {
+            c = new Color(409, 400, 400);
+        } catch (IllegalArgumentException e) {
+            exceptions = true;
+        }
+        if (!exceptions)
+            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
+                    "when expected in headless mode");
+
+        exceptions = false;
+        try {
+            c = new Color(400, 3003, 400, 400);
+        } catch (IllegalArgumentException e) {
+            exceptions = true;
+        }
+        if (!exceptions)
+            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
+                    "when expected in headless mode");
+
+        exceptions = false;
+        try {
+            c = new Color(8f, 8f, 3f);
+        } catch (IllegalArgumentException e) {
+            exceptions = true;
+        }
+        if (!exceptions)
+            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
+                    "when expected in headless mode");
+
+        exceptions = false;
+        try {
+            c = new Color(-8f, -8f, -3f);
+        } catch (IllegalArgumentException e) {
+            exceptions = true;
+        }
+        if (!exceptions)
+            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
+                    "when expected in headless mode");
+
+        exceptions = false;
+        try {
+            c = new Color(0.999f, 8f, 8f, 3f);
+        } catch (IllegalArgumentException e) {
+            exceptions = true;
+        }
+        if (!exceptions)
+            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
+                    "when expected in headless mode");
+
+        exceptions = false;
+        try {
+            c = new Color(20f, 8f, 8f, 3f);
+        } catch (IllegalArgumentException e) {
+            exceptions = true;
+        }
+        if (!exceptions)
+            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
+                    "when expected in headless mode");
+
+        exceptions = false;
+        try {
+            c = new Color(-20f, -8f, -8f, -3f);
+        } catch (IllegalArgumentException e) {
+            exceptions = true;
+        }
+        if (!exceptions)
+            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
+                    "when expected in headless mode");
+
+        exceptions = false;
+        try {
+            c = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB),
+                    new float[]{-8f, -8f, -3f}, 1f);
+        } catch (IllegalArgumentException e) {
+            exceptions = true;
+        }
+        if (!exceptions)
+            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
+                    "when expected in headless mode");
+
+        exceptions = false;
+        try {
+            c = new Color(ColorSpace.getInstance(ColorSpace.CS_sRGB),
+                    new float[]{-8f, -8f, -3f}, -1f);
+        } catch (IllegalArgumentException e) {
+            exceptions = true;
+        }
+        if (!exceptions)
+            throw new RuntimeException("Constructor did not throw IllegalArgumentException " +
+                    "when expected in headless mode");
+
+
+        c = new Color(1, 2, 3);
+        c.hashCode();
+        c.toString();
+        if (c.getRed() != 1)
+            throw new RuntimeException("Incorrect red value");
+        if (c.getGreen() != 2)
+            throw new RuntimeException("Incorrect green value");
+        if (c.getBlue() != 3)
+            throw new RuntimeException("Incorrect bluevalue");
+        if (c.getAlpha() != 255)
+            throw new RuntimeException("Incorrect alpha value");
+        if (c.getRGB() != ((255 << 24) | (1 << 16) | (2 << 8) | (3)))
+            throw new RuntimeException("Incorrect rgb value");
+
+        int rgb = c.getRGB();
+        c.brighter();
+        if (rgb != c.getRGB())
+            throw new RuntimeException("Color object changed RGB value after brighter() called");
+
+        rgb = c.getRGB();
+        c.darker();
+        if (rgb != c.getRGB())
+            throw new RuntimeException("Color object changed RGB value after brighter() called");
+
+        c = new Color(1, 2, 3, 4);
+        c.hashCode();
+        c.toString();
+        if (c.getRed() != 1)
+            throw new RuntimeException("Incorrect red value");
+        if (c.getGreen() != 2)
+            throw new RuntimeException("Incorrect green value");
+        if (c.getBlue() != 3)
+            throw new RuntimeException("Incorrect bluevalue");
+        if (c.getAlpha() != 4)
+            throw new RuntimeException("Incorrect alpha value");
+        if (c.getRGB() != ((4 << 24) | (1 << 16) | (2 << 8) | (3)))
+            throw new RuntimeException("Incorrect rgb value");
+
+        rgb = c.getRGB();
+        c.brighter();
+        if (rgb != c.getRGB())
+            throw new RuntimeException("Color object changed RGB value after brighter() called");
+
+        rgb = c.getRGB();
+        c.darker();
+        if (rgb != c.getRGB())
+            throw new RuntimeException("Color object changed RGB value after brighter() called");
+
+
+        if (!(new Color(1, 2, 3).equals(new Color(1, 2, 3))))
+            throw new RuntimeException("Inequality in colors when equality expected");
+        if (new Color(1, 2, 3).equals(new Color(3, 2, 1)))
+            throw new RuntimeException("Equality in colors when NO equality expected");
+
+        if (!(new Color(1, 2, 3, 4).equals(new Color(1, 2, 3, 4))))
+            throw new RuntimeException("Inequality in colors when equality expected");
+        if (new Color(1, 2, 3, 4).equals(new Color(4, 3, 2, 1)))
+            throw new RuntimeException("Equality in colors when NO equality expected");
+
+        c = Color.decode("0xffffff");
+        c = Color.getColor("65535");
+        c = Color.getColor("65535", Color.black);
+        c = Color.getColor("65535", 0xffffff);
+
+        int hsb_value = Color.HSBtoRGB(0.1f, 0.2f, 0.3f);
+        float[] rgb_value = Color.RGBtoHSB(1, 2, 3, null);
+
+        c = Color.getHSBColor(0.3f, 0.4f, 0.6f);
+        c = Color.getHSBColor(-0.3f, -0.4f, -0.6f);
+        c = Color.getHSBColor(30, 40, 60);
+
+        float[] comps;
+        comps = Color.black.getRGBComponents(null);
+        comps = Color.black.getRGBColorComponents(null);
+        comps = Color.black.getComponents(null);
+        comps = Color.black.getColorComponents(null);
+        comps = Color.black.getComponents(ColorSpace.getInstance(ColorSpace.CS_sRGB), null);
+        comps = Color.black.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_sRGB), null);
+
+        Color.black.getColorSpace();
+        Color.black.getTransparency();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/ColorClass/OpacityChange/OpacityChange.java	Tue Oct 15 22:42:23 2019 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+  @test
+  @bug 6783910
+  @summary java.awt.Color.brighter()/darker() methods make color opaque
+  @author Andrei Dmitriev: area=awt-color
+  @run main OpacityChange
+*/
+
+import java.awt.*;
+
+public class OpacityChange {
+    private final static int INITIAL_ALPHA = 125;
+
+    public static void main(String argv[]) {
+        Color color = new Color(20, 20, 20, INITIAL_ALPHA);
+        System.out.println("Initial alpha: " + color.getAlpha());
+        Color colorBrighter = color.brighter();
+        System.out.println("New alpha (after brighter): " + colorBrighter.getAlpha());
+
+        Color colorDarker = color.darker();
+        System.out.println("New alpha (after darker): " + colorDarker.getAlpha());
+
+
+        if (INITIAL_ALPHA != colorBrighter.getAlpha()) {
+            throw new RuntimeException("Brighter color alpha has changed from : " +INITIAL_ALPHA + " to " + colorBrighter.getAlpha());
+        }
+        if (INITIAL_ALPHA != colorDarker.getAlpha()) {
+            throw new RuntimeException("Darker color alpha has changed from : " +INITIAL_ALPHA + " to " + colorDarker.getAlpha());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/ColorClass/XRenderTranslucentColorDrawTest.java	Tue Oct 15 22:42:23 2019 -0700
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @key headful
+ * @bug      8176795
+ * @summary  Test verifies that we get proper color when we draw translucent
+ *           color over an opaque color using X Render extension in Linux.
+ * @requires (os.family == "linux")
+ * @run      main XRenderTranslucentColorDrawTest -Dsun.java2d.xrender=true
+ */
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.image.BufferedImage;
+import java.awt.image.VolatileImage;
+
+public class XRenderTranslucentColorDrawTest {
+
+    public static void main(String[] args) throws Exception {
+        GraphicsEnvironment env = GraphicsEnvironment.
+                getLocalGraphicsEnvironment();
+        GraphicsConfiguration translucentGC = null;
+        SCREENS: for (GraphicsDevice screen : env.getScreenDevices()) {
+            for (GraphicsConfiguration gc : screen.getConfigurations()) {
+                if (gc.isTranslucencyCapable()) {
+                    translucentGC = gc;
+                    break SCREENS;
+                }
+            }
+        }
+        if (translucentGC == null) {
+            throw new RuntimeException("No suitable gc found.");
+        }
+        int width = 10;
+        int height = 10;
+        VolatileImage image = translucentGC.
+                createCompatibleVolatileImage(width, height);
+        Graphics2D g = image.createGraphics();
+        // draw opaque black color
+        g.setColor(new Color(0xff000000, true));
+        g.fillRect(0, 0, width, height);
+        // draw translucent white color over opaque black color
+        g.setColor(new Color(0x80ffffff, true));
+        g.fillRect(0, 0, width, height);
+        g.dispose();
+        // Get snapshot of VolatileImage to pick color and verify the same
+        BufferedImage snapshot = image.getSnapshot();
+        int argb = snapshot.getRGB(width / 2, height / 2);
+        // we expect the resultant rgb hex value to be ff808080
+        if (!(Integer.toHexString(argb).equals("ff808080"))) {
+            throw new RuntimeException("Using X Render extension for drawing"
+                    + " translucent color is not giving expected results.");
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/color/GetMinMaxValue_ICC_ColorSpace.java	Tue Oct 15 22:42:23 2019 -0700
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.awt.color.ColorSpace;
+import java.awt.color.ICC_ColorSpace;
+import java.awt.color.ICC_Profile;
+import java.io.IOException;
+
+/**
+  * @test
+  * @bug 8072678
+  * @author Prasanta Sadhukhan
+  */
+
+public class GetMinMaxValue_ICC_ColorSpace {
+
+    public static void main(String[] a) throws Exception {
+        ICC_Profile cmyk_profile = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
+        ICC_ColorSpace colorSpace = new ICC_ColorSpace(cmyk_profile);
+        String minstr = null;
+        String maxstr = null;
+
+        colorSpace.fromRGB(new float[]{4.3f,3.1f,2.2f});
+        try {
+            System.out.println("minvalue " + colorSpace.getMinValue(3));
+        } catch (IllegalArgumentException iae) {
+            minstr = iae.toString();
+        }
+        try {
+            System.out.println("maxvalue " + colorSpace.getMaxValue(3));
+        } catch (IllegalArgumentException iae) {
+            maxstr = iae.toString();
+        }
+
+        if (minstr.endsWith("+ component") || maxstr.endsWith("+ component")) {
+            System.out.println("Test failed");
+            throw new RuntimeException("IllegalArgumentException contains incorrect text message");
+        } else {
+            System.out.println("Test passed");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/color/LoadProfileWithSM.java	Tue Oct 15 22:42:23 2019 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.color.*;
+
+/*
+ * @test
+ * @bug 8058969 8178708
+ * @summary test standard profiles loads with SecurityManager installed.
+ * @run main/othervm LoadProfileWithSM
+ */
+
+public class LoadProfileWithSM {
+
+    public static void main(String[] args) {
+        System.setSecurityManager(new SecurityManager());
+        ICC_Profile profile =
+            ((ICC_ColorSpace)(ColorSpace.getInstance(
+                ColorSpace.CS_GRAY))).getProfile();
+        /* request profile data in order to force profile loading */
+        profile.getData();
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/color/LoadStandardProfilesTest.java	Tue Oct 15 22:42:23 2019 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8039271
+ * @summary test all standard profiles load correctly.
+ */
+
+import java.awt.color.ICC_Profile;
+
+public class LoadStandardProfilesTest {
+
+    public static void main(String args[]) {
+        try {
+            ICC_Profile sRGB      = ICC_Profile.getInstance("sRGB.pf");
+            ICC_Profile gray      = ICC_Profile.getInstance("GRAY.pf");
+            ICC_Profile pycc      = ICC_Profile.getInstance("PYCC.pf");
+            ICC_Profile ciexyz    = ICC_Profile.getInstance("CIEXYZ.pf");
+            ICC_Profile linearRGB = ICC_Profile.getInstance("LINEAR_RGB.pf");
+
+            if (sRGB == null ||
+                gray == null ||
+                pycc == null ||
+                ciexyz == null ||
+                linearRGB == null)
+            {
+                throw new RuntimeException("null profile.");
+            }
+        } catch (Exception e) {
+           throw new RuntimeException(e);
+        }
+    }
+}