Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Overriding method out of Library does not work

GamersBot.java : https://pastebin.com/7HbGrzCd
Cefh.java : https://pastebin.com/MZeVDqkx
Screenshot: http://prnt.sc/ewm2dn

The output generated:
Code
xjoeyv.cefh.MessageTransporterEvent@4208289f
xjoeyv.cefh.MessageTransporterEvent@5e8d667f
Is a part of the 'library' and comes from the function:
Code
public void onMessageTransport(MessageTransporterEvent event) {
    System.out.println(event);
}
And my function on the left side does not override it, why not? The function in the Cefh.java file will get called as you can see.
[Image: n4b6KUJ.png]
You need to call GamersBot.onMessageTransport if you want to use the overridden function.
Where's the rest of the code ? How do you know that onMessageTransport() is not being overridden in GamersBot class, you used "@override" annotation so you imply to the compiler that you actually want to override a method in the code that follows, and if it doesn't give you an error than it means it actually is being overridden, the mistake may be in the part of code where you call these methods.
[Image: 4f2d8e8a917f4be2a829a0405325e880.png]
(Apr 14, 2017 06:08 PM)Weco Wrote:  You need to call xjoeyv.gamersbot.Cefh.onMessageTransport if you want to use the overridden function.

You mean what happends here?
Code
package xjoeyv.cefh;

import org.cef.browser.CefBrowser;
import org.cef.callback.CefQueryCallback;
import org.cef.handler.CefMessageRouterHandlerAdapter;

public class MessageTransporter extends CefMessageRouterHandlerAdapter {
    
    @Override
    public boolean onQuery(CefBrowser browser,
            long query_id,
            String request,
            boolean persistent,
            CefQueryCallback callback) {    
        Cefh.getInstance().onMessageTransport(new MessageTransporterEvent(callback, request));
        return false;
    }
}

(Apr 14, 2017 06:47 PM)SIM-429621 Wrote:  Where's the rest of the code ? How do you know that onMessageTransport() is not being overridden in GamersBot class, you used "@override" annotation so you imply to the compiler that you actually want to override a method in the code that follows, and if it doesn't give you an error than it means it actually is being overridden, the mistake may be in the part of code where you call these methods.

See above ^^
"How do you know that onMessageTransport() is not being overridden in GamersBot class" and how do you mean that? GamersBot class should override it right? Or that is what I want
[Image: n4b6KUJ.png]
(Apr 15, 2017 02:05 AM)Zippy™ Wrote:  You mean what happends here?
Code
package xjoeyv.cefh;

import org.cef.browser.CefBrowser;
import org.cef.callback.CefQueryCallback;
import org.cef.handler.CefMessageRouterHandlerAdapter;

public class MessageTransporter extends CefMessageRouterHandlerAdapter {
    
    @Override
    public boolean onQuery(CefBrowser browser,
            long query_id,
            String request,
            boolean persistent,
            CefQueryCallback callback) {    
        Cefh.getInstance().onMessageTransport(new MessageTransporterEvent(callback, request));
        return false;
    }
}

public boolean onQuery gets Overriden, so whenever MessageTransporter.onQuery is called, the overriden function will be used instead of the original.
(Apr 15, 2017 06:28 AM)Weco Wrote:  public boolean onQuery gets Overriden, so whenever MessageTransporter.onQuery is called, the overriden function will be sued instead of the original.

So how can I resolve this issue? What should be the best way to go? Cause I do want the function to be overriden in the Cefh class.
[Image: n4b6KUJ.png]
(Apr 15, 2017 07:02 AM)Zippy™ Wrote:  So how can I resolve this issue? What should be the best way to go? Cause I do want the function to be overriden in the Cefh class.

You simply call GamersBot.onMessageTransport instead of Cefh.onMessageTransport :)
You can read more here: http://docs.oracle.com/javase/tutorial/j...rride.html
(Apr 15, 2017 08:35 AM)Weco Wrote:  You simply call GamersBot.onMessageTransport instead of Cefh.onMessageTransport :)
You can read more here: http://docs.oracle.com/javase/tutorial/j...rride.html

Yea but I said the Cefh is a library so people can use it them selfs, this can end up that someone else its class is CefBrowser that wants to override the onMessageTransport.
[Image: n4b6KUJ.png]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by phisnNov 11, 2020 08:44 AM 1 166 Nov 11, 2020 08:44 AM
Last Post: HFDone
[C] by Sir BillyAug 26, 2019 06:33 PM 1 149 Aug 26, 2019 06:33 PM
Last Post: YouthInAsia
[C] by FinnTheHumanJul 9, 2017 09:31 PM 1 181 Jul 9, 2017 09:31 PM
Last Post: Rageline