Design, java code generation and template parameters [message #1786192] |
Thu, 26 April 2018 16:46 |
Tristan Faure Messages: 460 Registered: July 2009 |
Senior Member |
|
|
Hello
a coworker tries to generate java code with classifier template
to test we have
- Class T
- Class T1 extends T
- Class List, classifier template parameter T
- method foo returns T
- Class MyList extends T with a binding T1 -> T
but at java code generation
- Class List<T> : OK but method foo returns packageName.T and not T
- Class MyList is not generated.
is it something managed
we use Eclipse v4.7 oxygen, Papyrus 3.3.0.2018, Designer 1.0.5
[Updated on: Thu, 26 April 2018 16:48] Report message to a moderator
|
|
|
|
Re: Design, java code generation and template parameters [message #1786921 is a reply to message #1786898] |
Tue, 15 May 2018 15:32 |
|
Hi Tristan,
sorry for the late reply. I have some trouble to understand the example: Why does MyList extend T and why is T1 is bound to T? I would rather expect that MyList has a template binding relationship with List in which T (the formal parameter) is bound to some other type (T -> otherType), but no inheritance from T. It seems that you are binding T1 which is not a parametered element of the signature (if I understand the setup right). Can you eventually post your example model?
Ansgar
|
|
|
Re: Design, java code generation and template parameters [message #1787008 is a reply to message #1786921] |
Thu, 17 May 2018 09:16 |
|
I tried the code generation from my sample model (which might not correspond to yours). In this model, class List defines a template parameter (DataType) T in its signature, the operation foo returns this type. MyList has a template binding relationship with list in which T is bound to class MyListElem. Class ListUser declares an attribute list of type MyList.
The code generated for List and ListUser looks ok (see below). No code is generated for MyList itself, but I don't consider this as a bug: there is no Java means to declare such a binding, you just use the bound classes at different places, such as the attribute declaration in class ListUser.
public class List<T> {
/** ... */
public T foo() {
return null;
}
};
public class ListUser {
public List<MyListElem> list;
};
|
|
|
Powered by
FUDForum. Page generated in 0.03528 seconds