Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Problem with ajc and generics?

Hello,

That code compiles fine for me with AspectJ1.5.4 or the more recent
1.6.0. However, I am on a Mac.

The AspectJ compiler is based on the JDT compiler at its heart - and
so that compiler is being used to compile language features like
generics.  AspectJ1.5.4 includes the Eclipse 3.1 compiler - have you
tried using the eclipse 3.1 compiler to build that code?

AspectJ1.6.0 is based on the Eclipse3.3 compiler.  Between those two
compiler levels (3.1 and 3.3) there are many generics related
compilation bugs that were fixed - including things similar to the
problem you are seeing.

I would presume if you look at the definition of HashMap within the
IBM and Sun VMs - you might see a difference and that is what is
causing the problem.  How many put methods are defined within the IBM
and Sun JDKs?  Are there bridge methods within the classes that
differ?

If you recompile the code with AspectJ1.6.0 and it works fine, I would
put it down to a difference between the old eclipse 3.1 and the new
eclipse 3.3 compilers and suggest the raiser upgrade to the latest
version.

Andy.

On 21/02/2008, David Griffiths <dgriff@xxxxxxxxxxxxxxx> wrote:
>
>
>  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
>
> _______________________________________________
>  aspectj-dev mailing list
>  aspectj-dev@xxxxxxxxxxx
>  https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>
>


Back to the top