RFR: 8367384: The ICC_Profile class may throw exceptions during serialization [v3]

Harshitha Onkar honkar at openjdk.org
Sat Sep 27 00:07:15 UTC 2025


On Thu, 25 Sep 2025 03:07:54 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> test/jdk/java/awt/color/ICC_Profile/Serialization/SerializationSpecTest/SerializationSpecTest.java line 89:
>> 
>>> 87:             throw new RuntimeException("Test failed");
>>> 88:         }
>>> 89:     }
>> 
>> Suggestion:
>> 
>>     private static void test(String test, Class<?> expected, String msg) {
>>         System.out.println("Testing: " + test);
>>         System.out.println("Description: " + msg);
>>         
>>         String fileName = test + ".ser";
>>         File file = new File(System.getProperty("test.src", "."), fileName);
>>         Class<?> actual = null;
>>         try (var fis = new FileInputStream(file);
>>              var ois = new ObjectInputStream(fis))
>>         {
>>             ois.readObject();
>>         } catch (Exception e) {
>>             actual = e.getClass();
>>         }
>>         if (actual != expected) {
>>             System.err.println("Test: " + test);
>>             System.err.println("Expected: " + expected);
>>             System.err.println("Actual: " + actual);
>>             throw new RuntimeException("Test failed");
>>         }
>>         System.out.println("Test Case: " + test + " passed \n");
>>     }
>
> I am not sure I like it when the test outputs much information. When an error occurs, it prints the test case that was running at the time. I have added a comment explaining the filename notation used in the test.

Sounds reasonable. The updated comment adds clarity. Thank you!

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

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


More information about the client-libs-dev mailing list