Integrated: JDK-8252409: JShell: Intersection types cause NoSuchFieldError

Jan Lahoda jlahoda at openjdk.java.net
Fri Jan 29 09:22:40 UTC 2021


On Thu, 28 Jan 2021 10:53:08 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> From the bug:
> jshell> var test = (Serializable & Runnable) () -> {};
> test ==> $Lambda$26/0x0000000800ba4248 at 5910e440
> 
> jshell> test
> | Exception java.lang.NoSuchFieldError: test
> | at (#2:1)
> 
> jshell> test.toString()
> | Exception java.lang.NoSuchFieldError: test
> | at (#3:1)
> 
> 
> The reason is that the field generated for `var test = ...` has type `j.l.Object`, but the references to it use `Serializable`, and hence the field is not found. The proposal is to generate the field's type as an erased type of the intersection type.

This pull request has now been integrated.

Changeset: 06754734
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/06754734
Stats:     26 lines in 5 files changed: 15 ins; 0 del; 11 mod

8252409: JShell: Intersection types cause NoSuchFieldError

Reviewed-by: vromero

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

PR: https://git.openjdk.java.net/jdk/pull/2284


More information about the kulla-dev mailing list