RFR: 8029301: Confusing error message for array creation method reference [v2]

ExE Boss duke at openjdk.org
Wed Mar 22 15:01:36 UTC 2023


On Tue, 21 Mar 2023 23:07:28 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
>
> Archie L. Cobbs has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
> 
>  - Merge branch 'master' into JDK-8029301
>  - Improve error referring to "constructor Array in class Array".

@archiecobbs
The “[sponsor]” label has been removed.

[sponsor]: https://github.com/openjdk/jdk/labels/sponsor "Pull request is ready to be sponsored"

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

PR Comment: https://git.openjdk.org/jdk/pull/12646#issuecomment-1479724432


More information about the compiler-dev mailing list