Interface methods aren't compiled
Monkey Forums/Monkey Bug Reports/Interface methods aren't compiled
| ||
Hi, I'm experiencing this kind of error with increased frequency. When compiling, Monkey doesn't compile actually needed methods, which either generate runtime errors (in the case of JavaScript for example), or get caught by other compilers, like the Java one. I'm using Monkey Pro v84e. Following the code I'm using: util/publisher.monkey import engine.core.idisposable import ipublisher import isubscriber class Publisher implements IPublisher, IDisposable method New() subscribers = new StringMap<List<ISubscriber>> subscribers.Add("*", new List<ISubscriber>) Subscribe(null, "") end method Publish:void(event:string, data:Object) for local s:= eachin subscribers.Get("*") s.OnEventPublished(event, data) next if not subscribers.Contains(event) then return for local s:= eachin subscribers.Get(event) if subscribers.Get("*").Contains(s) then continue s.OnEventPublished(event, data) next end method Subscribe:void(subscriber:ISubscriber, event:string) if not subscribers.Contains(event) then subscribers.Add(event, new List<ISubscriber>) if subscribers.Get(event).Contains(subscriber) then return subscribers.Get(event).AddLast(subscriber) end method Unsubscribe:void(subscriber:ISubscriber, event:string) if not subscribers.Contains(event) then return subscribers.Get(event).RemoveEach(subscriber) end method Dispose:void() for local eventSubscribers:= eachin subscribers.Values() eventSubscribers.Clear() next subscribers.Clear() end private field subscribers:StringMap<List<ISubscriber>> end util/ipublisher.monkey import isubscriber interface IPublisher method Publish:void(event:string, data:Object) method Subscribe:void(subscriber:ISubscriber, event:string) method Unsubscribe:void(subscriber:ISubscriber, event:string) end This is the translated Java code: interface c_IPublisher{ public void p_Subscribe(c_ISubscriber t_subscriber,String t_event); public void p_Publish(String t_event,Object t_data); } interface c_IDisposable{ public void p_Dispose(); } class c_Publisher extends Object implements c_IPublisher,c_IDisposable{ c_StringMap m_subscribers=null; public final c_Publisher m_Publisher_new(){ m_subscribers=(new c_StringMap()).m_StringMap_new(); m_subscribers.p_Add("*",(new c_List7()).m_List_new()); return this; } public final void p_Publish(String t_event,Object t_data){ c_Enumerator7 t_=m_subscribers.p_Get("*").p_ObjectEnumerator(); while(t_.p_HasNext()){ c_ISubscriber t_s=t_.p_NextObject(); t_s.p_OnEventPublished(t_event,t_data); } if(!m_subscribers.p_Contains3(t_event)){ return; } c_Enumerator7 t_2=m_subscribers.p_Get(t_event).p_ObjectEnumerator(); while(t_2.p_HasNext()){ c_ISubscriber t_s2=t_2.p_NextObject(); if(m_subscribers.p_Get("*").p_Contains7(t_s2)){ continue; } t_s2.p_OnEventPublished(t_event,t_data); } } } The IPublisher.Subscribe and IDisposable.Dispose methods are not compiled and Java complains error: c_Publisher is not abstract and does not override abstract method p_Subscribe(c_ISubscriber,String) in c_IPublisher [javac] class c_Publisher extends Object implements c_IPublisher,c_IDisposable{ [javac] ^ I can sometimes circumvent these errors by forcing the calling of those methods, like class Publisher implements IPublisher, IDisposable method New() subscribers = new StringMap<List<ISubscriber>> subscribers.Add("*", new List<ISubscriber>) Subscribe(null, "") ' <---- really bad hack end ... But it's not always that simple obviously. I can also force the methods to compile by including the class in the reflection filter, but it's something I'd rather avoid. |
| ||
Can you post a build/runnable example? |
| ||
Nope, the error appears only when all the game code is being compiled, not when only that class is being used in a test code :/ I will try to narrow it down though. |