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

Wrong error message when same name and same erasure type of constructors are declared.

XMLWordPrintable

    • generic
    • generic

      Tried on Linux JDK build 1.6.0-auto-073
      Compiler will throw wrmog error message when same name and same erasure type constructors are delcared.

      Please see the following code:
      <code>
      class TestConstructor<T, K> {
          public TestConstructor(K k) {}
          public TestConstructor(T t) {}
          @SuppressWarnings("unchecked")
          public static void main(String... arg){
              TestConstructor tc = new TestConstructor("string");
          }
      }
      <\code>

      Ouput of the code when compiled :

      <output>
      Test17.java:6: reference to TestConstructor is ambiguous, both method TestConstructor(K) in TestConstructor and method TestConstructor(T) in TestConstructor match
              TestConstructor tc = new TestConstructor("string");
                                   ^
      1 error
      </output>

      ---
      In the error message TestConstructor(T) and TestConstructor(K) described as methods, should be constructors.


      ###@###.### 2005-04-17 16:24:17 GMT

            mcimadamore Maurizio Cimadamore
            savadhansunw Seetharama Avadhanam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: