6211202: ColorSpace.getInstance(int): IAE is not specified

Reviewed-by: prr
This commit is contained in:
Sergey Bylokhov 2023-07-18 21:46:02 +00:00
parent 28c4d196cf
commit 7d9f5afea1
3 changed files with 19 additions and 5 deletions
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
@ -305,6 +305,8 @@ public abstract class ColorSpace implements Serializable {
* class constants (e.g. {@code CS_sRGB}, {@code CS_LINEAR_RGB},
* {@code CS_CIEXYZ}, {@code CS_GRAY}, or {@code CS_PYCC})
* @return the requested {@code ColorSpace} object
* @throws IllegalArgumentException if {@code cspace} is not one of the
* predefined color space types
*/
// NOTE: This method may be called by privileged threads.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!

@ -818,8 +818,7 @@ public sealed class ICC_Profile implements Serializable
/**
* Constructs an {@code ICC_Profile} corresponding to one of the specific
* color spaces defined by the {@code ColorSpace} class (for example
* {@code CS_sRGB}). Throws an {@code IllegalArgumentException} if cspace is
* not one of the defined color spaces.
* {@code CS_sRGB}).
*
* @param cspace the type of color space to create a profile for. The
* specified type is one of the color space constants defined in the

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 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
@ -21,11 +21,12 @@
* questions.
*/
import java.awt.color.ColorSpace;
import java.awt.color.ICC_Profile;
/**
* @test
* @bug 6211198
* @bug 6211198 6211202
* @summary IllegalArgumentException in ICC_Profile.getInstance for broken data
*/
public final class GetInstanceBrokenData {
@ -38,5 +39,17 @@ public final class GetInstanceBrokenData {
} catch (IllegalArgumentException ignored) {
// expected
}
try {
ICC_Profile.getInstance(-5);
throw new RuntimeException("IllegalArgumentException is expected");
} catch (IllegalArgumentException ignored) {
// expected
}
try {
ColorSpace.getInstance(-5);
throw new RuntimeException("IllegalArgumentException is expected");
} catch (IllegalArgumentException ignored) {
// expected
}
}
}