Eclipse 3.4. Java compiler level 1.6 JRE IBM 1.6
We have a library class that we cannot change that is of the form.
import java.util.Hashtable;
public class A extends Hashtable {
...
}
And we have build a utility class to provide easy access to A.
public class B {
private A a;
public B() {
this.a = new A();
}
public B(final A props) {
this.a = props;
}
public B(final Map<String, String> props) {
this();
for (String key : props.keySet()) {
add(key, props.get(key));
}
}
@SuppressWarnings("unchecked")
public B add(final String name, final Object value) {
a.put(name, value);
return this;
}
}
The problem occurs when we try to call one of the constructors from another class.
public class C {
public void stuff() {
A a = new A();
B b = new B(a);//Error in javac
}
}
Eclipse compiles this without error, and when it is compiled through ant javac and jenkins the compiler gives an error like the following.
reference to B is ambiguous, both method B(com.foo.A) in com.bar.B and method B(java.util.Map<java.lang.String,java.lang.String>) in com.bar.B match
[javac] B b = new B(a);
Should this error happen in javac? In my view eclipse is correct in selecting the more specific method.
HashTable
. Should that beHashtable
? – David Grantpublic B(final Map props)
. Not sure why. Sounds like a bug injavac
. – dogbane