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

Bogus javac error: required: no arguments, found: no arguments

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 21
    • 7u51, 9
    • tools
    • b05
    • x86_64
    • generic

      FULL PRODUCT VERSION :
      java version "1.7.0_51"
      OpenJDK Runtime Environment (IcedTea 2.4.4) (suse-24.13.5-i386)
      OpenJDK Server VM (build 24.45-b08, mixed mode

      ADDITIONAL OS VERSION INFORMATION :
      openSUSE 13.1

      Linux ops 3.13.7-x86-linode57 #1 SMP Tue Mar 25 09:45:52 EDT 2014 i686 i686 i386 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      The following program fails to compile:

      import com.google.common.base.Converter;
      public class xx<X, Y> {

          xx(Converter<X, Y> c) {
          }

          static void foo() {
              new xx<Integer, Integer>(Converter.<Integer, Integer>identity());
          }
      }

      The error message reported is:

      xx.java:8: error: method identity in class Converter<A,B> cannot be applied to given types;
              new xx<Integer, Integer>(Converter.<Integer, Integer>identity());
                                                ^
        required: no arguments
        found: no arguments
        reason: actual and formal argument lists differ in length
        where A,B are type-variables:
          A extends Object declared in class Converter
          B extends Object declared in class Converter
      1 error

      The error message makes no sense. It says "actual and formal argument lists differ in length" but both are zero and therefore the same length.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Download Google Guava 17.0 from http://search.maven.org/remotecontent?filepath=com/google/guava/guava/17.0/guava-17.0.jar
      2. Run "javac -cp guava-17.0.jar xx.java"
      3. Witness error message

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Program compiles successfully, or at least a more valid error message is generated if there is an error.


      ACTUAL -
      Program does not compile successfully.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      xx.java:8: error: method identity in class Converter<A,B> cannot be applied to given types;
              new xx<Integer, Integer>(Converter.<Integer, Integer>identity());
                                                ^
        required: no arguments
        found: no arguments
        reason: actual and formal argument lists differ in length
        where A,B are type-variables:
          A extends Object declared in class Converter
          B extends Object declared in class Converter
      1 error


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import com.google.common.base.Converter;
      public class xx<X, Y> {

          xx(Converter<X, Y> c) {
          }

          static void foo() {
              new xx<Integer, Integer>(Converter.<Integer, Integer>identity());
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None known.

            vromero Vicente Arturo Romero Zaldivar
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: