Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8029301

Confusing error message for array creation method reference

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 21
    • 8
    • tools
    • b16

      Array creation method references are treated internally as references to a constructor of an array type. But this internal encoding doesn't make much sense to users, when it is leaked to them via an error message:

      error: incompatible types: invalid constructor reference
        Runnable r2 = 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

      A more useful message would be something specialized like "array creation requires a single int parameter" or just "incompatible functional interface target type".

            vromero Vicente Arturo Romero Zaldivar
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: