Bug 211146 - Fields and methods of parameterized type introduced by ITDs become raw types after weaving
Summary: Fields and methods of parameterized type introduced by ITDs become raw types ...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 1.6.2   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-27 19:01 EST by Dmitry Amelin CLA
Modified: 2008-08-21 19:13 EDT (History)
2 users (show)

See Also:


Attachments
Isolated example classes, aspect and compile commands (1.31 KB, application/octet-stream)
2007-11-27 19:01 EST, Dmitry Amelin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Amelin CLA 2007-11-27 19:01:01 EST
Created attachment 83915 [details]
Isolated example classes, aspect and compile commands

Build ID: M20071023-1652

Steps To Reproduce:
1. Create empty class.
2. Create aspect, which introduces ITD method returning collection parameterized by String - public Collection<String> getStrings().
3. Weave classes.
4. Create class with main method, add string to collection and iterate collection with enhanced for loop.
5. Try to compile with java compiler - it won't.

More information:
If you compile classes in one compilation process, everything works fine as calls to fields/methods of parameterized type is preceded with casts.
Comment 1 Andrew Clement CLA 2008-08-21 19:13:52 EDT
Firstly we need to know if the generics information is preserved in how the ITD is captured post compile (and pre weave).

In ResolvedMemberImpl.write() we are writing out an EclipseResolvedMember that represents the ITD.  The signature is considered to be: ()Ljava/util/List; whilst the generics sig (our internal take on it) is <>()Pjava/util/List<Ljava/lang/String;>; indicating no type variables, no parameters, and a parameterized List as the return value.  Because the signatures differ we write out the parameter types and return type signatures in full (to preserve the generics info).

This is good news, the info should be there when the itd method is added to the target.

I've written a few tests for this and implemented the necessary fixes - seems to work.

I have tested:
- public ITDs with parameterized return types
- public ITDs with parameterized parameter types
- public ITDs that are generic and have parameterized return or parameter types
- public ITDs that target interfaces.
- public ITD fields of a parameterized type

For all these I've checked the class files created, not written full blown tests that exercise the functionality.  Apart from the case mentioned when the bug was raised, so I have fully checked separate compilation with another type that uses the ITD'd method.

I have not tested:
- anything other than public ITDs
- ITDs that share type variables with the target type
- the accessor methods generated on interfaces for ITD fields that target interfaces.

If someone wants to contribute more testcases, i'll contribute more fixes ;)

Samples of the kind of testcases I've created are here:
http://dev.eclipse.org/viewcvs/index.cgi/org.aspectj/modules/tests/bugs162/pr211146/?root=Tools_Project

(that link will go live in a little while once it picks up my submitted changes)