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

Bug 369075

Summary: Java generator produces bad code for array attributes of non-basic types in DataClasses
Product: [Modeling] eTrice Reporter: Klaus Birken <klaus.birken>
Component: GeneratorsAssignee: Project Inbox <etrice.generators-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: hrr
Version: 0.1.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: 0.2.0M1

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