6211126: ICC_ColorSpace.toCIEXYZ(float[]): NPE is not specified
6211139: ICC_ColorSpace.toRGB(float[]): NPE is not specified Reviewed-by: prr
This commit is contained in:
parent
7d9f5afea1
commit
e31df3a774
src/java.desktop/share/classes/java/awt/color
test/jdk/java/awt/color
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, 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
|
||||
@ -51,9 +51,9 @@ public class CMMException extends RuntimeException {
|
||||
/**
|
||||
* Constructs a {@code CMMException} with the specified detail message.
|
||||
*
|
||||
* @param s the specified detail message
|
||||
* @param message the specified detail message, or {@code null}
|
||||
*/
|
||||
public CMMException(String s) {
|
||||
super(s);
|
||||
public CMMException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
@ -352,6 +352,7 @@ public abstract class ColorSpace implements Serializable {
|
||||
* @return a float array of length 3
|
||||
* @throws ArrayIndexOutOfBoundsException if array length is not at least
|
||||
* the number of components in this {@code ColorSpace}
|
||||
* @throws NullPointerException if {@code colorvalue} is {@code null}
|
||||
*/
|
||||
public abstract float[] toRGB(float[] colorvalue);
|
||||
|
||||
@ -373,6 +374,7 @@ public abstract class ColorSpace implements Serializable {
|
||||
* @return a float array with length equal to the number of components in
|
||||
* this {@code ColorSpace}
|
||||
* @throws ArrayIndexOutOfBoundsException if array length is not at least 3
|
||||
* @throws NullPointerException if {@code rgbvalue} is {@code null}
|
||||
*/
|
||||
public abstract float[] fromRGB(float[] rgbvalue);
|
||||
|
||||
@ -397,7 +399,8 @@ public abstract class ColorSpace implements Serializable {
|
||||
* components in this {@code ColorSpace}
|
||||
* @return a float array of length 3
|
||||
* @throws ArrayIndexOutOfBoundsException if array length is not at least
|
||||
* the number of components in this {@code ColorSpace}.
|
||||
* the number of components in this {@code ColorSpace}
|
||||
* @throws NullPointerException if {@code colorvalue} is {@code null}
|
||||
*/
|
||||
public abstract float[] toCIEXYZ(float[] colorvalue);
|
||||
|
||||
@ -423,6 +426,7 @@ public abstract class ColorSpace implements Serializable {
|
||||
* @return a float array with length equal to the number of components in
|
||||
* this {@code ColorSpace}
|
||||
* @throws ArrayIndexOutOfBoundsException if array length is not at least 3
|
||||
* @throws NullPointerException if {@code colorvalue} is {@code null}
|
||||
*/
|
||||
public abstract float[] fromCIEXYZ(float[] colorvalue);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, 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
|
||||
@ -130,6 +130,7 @@ public class ICC_ColorSpace extends ColorSpace {
|
||||
* @param profile the specified {@code ICC_Profile} object
|
||||
* @throws IllegalArgumentException if profile is inappropriate for
|
||||
* representing a {@code ColorSpace}
|
||||
* @throws NullPointerException if {@code profile} is {@code null}
|
||||
*/
|
||||
public ICC_ColorSpace(ICC_Profile profile) {
|
||||
super(profile.getColorSpaceType(), profile.getNumComponents());
|
||||
@ -157,6 +158,7 @@ public class ICC_ColorSpace extends ColorSpace {
|
||||
* @throws ClassNotFoundException if the class of a serialized object could
|
||||
* not be found
|
||||
* @throws IOException if an I/O error occurs
|
||||
* @throws NullPointerException if {@code s} is {@code null}
|
||||
*/
|
||||
@Serial
|
||||
private void readObject(ObjectInputStream s)
|
||||
@ -195,6 +197,7 @@ public class ICC_ColorSpace extends ColorSpace {
|
||||
* @return a float array of length 3
|
||||
* @throws ArrayIndexOutOfBoundsException if array length is not at least
|
||||
* the number of components in this {@code ColorSpace}
|
||||
* @throws NullPointerException if {@code colorvalue} is {@code null}
|
||||
*/
|
||||
public float[] toRGB(float[] colorvalue) {
|
||||
if (this2srgb == null) {
|
||||
@ -243,6 +246,7 @@ public class ICC_ColorSpace extends ColorSpace {
|
||||
* @return a float array with length equal to the number of components in
|
||||
* this {@code ColorSpace}
|
||||
* @throws ArrayIndexOutOfBoundsException if array length is not at least 3
|
||||
* @throws NullPointerException if {@code rgbvalue} is {@code null}
|
||||
*/
|
||||
public float[] fromRGB(float[] rgbvalue) {
|
||||
if (srgb2this == null) {
|
||||
@ -371,6 +375,7 @@ public class ICC_ColorSpace extends ColorSpace {
|
||||
* @return a float array of length 3
|
||||
* @throws ArrayIndexOutOfBoundsException if array length is not at least
|
||||
* the number of components in this {@code ColorSpace}
|
||||
* @throws NullPointerException if {@code colorvalue} is {@code null}
|
||||
*/
|
||||
public float[] toCIEXYZ(float[] colorvalue) {
|
||||
if (this2xyz == null) {
|
||||
@ -502,6 +507,7 @@ public class ICC_ColorSpace extends ColorSpace {
|
||||
* @return a float array with length equal to the number of components in
|
||||
* this {@code ColorSpace}
|
||||
* @throws ArrayIndexOutOfBoundsException if array length is not at least 3
|
||||
* @throws NullPointerException if {@code colorvalue} is {@code null}
|
||||
*/
|
||||
public float[] fromCIEXYZ(float[] colorvalue) {
|
||||
if (xyz2this == null) {
|
||||
|
@ -1411,6 +1411,7 @@ public sealed class ICC_Profile implements Serializable
|
||||
*
|
||||
* @param s stream used for serialization
|
||||
* @throws IOException thrown by {@code ObjectInputStream}
|
||||
* @throws NullPointerException if {@code s} is {@code null}
|
||||
* @serialData the {@code String} is the name of one of
|
||||
* <code>CS_<var>*</var></code> constants defined in the
|
||||
* {@link ColorSpace} class if the profile object is a profile for a
|
||||
@ -1466,8 +1467,8 @@ public sealed class ICC_Profile implements Serializable
|
||||
*
|
||||
* @param s stream used for deserialization
|
||||
* @throws IOException thrown by {@code ObjectInputStream}
|
||||
* @throws ClassNotFoundException thrown by {@code
|
||||
* ObjectInputStream}
|
||||
* @throws ClassNotFoundException thrown by {@code ObjectInputStream}
|
||||
* @throws NullPointerException if {@code s} is {@code null}
|
||||
* @serialData the {@code String} is the name of one of
|
||||
* <code>CS_<var>*</var></code> constants defined in the
|
||||
* {@link ColorSpace} class if the profile object is a profile for a
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, 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
|
||||
@ -43,9 +43,9 @@ public class ProfileDataException extends RuntimeException {
|
||||
* Constructs a {@code ProfileDataException} with the specified detail
|
||||
* message.
|
||||
*
|
||||
* @param s the specified detail message
|
||||
* @param message the specified detail message, or {@code null}
|
||||
*/
|
||||
public ProfileDataException(String s) {
|
||||
super(s);
|
||||
public ProfileDataException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
48
test/jdk/java/awt/color/CMMExceptionMessage.java
Normal file
48
test/jdk/java/awt/color/CMMExceptionMessage.java
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright Amazon.com Inc. 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.CMMException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6211126
|
||||
* @summary Checks basic functionality of java.awt.color.CMMException
|
||||
*/
|
||||
public final class CMMExceptionMessage {
|
||||
|
||||
public static void main(String[] args) {
|
||||
test(null);
|
||||
test("");
|
||||
test("CMMExceptionMessage");
|
||||
}
|
||||
|
||||
private static void test(String expected) {
|
||||
CMMException e = new CMMException(expected);
|
||||
if (!Objects.equals(e.getMessage(), expected)) {
|
||||
System.err.println("Expected message: " + expected);
|
||||
System.err.println("Actual message: " + e.getMessage());
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright Amazon.com Inc. 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;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6211126 6211139
|
||||
*/
|
||||
public final class ExpectedNPEOnNull {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
new ICC_ColorSpace(null);
|
||||
throw new RuntimeException("NPE is expected");
|
||||
} catch (NullPointerException ignored) {
|
||||
// expected
|
||||
}
|
||||
test(ICC_ColorSpace.getInstance(ColorSpace.CS_sRGB));
|
||||
test(ICC_ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB));
|
||||
test(ICC_ColorSpace.getInstance(ColorSpace.CS_CIEXYZ));
|
||||
test(ICC_ColorSpace.getInstance(ColorSpace.CS_PYCC));
|
||||
test(ICC_ColorSpace.getInstance(ColorSpace.CS_GRAY));
|
||||
}
|
||||
|
||||
private static void test(ColorSpace cs) {
|
||||
try {
|
||||
cs.toRGB(null);
|
||||
throw new RuntimeException("NPE is expected");
|
||||
} catch (NullPointerException ignored) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
cs.fromRGB(null);
|
||||
throw new RuntimeException("NPE is expected");
|
||||
} catch (NullPointerException ignored) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
cs.toCIEXYZ(null);
|
||||
throw new RuntimeException("NPE is expected");
|
||||
} catch (NullPointerException ignored) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
cs.fromCIEXYZ(null);
|
||||
throw new RuntimeException("NPE is expected");
|
||||
} catch (NullPointerException ignored) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
}
|
48
test/jdk/java/awt/color/ProfileDataExceptionMessage.java
Normal file
48
test/jdk/java/awt/color/ProfileDataExceptionMessage.java
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright Amazon.com Inc. 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.ProfileDataException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6211126
|
||||
* @summary Checks basic functionality of java.awt.color.ProfileDataException
|
||||
*/
|
||||
public final class ProfileDataExceptionMessage {
|
||||
|
||||
public static void main(String[] args) {
|
||||
test(null);
|
||||
test("");
|
||||
test("ProfileDataExceptionMessage");
|
||||
}
|
||||
|
||||
private static void test(String expected) {
|
||||
ProfileDataException e = new ProfileDataException(expected);
|
||||
if (!Objects.equals(e.getMessage(), expected)) {
|
||||
System.err.println("Expected message: " + expected);
|
||||
System.err.println("Actual message: " + e.getMessage());
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user