Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 369075 - Java generator produces bad code for array attributes of non-basic types in DataClasses
Summary: Java generator produces bad code for array attributes of non-basic types in D...
Status: CLOSED FIXED
Alias: None
Product: eTrice
Classification: Modeling
Component: Generators (show other bugs)
Version: 0.1.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: 0.2.0M1
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-19 08:59 EST by Klaus Birken CLA
Modified: 2012-03-28 05:12 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Klaus Birken CLA 2012-01-19 08:59:04 EST
Non-basic array attributes in a DataClass will lead to bad Java code. Example:

	DataClass ExampleSimple {
		Attribute a : int16
	}
	DataClass ExampleArrayDerived {
		Attribute val [ 19 ] : ExampleSimple
	}

From the above model, the Java generator produces

// default constructor
public ExampleArrayDerived() {
	val = new ExampleSimple();  // !! Type mismatch: cannot convert from ExampleSimple to ExampleSimple[]
}
	
// deep copy
public ExampleArrayDerived deepCopy() {
	ExampleArrayDerived copy = new ExampleArrayDerived();
	copy.val = val.deepCopy();  // !! Cannot invoke deepCopy() on the array type ExampleSimple[]
	return copy;
}

This code is not compilable (see comments with the compiler's error messages).
Comment 1 Henrik Rentz-Reichert CLA 2012-01-19 11:50:02 EST
This is already fixed in the mail line of the development (when the new types were introduced).

But a closer look at DataClass (with inheritance) generation lead to a number of fixes and improvements (see commit 40ff55bc1e31c1ec8a70f396af371b44f6ae8b11).

Thanks for reporting this.

If you want to pick up the changes you have to use our nightly builds from
http://download.eclipse.org/etrice/updates/nightly
Comment 2 Henrik Rentz-Reichert CLA 2012-03-28 05:12:52 EDT
closing bugs that went into 0.2.0M1