eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

Sequence Parameters in Generated *Impl OCL Operations Result Unboxed Values of Null #1445

Closed eclipse-ocl-bot closed 1 month ago

eclipse-ocl-bot commented 1 month ago

| --- | --- | | Bugzilla Link | 458772 | | Status | RESOLVED INVALID | | Importance | P3 normal | | Reported | Jan 29, 2015 16:01 EDT | | Modified | Jan 30, 2015 15:02 EDT | | Version | 5.0.0 | | Reporter | Robert Daniels |

Description

I've looked through the bug reports and did not see anything that I could correlate to this issue...

I've run into this problem while attempting to generate OCL into *Impl classes. An operation with a Sequence as one of the parameters, the corresponding code that is generated to call this operation attempts to get the unboxed value of null and is missing a parameter in the GET_UNBOXED_VALUE() method.

The following is a model that can reproduce the issue...\ -------------------\ import ecore : 'http://www.eclipse.org/emf/2002/Ecore';

package rootPackage : rootPackage = 'http://www.example.com/rootPackage/2.0'\ {\ package subPackage : subPackage = 'http://www.example.com/subPackage/2.0'\ {\ class SubElement\ {\ operation op(tokens : String[] { ordered !unique }) : Boolean\ {\ body: \ \ if tokens->at(1) = '1'\ then\ op2(tokens)\ else\ true\ endif;\ }\ operation op2(tokens : String[] { ordered !unique }) : Boolean\ {\ body: \ true;\ }\ }\ }\ abstract class Element\ {\ attribute name : String = '';\ }\ }\ -------------------\ The following is a sample of the generated Java code.

if (eq) {\ final /@NonNull/ /@NonInvalid/ List<?> UNBOXED_tokens = null.GET_UNBOXED_VALUE(, "String");\ final /@NonNull/ /@Thrown/ Boolean op2 = self.op2((EList)UNBOXED_tokens);\ symbol_0 = op2;\ }\

Please forgive me if this is a duplicate or if I'm missing something obvious....

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Jan 30, 2015 06:31

This seems to be fixed in that latest 6.0.0 I-build.

Generated code is:

        final /*@Thrown*/ boolean op2 = this.op2(tokens);

propagating the Ecore representation unchanged.

But just looking at the generated code for collections highlights that we must avoid unnecessary conversions. Sequence(String) really should be easy.

eclipse-ocl-bot commented 1 month ago

By Robert Daniels on Jan 30, 2015 10:59

I've confirmed this is fixed mdt-ocl-Update-I201501261843.

eclipse-ocl-bot commented 1 month ago

By Ed Willink on Jan 30, 2015 15:02

(In reply to Robert Daniels from comment #0)

GET_UNBOXED_VALUE() method.

This was a placeholder in the Kepler release for an unsupported conversion. It was replaced very early in the Luna release cycle.

This is therefore a 4.x.x not a 5.0.0 bug report.

The CG is experimental. Luna is significantly better than Kepler.