RFR: 8208752: Calling a deserialized Lambda might fail with ClassCastException [v4]
Jan Lahoda
jlahoda at openjdk.org
Thu Jan 22 16:28:51 UTC 2026
On Thu, 22 Jan 2026 11:45:08 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:
>> See [JDK-8208752: Calling a deserialized Lambda might fail with ClassCastException](https://bugs.openjdk.org/browse/JDK-8208752).
>>
>> Lambda deserialization currently does not consider `SerializedLambda#getInstantiatedMethodType` when deserializing lambdas, which can lead to method references that differ only in `getInstantiatedMethodType` being merged into the same lambda instance, and can result in `ClassCastException`s like the one reported in the bug.
>>
>> This depends on the fix for [JDK-8374654: Inconsistent handling of lambda deserialization for Object method references on interfaces](https://bugs.openjdk.org/browse/JDK-8374654) in https://github.com/openjdk/jdk/pull/29075.
>
> Liam Miller-Cushon has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains nine commits:
>
> - Merge branch 'JDK-8374654' into JDK-8208752
> - Test cleanup
> - Updates for --debug=dumpLambdaDeserializationStats
> - Merge branch 'JDK-8374654' into JDK-8208752
> - Merge branch 'JDK-8374654' into JDK-8208752
> - Update test
> - Merge branch 'JDK-8374654' into JDK-8208752
> - Don't rely on the iteration order of Map.of entries
> - 8208752: Calling a deserialized Lambda might fail with ClassCastException
This looks reasonable to me, and I don't see how this could break anything (although that does not mean nothing will be broken, of course). Aside for making the method a bit bigger, of course, but that hopefully shouldn't be a big deal. So, overall, I am OK with this patch.
What I am not as OK with is the dependency on PR #29075 - that PR without this one will cause a regression, and even if it was a transient/short-term regression, I don't think we should knowingly do it.
So, my proposal would be to do one of these:
- change the order of the patches. Integrate this one (which should be OK, right?), and then PR #29075
- do both this and #29075 together
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28943#issuecomment-3785329343
More information about the compiler-dev
mailing list