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

Bug 206812

Summary: Adopt J2SE 5.0 in Query Component
Product: [Modeling] EMF Services Reporter: Christian Damus <give.a.damus>
Component: QueryAssignee: Christian Damus <give.a.damus>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: Ed.Merks
Version: unspecifiedKeywords: api, plan
Target Milestone: ---Flags: Ed.Merks: review+
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
First pass at adopting J2SE 5.0-isms ahunter.eclipse: iplog+

Description Christian Damus CLA 2007-10-18 15:08:12 EDT
The EMF core run-time and tools adopted J2SE 5.0 APIs and language additions in the 2.3 release (see bug 79768 for details).

The Query component should do likewise for the 1.2 (Ganymede) release.
Comment 1 Christian Damus CLA 2007-10-21 20:52:51 EDT
Created attachment 80842 [details]
First pass at adopting J2SE 5.0-isms

Attached a patch implementing a first pass at adopting J2SE 5.0 language features and APIs.  This patch deals with generic types.
Comment 2 Christian Damus CLA 2007-10-21 20:59:20 EDT
Hi, Ed, when you get a chance, could you review the attached patch?  I had briefly considered add an

   <E extends EObject>

type parameter to the EObjectCondition class indicating the type of object matched by the condition, and propagating that through the WHERE clause into the SELECT statement, so that clients would be able to declare the result type of a query (e.g., SELECT<Book> would return an IQueryResult<Book> providing an Iterator<Book> to get the results).  That idea didn't last long, as I quickly realized that most queries would want to be able to handle dynamic EMF, as well, which doesn't have the convenient type system of statically generated APIs, so clients would have to declare everything as <EObject> anyway.

Any other ideas for types/operations that should be generic would be most welcome.
Comment 3 Ed Merks CLA 2007-10-23 07:23:40 EDT
I only looked at that org.eclipse.emf.query plugin.  It looks good to me.  My only very minor concern is that the code assumes that all generated APIs explicitly extend EObject in their API.  E.g., if I have a List<Library> and Library doesn't extend EObject, I can't pass it to List<? extends EObject> without casting; but I think that's okay; after all, EMF has many EObject methods and you'd have to cast to EObject to call them.  I just want to be sure it's an explicit decision on your part.
Comment 4 Christian Damus CLA 2007-10-23 08:11:22 EDT
Thanks, Ed.  There wasn't any other plug-in to look at ... the rest is really just noise  :-)

Yes, it did actually occur to me that APIs generated without the EObject interface would require lots of unchecked casts in client code.  However, the whole point of the generic declarations is to promote type safety, so it's essential that the API only accept inputs that actually are EObjects, because it needs the services provided by EObject.

I think that in a J2SE 5.0+ world of generics, users of EMF would best be advised to explicitly extend EObject for this reason.  Otherwise, they will never have code that the compiler can assure them is type safe!
Comment 5 Christian Damus CLA 2007-11-08 18:03:38 EST
Committed the changes to CVS HEAD (1.2 branch).
Comment 6 Christian Damus CLA 2007-11-14 15:28:32 EST
Fixed in the EMF QUERY 1.2.0 I200711141410 build.
Comment 7 Nick Boldt CLA 2008-01-28 16:35:50 EST
Move to verified as per bug 206558.