Integrated: 8029301: Confusing error message for array creation method reference

Archie L. Cobbs duke at openjdk.org
Wed Mar 22 21:03:54 UTC 2023


On Mon, 20 Feb 2023 01:55:05 GMT, Archie L. Cobbs <duke at openjdk.org> wrote:

> The error for an invalid constructor reference of an array type looks like this:
> 
> Test.java:3: error: incompatible types: invalid constructor reference
>         Runnable r = String[]::new;
>                      ^
>     constructor Array in class Array cannot be applied to given types
>       required: int
>       found:    no arguments
>       reason: actual and formal argument lists differ in length
> 
> The phrase "constructor Array in class Array" is somewhat confusing.
> 
> This is a simple patch to reword this type of error to look like this instead:
> 
> Test.java:3: error: incompatible types: invalid constructor reference
>         Runnable r = String[]::new;
>                      ^
>     cannot create array from given types
>       required: int
>       found:    no arguments
>       reason:   actual and formal argument lists differ in length

This pull request has now been integrated.

Changeset: 91f407d6
Author:    Archie L. Cobbs <archie.cobbs at gmail.com>
Committer: Vicente Romero <vromero at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/91f407d6fe285c44bcc25c1acdf5dc0c43be0172
Stats:     31 lines in 4 files changed: 24 ins; 2 del; 5 mod

8029301: Confusing error message for array creation method reference

Reviewed-by: vromero

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

PR: https://git.openjdk.org/jdk/pull/12646


More information about the compiler-dev mailing list