Hi, I work in IBM Java Service and we've just had the following problem
submitted to us. I'm not sure whether the problem is in ajc or in our
JDK and since I'm new to aspectj I've no idea how to proceed. It may
well be our JDK but the test apparently compiles fine with javac and I
don't know what ajc is adding to the mix. Here is the problem as
reported, any suggestions would be much appreciated!
*Abstract: *Win32* aspectj - put is ambiguous for
HashMap<Integer,String>
*Operating system: Win32, Windows XP SP2
*JDK short version: 5.0
*JDK full version: j9vmwi3223-20071007
*Testcase provided: Yes
*JDK component: javac
*Java components: aspectj 1.5.4
*Machine details: Thinkpad T42p
*Symptoms: When using aspectj to compile code that uses
HashMap<Integer,String>, I get an error when invoking the put() method:
C:\java\test\aspect\HashMapTest.java:21 [error] The method put(Integer,
String) is ambiguous for the type HashMap<Integer,String>
integerStringMap.put(i, s);
The error does not occur when using the Sun JDK.
The error appears to be related to the use of Integer as the key with
HashMap; HashMap<String,String> works fine. And
Hashtable<Integer,String> also works.
The code compiles and runs correctly using javac.
===========
Sample code (HashMapTest.java):
import java.util.HashMap;
import java.util.Hashtable;
public class HashMapTest
{
public void main (String [] args)
{
Integer i = new Integer(1);
String s = "xxx";
Hashtable<String, String> stringStringTable = new Hashtable<String, String>();
stringStringTable.put(s, s);
Hashtable<Integer, String> integerStringTable = new Hashtable<Integer, String>();
integerStringTable.put(i, s);
HashMap<String, String> stringStringMap = new HashMap<String, String>();
stringStringMap.put(s, s);
HashMap<Integer, String> integerStringMap = new HashMap<Integer, String>();
integerStringMap.put(i, s);
}
}
=========
aspectj invocation:
ajc HashMapTest.java -source 1.5
*Behaviour differences: This error does not occur with an earlier IBM
JDK version I have installed:
Java(TM) 2 Runtime Environment, Standard Edition (build
pwi32devifx-20070323 (ifix 117674: SR4 + 116644 + 114941 + 116110 +
114881))
And the error does not occur with the current Sun Java SE 5.0 compiler:
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Thanks!
Dave