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

Vicente Romero vromero at openjdk.org
Mon Mar 20 21:18:41 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

looks good

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

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/12646#pullrequestreview-1349411631


More information about the compiler-dev mailing list