From: Gergely K. <ger...@ma...> - 2010-03-26 17:59:27
|
Hi, There are already multiple patches in the review queue for the Collections Framework. Following my previous suggestion, I am now trying to open a discussion regarding the design of the collections framework. In our patch ( http://xmlvm-reviews.appspot.com/18002) you can already see a partial implementation of this suggestion. Requirements: 1. Need to support seamless integration between regular ObjC types (NSArray ... etc.) and Java classes -> use categories 2. Need to support subclassing for non-final classes. This is a problem with using class clusters as the basis. The proposal: 1. Create the interfaces as protocols (java_util_List, java_util_Map ... etc.) 2. Implement the interfaces as categories of the non-mutable ObjC collection classes. (NSArray, NSSet, NSDictionary) - The mutator methods are implemented to throw UnsupportedOperationException. In essence you receive the same behavior as if you used Collections.unmodifiable*() methods 3. Only implement the mutator methods in the NSMutable* collection classes. At this point any ObjC collection can be used as a regular Java collection. Now we need to implement the actual concrete classes. However class clusters cannot be subclassed easily. The solution is to implement the concrete classes using NSProxy. (See how java_util_Vector is implemented in our patch). However, this implementation adds an unnecessary indirection and performance overhead. So the idea is to detect in the proxy class init function whether a subclass is instantiated. If it is not a subclass, then simply return the appropriate NSMutable* instance. Otherwise return the proxy. What do you think? If you agree with this approach we can clean up our implementation, and submit it separately. Best Regards, Gergely -- Kis Gergely MattaKis Consulting Email: ger...@ma... Web: http://www.mattakis.com Phone: +36 70 408 1723 Fax: +36 27 998 622 |