From: Arno P. <ar...@pu...> - 2011-03-18 19:36:00
|
this is one of those reasons we are moving to the C backend. Mapping the Java object model to the Objective-C object model causes these kinds of problems. Can you please generate a patch and submit to the review system? As long as we haven't switched to the C backend we're willing to look at Objective-C patches. (you have a CLA on file, right?) Arno On 3/18/11 8:43 AM, Troy Gaines wrote: > Hello everyone, > > It seems like the java.util.HashMap might be implemented incorrectly. > Either that, or I'm not seeing something. Below is the > implementation. I had some code that was cross-compiled over which had > the equals method and hashCode method implemented correctly. > > During the program run, it could not find User instances in the map. > What I discovered is this was only a problem when the User instances > were separate references even though the equals method and hashCode was > correct. > > I'm thinking the [NSValue valueWithPointer:key] compares references and > not the underlying values (in this case User). Has anyone seen this > same issue? This may not even be a problem in the new C back-end, but > I'm curious what you guys think. The only solution I could come up with > is to wrap the key in something else and forward the isEqual and hash > methods. > > - (java_lang_Object*) > put___java_lang_Object_java_lang_Object:(java_lang_Object*) key: > (java_lang_Object*) value { > java_lang_Object* oldObj = [self get___java_lang_Object:key]; > id k = [key conformsToProtocol: @protocol(NSCopying)] ? key : [NSValue > valueWithPointer: key]; > [self setObject:value forKey:k]; > return oldObj; > } > > Thanks again for all the great work! > > > > > ------------------------------------------------------------------------------ > Colocation vs. Managed Hosting > A question and answer guide to determining the best fit > for your organization - today and in the future. > http://p.sf.net/sfu/internap-sfd2d > > > > _______________________________________________ > Xmlvm-developers mailing list > Xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmlvm-developers |