Re: EO generating and Interfaces
Re: EO generating and Interfaces
- Subject: Re: EO generating and Interfaces
- From: Mike Schrag <email@hidden>
- Date: Wed, 21 May 2008 22:53:31 -0400
public NSArray<RRSCalendarEvent> workshopEvents() { return (NSArray<RRSCalendarEvent>)workshops();; }
This is really not a safe cast to make, because generic types aren't covariant, NSArray<WorkshopMaster> does not "extend" NSArray<RSSCalendarEvent>, because there's no runtime type information to guarantee the type-safety like there is for Arrays (which do have covariance). For arrays, if you do RSSCalendarEvent[] events = new WorkshopMaster[1]; and you try to assign some other subclass of RSSCalendarEvent to the array, you'll get a runtime exception (i think an ArrayStore maybe? might be a ClassCast, but I think it's ArrayStore), because the Java type system carries around that it's ACTUALLY a WorkshopMaster array even though you are just "calling it" an RSSCalendarEvent[]. But for generics, there is no runtime type for generics, so it can't perform this check. Even the bounded type is sort of sketchy in this particular case, because it has some of the same semantic problems, but it should prevent the compiler complaint.
ms |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden