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

Vicente Romero vromero at openjdk.java.net
Thu Jan 28 13:21:41 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.

looks good

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

Marked as reviewed by vromero (Reviewer).

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


More information about the kulla-dev mailing list