From: Markus H. <ma...@ti...> - 2011-03-17 20:43:34
|
Hi, I'm trying to convert a class that implements the Comparator interface with the c-backend. Unfortunately using that class as a comparator (e.g. in Arrays.sort) gives a EXC_BAD_ACCESS. In the included source snippet, you can see, that the com_sun_media_sound_ModelInstrumentComparator_compare___javax_sound_midi_Instrument_javax_sound_midi_Instrument function is bound to __TIB_com_sun_media_sound_ModelInstrumentComparator.vtable[11] . But a little bit later in the interface vtable __TIB_com_sun_media_sound_ModelInstrumentComparator.vtable[12] is used, which is unset and leads to the error. I have manually changed the 12 to 11 in that line and the code works fine after that. void __INIT_IMPL_com_sun_media_sound_ModelInstrumentComparator() { if (!__TIB_com_sun_media_sound_ModelInstrumentComparator.classInitializationBegan) { __TIB_com_sun_media_sound_ModelInstrumentComparator.classInitializationBegan = 1; // Initialize base class if necessary if (!__TIB_java_lang_Object.classInitialized) __INIT_IMPL_java_lang_Object(); __TIB_com_sun_media_sound_ModelInstrumentComparator.newInstanceFunc = __NEW_INSTANCE_com_sun_media_sound_ModelInstrumentComparator; // Copy vtable from base class XMLVM_MEMCPY(__TIB_com_sun_media_sound_ModelInstrumentComparator.vtable, __TIB_java_lang_Object.vtable, sizeof(__TIB_java_lang_Object.vtable)); // Initialize vtable for this class __TIB_com_sun_media_sound_ModelInstrumentComparator.vtable[11] = (VTABLE_PTR) &com_sun_media_sound_ModelInstrumentComparator_compare___javax_sound_midi_Instrument_javax_sound_midi_Instrument; // Initialize vtable for implementing interfaces __TIB_com_sun_media_sound_ModelInstrumentComparator.numImplementedInterfaces = 1; __TIB_com_sun_media_sound_ModelInstrumentComparator.implementedInterfaces = (__TIB_DEFINITION_TEMPLATE* (*)[1]) XMLVM_MALLOC(sizeof(__TIB_DEFINITION_TEMPLATE*) * 1); __INIT_IMPL_FOR_CLASS_java_util_Comparator(&__TIB_com_sun_media_sound_ModelInstrumentComparator.implementedInterfaces[0][0]); __TIB_com_sun_media_sound_ModelInstrumentComparator.implementedInterfaces[0][0]->vtable[11] = __TIB_com_sun_media_sound_ModelInstrumentComparator.vtable[12]; __TIB_com_sun_media_sound_ModelInstrumentComparator.implementedInterfaces[0][0]->vtable[1] = __TIB_com_sun_media_sound_ModelInstrumentComparator.vtable[1]; __TIB_com_sun_media_sound_ModelInstrumentComparator.declaredFields = &__field_reflection_data[0]; __TIB_com_sun_media_sound_ModelInstrumentComparator.numDeclaredFields = sizeof(__field_reflection_data) / sizeof(XMLVM_FIELD_REFLECTION_DATA); __TIB_com_sun_media_sound_ModelInstrumentComparator.constructorDispatcherFunc = constructor_dispatcher; __TIB_com_sun_media_sound_ModelInstrumentComparator.declaredConstructors = &__constructor_reflection_data[0]; __TIB_com_sun_media_sound_ModelInstrumentComparator.numDeclaredConstructors = sizeof(__constructor_reflection_data) / sizeof(XMLVM_CONSTRUCTOR_REFLECTION_DATA); __TIB_com_sun_media_sound_ModelInstrumentComparator.methodDispatcherFunc = method_dispatcher; __TIB_com_sun_media_sound_ModelInstrumentComparator.declaredMethods = &__method_reflection_data[0]; __TIB_com_sun_media_sound_ModelInstrumentComparator.numDeclaredMethods = sizeof(__method_reflection_data) / sizeof(XMLVM_METHOD_REFLECTION_DATA); __CLASS_com_sun_media_sound_ModelInstrumentComparator = XMLVM_CREATE_CLASS_OBJECT(&__TIB_com_sun_media_sound_ModelInstrumentComparator); __TIB_com_sun_media_sound_ModelInstrumentComparator.clazz = __CLASS_com_sun_media_sound_ModelInstrumentComparator; __CLASS_com_sun_media_sound_ModelInstrumentComparator_ARRAYTYPE = XMLVM_CREATE_ARRAY_CLASS_OBJECT(__CLASS_com_sun_media_sound_ModelInstrumentComparator, 1); __TIB_com_sun_media_sound_ModelInstrumentComparator.classInitialized = 1; } } I don't have enough knowledge of the c backend, so I can't find the place where to correct this in the source myself... (And yes, you see correctly, that I'm trying to do MIDI in there :D) Regards, Markus |