RFR: 8367384: The ICC_Profile class may throw exceptions during serialization

Sergey Bylokhov serb at openjdk.org
Wed Sep 17 20:30:04 UTC 2025


On Wed, 17 Sep 2025 19:23:50 GMT, Phil Race <prr at openjdk.org> wrote:

> I don't see InvalidObjectException as a declared exception either for This is a little tricky InvalidObjectException isn't listed explicitly by https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/ObjectInputStream.html#readObject() although it is a subclass of IOException https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/io/InvalidObjectException.html#%3Cinit%3E(java.lang.String)

Throwing "new InvalidObjectException" from readObject for certain issues is a common pattern in the java.base and java.desktop modules. The assumption seems to be that InvalidObjectException is treated as a kind of io error(IOException), since it is usually thrown when the data is “broken” and cannot be saved by the corresponding write method. The specification for "ObjectInputStream.readObject()" could be updated to mention this behavior.

> However the docs for https://docs.oracle.com/en/java/javase/25/docs/api/java.desktop/java/awt/color/ICC_Profile.html#getInstance(byte%5B%5D)
> 
> say that IOException is thrown by ObjectInputStream * @throws IOException thrown by {@code ObjectInputStream} but the exceptions you are catching are from the profile verifier - at least the IAE is. And there is a (closed) test that expects IAE in this case and fails because it now gets InvalidObjectException
> 
> Either that test, or this fix, or both will need revising. Perhaps the spec. of readObject should be updated too.

That closed test should be updated.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27326#discussion_r2356693340


More information about the client-libs-dev mailing list