Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344908

Summary: Java method bodies generated twice
Product: [Modeling] MDT.UML2 Reporter: Kenn Hussey <Kenn.Hussey>
Component: CoreAssignee: Kenn Hussey <Kenn.Hussey>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 Flags: Kenn.Hussey: indigo+
Version: 3.1.0   
Target Milestone: RC1   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Kenn Hussey CLA 2011-05-05 21:20:05 EDT
If/when a Java body is expression is specified for an operation and code is generated for the model using EMF (via the UML importer), the code for the method is generated twice - once in the method itself and once in the operations class. If/when operations classes are enabled, the code should only be generated in one place - in the operations class.
Comment 1 Kenn Hussey CLA 2011-05-05 22:14:18 EDT
On second thought, the code should be generated into the method implementation (only) and NOT into the operations class. This is more backwards compatible, since existing code suffering from this (if any) will already have method implementations written from the perspective of an instance method and redundant implementations in the operations classes which are benign. Also, the intent behind operations classes is to avoid having to implement methods more than once in a hierarchy with multiple inheritance (such as that of UML), and this is already address in the case of Java body expressions by virtue of including the code as annotations (in one place) on the Ecore model.

There are currently three cases where methods do not delegate to an operations class, namely where any of the following have been specified for a given operation:

1. a method body
2. an invariant expression (as of EMF 2.6)
3. an invocation delegate (as of EMF 2.6)

The code that generates (redundant) method body code should be removed from the template for operations classes and the criteria for generating a method into an operations class should be modified to exclude operations that meet any of the above three criteria.
Comment 2 Kenn Hussey CLA 2011-05-08 23:17:27 EDT
The fix has been committed to CVS.
Comment 3 Kenn Hussey CLA 2011-05-17 23:01:33 EDT
The fix is available in the RC1 build.
Comment 4 Kenn Hussey CLA 2011-05-31 10:34:34 EDT
Closing for Indigo release.