Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361733 - GenericType resolution for subclass of BaseMap$Entry
Summary: GenericType resolution for subclass of BaseMap$Entry
Status: RESOLVED INVALID
Alias: None
Product: EMF
Classification: Modeling
Component: Core (show other bugs)
Version: 2.7.1   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-22 13:42 EDT by Michael Woski CLA
Modified: 2012-12-19 09:35 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Woski CLA 2011-10-22 13:42:54 EDT
I'm trying to create an ecore model that needs map references. I therefore created a generic stereotype that has its "class instance name" property set to java.util.Map$Entry. The ecore model roughly translates to this:

abstract IndexedObject<T> {
  Character key
  T value
}

I then use it like this:

ContainmentClass {
  IndexedObject<MyWrappedObject> wrappedObjects
}

When I generate the java code for this model the IndexedObject reference is translated into a Map.Entry, as I would have expected. However, the type parameter of IndexedObject<MyWrappedObject> is not getting resolved properly; instead of getting Map.Entry<Character, MyWrappedObject> a Map.Entry<Character, T> is being generated.

My guess is that this only needs some minor tweaking of the model parser, since syntactically everything looks alright.

I hope I could make my point clear, thx.
Comment 1 Ed Merks CLA 2011-10-23 02:12:09 EDT
Sorry, maps aren't designed to work this way. You must fully define the key and feature types in the map entry class.  I could investigate whether it's feasible to enhance the design to allow type parameters, but that's a significant bit of design work that will likely require some complex changes.
Comment 2 Michael Woski CLA 2011-10-23 08:58:12 EDT
(In reply to comment #1)
Hi Ed,

certainly I'm a bit naiv, but at least my abstract base class IndexedObject is properly generated, including its type parameter. It's only when I use it in a reference with a concrete type that the generated code does not have that concrete type, but rather the literal of the type parameter of my subclassed IndexedObject.
Comment 3 Ed Merks CLA 2012-12-19 09:35:44 EST
When you wrap an existing Java interface, the number of type parameters must be the same, and the bounds on each type parameter must be the same.  This is essentially the same issue as in https://bugs.eclipse.org/bugs/show_bug.cgi?id=384699