Duplicate :
|
The JMX API was recently generified in Mustang. In those changes, the class javax.management.AttributeList acquired a new constructor. In outline form, we have: public class AttributeList extends ArrayList { public AttributeList() {...} public AttributeList(AttributeList list) {...} public AttributeList(int initialCapacity) {...} public AttributeList(List<Attribute> list) {...} public void add(Attribute object) {...} ... } With this in place, the following statement: AttributeList al = new AttributeList(new AttributeList()); fails to compile: 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()); ^ I do not believe that this can be correct. The constructor argument here has a type as specific as it can possibly be, so if this behaviour were correct it would mean that the AttributeList(AttributeList) constructor can never be invoked by any Java expression. The compiler should not agree to generate such a constructor. (By the way, AttributeList would ideally extend ArrayList<Attribute> rather than just ArrayList, but the add method shown above prevents this since its return type is void rather than boolean.) ###@###.### 2005-03-25 10:22:15 GMT