[jdk17u-dev] RFR: 8302111: Serialization considerations [v3]

Richard Reingruber rrich at openjdk.org
Thu Feb 20 16:22:14 UTC 2025


On Thu, 20 Feb 2025 16:00:09 GMT, Goetz Lindenmaier <goetz at openjdk.org> wrote:

>> src/java.base/share/classes/com/sun/crypto/provider/DHPrivateKey.java line 379:
>> 
>>> 377:         } catch (IOException e) {
>>> 378:             InvalidObjectException ioe = new InvalidObjectException("Invalid encoding");
>>> 379:             if (ioe != null) {
>> 
>> Isn't this condition always true?
>> Note also that the throw below will throw a NPE if it `ioe` was null.
>> I think you can actually remove the condition.
>
> My inital desing was 
> throw new InvalidObjectException("Invalid encoding").initCause(e);
> But the compiler does not like this:
> error: unreported exception Throwable; must be caught or declared to be thrown
> So I decided to add the try/catch with the null check.

I see... strange. But it does compile without the null check. I think it should be removed.

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

PR Review Comment: https://git.openjdk.org/jdk17u-dev/pull/3278#discussion_r1963898802


More information about the jdk-updates-dev mailing list