On Fri, 26 Jul 2024 13:09:19 GMT, Andrey Turbanov <aturba...@openjdk.org> wrote:

> There is implicit null check in line before.
> 
> https://github.com/openjdk/jdk/blob/431d4f7e18369466eedd00926a5162a1461d0b25/src/java.base/share/classes/java/io/ObjectOutputStream.java#L1267-L1277
> 
> 'cl' can't be null after that.

That null check appears to have been added as part of 
https://mail.openjdk.org/pipermail/core-libs-dev/2014-April/026379.html. The 
change in that previous commit introduced 2 null checks - one in 
`writeProxyDesc()` and one in `writeNonProxyDesc()`. The null check added in 
`writeProxyDesc()` appears to be a copy/paste issue and as you note that null 
check essentially is a no-op because the `cl` has already been dereferenced a 
few lines above. Removing this redundant null check seems OK to me. 

Having said that, I think we might have to consider if that null check needs to 
be moved just after the call to `desc.forClass()`. Apparently that call is 
allowed to return null (which is what prompted the original commit).

I would wait for Roger or someone more familiar with this area to recommend 
what needs to be done here.

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

PR Comment: https://git.openjdk.org/jdk/pull/20351#issuecomment-2270349946

Reply via email to