Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 250876 - Paramaterized Instance Type Name in EClass object (in ECore) causes incorrect code generation
Summary: Paramaterized Instance Type Name in EClass object (in ECore) causes incorrect...
Status: VERIFIED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: Tools (show other bugs)
Version: 2.4.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 247980 253169
  Show dependency tree
 
Reported: 2008-10-14 23:18 EDT by Simon Pope CLA
Modified: 2009-06-25 10:15 EDT (History)
2 users (show)

See Also:


Attachments
Model illustrating the problem (31.66 KB, application/octet-stream)
2008-10-20 13:56 EDT, Ed Merks CLA
no flags Details
Patches to improve the behavior (17.12 KB, patch)
2008-10-20 14:05 EDT, Ed Merks CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Pope CLA 2008-10-14 23:18:21 EDT
Build ID: M20080911-1700

Steps To Reproduce:
Using 2.4.1 of EMF...

Create an ABSTRACT, INTERFACE EClass node inside an ECore file, and name it "JComparableObject". Set the "Instance Type Name" to "Comparable<Object>".

Create another EClass node with an ESuperType of "JComparableObject" (i.e. thatt corresponds to the first created node).

Open up the corresponding genmodel and generate model code. The generation will produce incorrect code for two generated methods:

  eBaseStructuralFeatureID(int, Class<?>), and
  eDerivedStructuralFeatureID(int, Class<?>)

The offending code in each will be: 

  "if (baseClass == Comparable<Object>.class)"

The correct solution is to have the generator drop the parameterization, producing this instead:

  "if (baseClass == Comparable.class)"

which will, of course, compile.

More information:
Comment 1 Simon Pope CLA 2008-10-14 23:40:08 EDT
BTW, the Instance Type Name should be:

    "java.lang.Comparable<java.lang.Object>"

and not the shorthand I wrote in the summary.
Comment 2 Simon Pope CLA 2008-10-14 23:55:39 EDT
OK, scratch that. I must have missed the "Show Generics" features in the Ecore editor.

The correct solution is to paramaterize the first eclass object, and then select the EJavaObject as the Generic Type Argument.

Easy peasy.
Comment 3 Ed Merks CLA 2008-10-20 13:54:12 EDT
Although what you've sketched out is a better way, what you did originally should have worked properly.  I'll attach an example model that reproduces your problem.
Comment 4 Ed Merks CLA 2008-10-20 13:56:16 EDT
Created attachment 115586 [details]
Model illustrating the problem

Note that it takes multiple inheritance to reproduce the problem.
Comment 5 Ed Merks CLA 2008-10-20 14:05:21 EDT
Created attachment 115587 [details]
Patches to improve the behavior

Note that I looked in the templates for anywhere we generated <something>.class and ensured that we use the raw type there.  Does this look okay to you Dave?
Comment 6 Dave Steinberg CLA 2008-11-02 16:24:56 EST
Looks good Ed.  This looks like a good candidate to fix in 3.4.2 to me, as well.  Do you think so?
Comment 7 Ed Merks CLA 2008-11-02 18:52:23 EST
Dave,

Not no much because who's generating RCP without Java 5.0 in EMF 2.4?
Comment 8 Ed Merks CLA 2008-11-03 06:48:47 EST
The changes have been committed to CVS for 2.5.

I confused this with the RCP editor bug.  This seems a little more important to fix in 2.4.x, though not crucial, but we may as well.

Kenn,

This bug affects UML's templates.
Comment 9 Nick Boldt CLA 2008-11-06 13:35:52 EST
Fix available in HEAD: 2.5.0M3 (S200811032126).
Comment 10 Dave Steinberg CLA 2009-06-25 02:56:43 EDT
Fix available in HEAD: 2.5.0 (R200906151043).