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

Compiler complains about ambiguity

XMLWordPrintable

    • generic
    • generic

      From: ###@###.###
      Date: Thu, 24 Mar 2005 19:21:27 +0100

      public class AttributeList extends ArrayList {
           public AttributeList(AttributeList al) {...}
           public AttributeList(List<Attribute> l) {...}
      }

      For some surprising compatibility reasons, AttributeList can't extend
      ArrayList<Attribute>, even though that is what it really is. It just
      extends raw ArrayList.

      What we're seeing is that the following code:

      AttributeList al =
           new AttributeList(new AttributeList());

      gives the following error:

      AL.java:6: reference to AttributeList is ambiguous, both method
      AttributeList(javax.management.AttributeList) in
      javax.management.AttributeList and method
      AttributeList(java.util.List<javax.management.Attribute>) in
      javax.management.AttributeList match
               AttributeList al = new AttributeList(new AttributeList());
                                  ^


      ###@###.### 2005-03-24 20:00:46 GMT

            Unassigned Unassigned
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: