Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem with Generics, inheritance and ecore validation
Problem with Generics, inheritance and ecore validation [message #414497] Fri, 09 November 2007 14:25 Go to next message
Benett is currently offline BenettFriend
Messages: 3
Registered: July 2009
Junior Member
Hello @ all !

I'm experiencing a trouble with EMF (ecore) validation about generics,
inheritance and upper bound. I think it's a lack (or bug ?) of the EMF
validator, but I'm not sure... Ready for the challenge ? Go ! :)
I'm making a simple application based on RCP/GEF/EMF that will be used to
make plannings. I made a simple model *framework* - that currently works -
with these classes (in EMF style) :

[] Planning<task extends Task, pp extends People<task>> -> Class
=>() task extends Task -> Generics : Type Parameter
() Task
=>() res extends People<task> -> Generics : Type Parameter
() People<task>
(<>) task
-> listPeople : pp -> Reference
(:) pp

[] People<task extends Task> -> Class
=>() task extends Task -> Generics : Type Parameter
() Task
-> listTasks : task -> Reference
(:) task

[] Task -> Class
-> people : People<? extends Task> -> Reference
(:) People<? extends Task>
(<>) ? extends Task


*Here is the problem* : I try to extend the framework by providing
specialized classes :

[] MySpecificTask -> Class
(|) Task -> Generic super type

[] MySpecificPeople<MySpecificTask> -> Class
(|) People<MySpecificTask> -> Generic super type
(<>) MySpecificTask

[] Program<MySpecificTask, MySpecificPeople> -> Class
(|) Planning<MySpecificTask, MySpecificPeople> -> Generic super type
(<>) MySpecificTask
(<>) MySpecificPeople

My error is when I try to validate this ecore model, I get a "problem
encountered during validation" : *The generic type 'MySpecificPeople' is
not a valid substitution for type parameter 'pp extends People<Task>'*,
error thrown on the "Program" declaration in the ecore. However, this
declaration should be correct, as I created it "from scratch" correctly (I
mean with no compile error). *Is there a way to make it valid from the
validator point of view ?*

I found a workaround (which is to add a type parameter to the
MySpecificPeople class), but I think this solution is quite ugly and less
easy to use... :(

So, please, can anyone (ideally an EMF team member ?) tell me if this is
an EMF validator bug, or if a way exists to make my dream come true ?

Thanks at all people that read this post until the end, and I promise a
candy to all people that answers me *with the solution* :)

Benett
Re: Problem with Generics, inheritance and ecore validation [message #414498 is a reply to message #414497] Fri, 09 November 2007 14:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Benett,

I'd have a much easier time if you could attach the Ecore model itself
or if you could send it to me at merks at ca dot ibm dot com.


Benett wrote:
> Hello @ all !
>
> I'm experiencing a trouble with EMF (ecore) validation about generics,
> inheritance and upper bound. I think it's a lack (or bug ?) of the EMF
> validator, but I'm not sure... Ready for the challenge ? Go ! :)
> I'm making a simple application based on RCP/GEF/EMF that will be used
> to make plannings. I made a simple model *framework* - that currently
> works - with these classes (in EMF style) :
>
> [] Planning<task extends Task, pp extends People<task>> -> Class
> =>() task extends Task -> Generics : Type Parameter
> () Task
> =>() res extends People<task> -> Generics : Type Parameter
> () People<task>
> (<>) task
> -> listPeople : pp -> Reference
> (:) pp
>
> [] People<task extends Task> -> Class
> =>() task extends Task -> Generics : Type Parameter
> () Task
> -> listTasks : task -> Reference
> (:) task
>
> [] Task -> Class
> -> people : People<? extends Task> -> Reference
> (:) People<? extends Task>
> (<>) ? extends Task
>
>
> *Here is the problem* : I try to extend the framework by providing
> specialized classes :
>
> [] MySpecificTask -> Class
> (|) Task -> Generic super type
>
> [] MySpecificPeople<MySpecificTask> -> Class
> (|) People<MySpecificTask> -> Generic super type
> (<>) MySpecificTask
>
> [] Program<MySpecificTask, MySpecificPeople> -> Class
> (|) Planning<MySpecificTask, MySpecificPeople> -> Generic super type
> (<>) MySpecificTask
> (<>) MySpecificPeople
>
> My error is when I try to validate this ecore model, I get a "problem
> encountered during validation" : *The generic type 'MySpecificPeople'
> is not a valid substitution for type parameter 'pp extends
> People<Task>'*, error thrown on the "Program" declaration in the
> ecore. However, this declaration should be correct, as I created it
> "from scratch" correctly (I mean with no compile error). *Is there a
> way to make it valid from the validator point of view ?*
>
> I found a workaround (which is to add a type parameter to the
> MySpecificPeople class), but I think this solution is quite ugly and
> less easy to use... :(
>
> So, please, can anyone (ideally an EMF team member ?) tell me if this
> is an EMF validator bug, or if a way exists to make my dream come true ?
>
> Thanks at all people that read this post until the end, and I promise
> a candy to all people that answers me *with the solution* :)
>
> Benett
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem with Generics, inheritance and ecore validation [message #414503 is a reply to message #414498] Fri, 09 November 2007 15:44 Go to previous messageGo to next message
Benett is currently offline BenettFriend
Messages: 3
Registered: July 2009
Junior Member
Hello,

thanks for your quick reply ! In response to your post, I sent you a mail
containing the "problematic" ecore (in both ecore and zip format). Did you
receive it ?
You can either post a response in my mailbox or in the newsgroup. In the
first case, I will post (if relevant) the answer to the newsgroup to make
the community aware of our work...
Re: Problem with Generics, inheritance and ecore validation [message #414509 is a reply to message #414503] Fri, 09 November 2007 16:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Benett,

It appears to be a bug, so I'll need to do some digging in the complex
code that enforces the constraints for this...


Benett wrote:
> Hello,
>
> thanks for your quick reply ! In response to your post, I sent you a
> mail containing the "problematic" ecore (in both ecore and zip
> format). Did you receive it ?
> You can either post a response in my mailbox or in the newsgroup. In
> the first case, I will post (if relevant) the answer to the newsgroup
> to make the community aware of our work...
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem with Generics, inheritance and ecore validation [message #414523 is a reply to message #414509] Sat, 10 November 2007 14:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Benett,

The code that is supposed to validate whether A<X> is bound for B<Y>,
which is the case if B extends A and X == Y, was confused because you
actually had C extends B<Y>, and in that case it should be checking that
the Y from B<Y> is equal to X and was instead upset that C had not
argument at all. I have a patch I'll commit for EMF 2.3.2 and 2.4 once
waiting for you to open a bugzilla...


Ed Merks wrote:
> Benett,
>
> It appears to be a bug, so I'll need to do some digging in the complex
> code that enforces the constraints for this...
>
>
> Benett wrote:
>> Hello,
>>
>> thanks for your quick reply ! In response to your post, I sent you a
>> mail containing the "problematic" ecore (in both ecore and zip
>> format). Did you receive it ?
>> You can either post a response in my mailbox or in the newsgroup. In
>> the first case, I will post (if relevant) the answer to the newsgroup
>> to make the community aware of our work...
>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem with Generics, inheritance and ecore validation [message #414528 is a reply to message #414523] Sat, 10 November 2007 22:42 Go to previous message
Benett is currently offline BenettFriend
Messages: 3
Registered: July 2009
Junior Member
Ed,

Thank you for having solved the problem before I added a new entry in
bugzilla :)
The bugzilla added is the number 209420.
Thanks once again for having spent time on this problem !

Benett


Ed Merks wrote:

> Benett,

> The code that is supposed to validate whether A<X> is bound for B<Y>,
> which is the case if B extends A and X == Y, was confused because you
> actually had C extends B<Y>, and in that case it should be checking that
> the Y from B<Y> is equal to X and was instead upset that C had not
> argument at all. I have a patch I'll commit for EMF 2.3.2 and 2.4 once
> waiting for you to open a bugzilla...


> Ed Merks wrote:
>> Benett,
>>
>> It appears to be a bug, so I'll need to do some digging in the complex
>> code that enforces the constraints for this...
>>
>>
>> Benett wrote:
>>> Hello,
>>>
>>> thanks for your quick reply ! In response to your post, I sent you a
>>> mail containing the "problematic" ecore (in both ecore and zip
>>> format). Did you receive it ?
>>> You can either post a response in my mailbox or in the newsgroup. In
>>> the first case, I will post (if relevant) the answer to the newsgroup
>>> to make the community aware of our work...
>>>
Previous Topic:Problem with EMap using EStore
Next Topic:Defining my own types
Goto Forum:
  


Current Time: Fri Apr 26 03:50:26 GMT 2024

Powered by FUDForum. Page generated in 0.03610 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top