Type inference bug with method references in OpenJDK 16+ discovered
Michael Mirwaldt
michael.mirwaldt at gmx.de
Tue Jun 22 14:34:21 UTC 2021
Hi Guoxiong,
thanks for trying out my example project, reproducing the bug even under
linux and creating a bug ticket for that.
I hope, my example project helps you to find out what goes wrong with
type inference here and fix that bug.
Best regards,
Michael Mirwaldt
Am 22.06.2021 um 12:04 schrieb Guoxiong Li:
> Hi Michael,
>
> Thanks for reporting this bug.
>
> I reproduced this bug on linux by using the following commands
> and the error messages are similar to yours.
>
> ```
> java -m jdk.compiler/com.sun.tools.javac.Main $(find src/main/java
> -name "*.java")
> java -classpath src/main/java net.mirwaldt.bug.Main
> ```
>
> And I also reproduced it by using the maven to compile.(also on linux)
>
> ```
> mvn clean compile
> java -classpath target/classes/ net.mirwaldt.bug.Main
> ```
>
> It seems that you misuse some commands.
>
> Anyway, it is a reproduced bug.
> Filed https://bugs.openjdk.java.net/browse/JDK-8269121
> <https://bugs.openjdk.java.net/browse/JDK-8269121> in the JBS.
>
> Best Regards,
> -- Guoxiong
>
>
> On Mon, Jun 21, 2021 at 5:49 AM Michael Mirwaldt
> <michael.mirwaldt at gmx.de <mailto:michael.mirwaldt at gmx.de>> wrote:
>
> Hi,
> I wanted to report a bug in the type inference with references in
> OpenJDK 16 and 17-ea.
> I have created a sample project on
> https://github.com/mmirwaldt/TypeInferenceBugOfMethodReferences/
> <https://github.com/mmirwaldt/TypeInferenceBugOfMethodReferences/>
> <https://github.com/mmirwaldt/TypeInferenceBugOfMethodReferences/
> <https://github.com/mmirwaldt/TypeInferenceBugOfMethodReferences/>>
> to reproduce the bug. Just run Main and notice the exception.
> However, a friend told me that the bug only occurs with compiling
> directly by javac but not by maven compile.
> We don't know why. Moreover, it seems to be dependent on the operating
> system:
> I haven't been able to reproduce the bug on linux (CentOS 7, OpenJDK
> 16.0.1) yet. Windows 10 and Mac show that bug, though.
> Can you please have a look on it, try it out and help me creating
> a bug
> ticket if you can confirm it's a bug?
> I mean it must be a bug if the type inference somehow infers the wrong
> type of a method reference which leads to an exception at runtime,
> doesn't it?
> Type inference should either infer the right type or cause a compiler
> error if it cannot infer the type or isn't sure about it in order
> to ask
> the developer for an explicit declaration. Is that right?
> I am sorry I cannot help you finding the bug in the code of the
> compiler
> which infers types. I would if I could.
> All the best,
> Michael Mirwaldt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210622/544f9c82/attachment.htm>
More information about the compiler-dev
mailing list