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

Archie L. Cobbs duke at openjdk.org
Tue Mar 21 23:07:28 UTC 2023


> 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".

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/12646/files
  - new: https://git.openjdk.org/jdk/pull/12646/files/4c6e1377..fa787de2

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=12646&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=12646&range=00-01

  Stats: 347443 lines in 2599 files changed: 211701 ins; 115337 del; 20405 mod
  Patch: https://git.openjdk.org/jdk/pull/12646.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/12646/head:pull/12646

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


More information about the compiler-dev mailing list