I am using the deprecated JavascriptContext class to create a logger Inside 
a BrowserComponent like this:

JavascriptContext ctx = new JavascriptContext(internalBrowser);
                  JSObject logger = (JSObject)ctx.get("{}");
                  logger.set("log", new JSFunction() {
                   public void apply(JSObject self, Object[] args) {
                    String msg = (String)args[0];
                    Log.p("[Javascript Logger] "+msg);
                   }
                  });
                  ctx.set("window.logger", logger);

this used to work fine (the same code from worked fine a month ago), but 
suddently, it stopped working (and crash my app) on android where it 
returns the error:

W/System.err: java.lang.NullPointerException: Attempt to invoke virtual 
method 'void com.codename1.javascript.JSObject.set(java.lang.String, 
java.lang.Object)' on a null object reference
        at 
org.tbdlab.myapp.socketio.SocketIO$1.actionPerformed(SocketIO.java:75)
        at com.codename1.ui.util.EventDispatcher.fireActionSync(Unknown 
Source)
        at com.codename1.ui.util.EventDispatcher.access$100(Unknown Source)
        at com.codename1.ui.util.EventDispatcher$CallbackClass.run(Unknown 
Source)
        at com.codename1.ui.Display.processSerialCalls(Unknown Source)
        at com.codename1.ui.Display.edtLoopImpl(Unknown Source)
        at com.codename1.ui.Display.mainEDTLoop(Unknown Source)
        at com.codename1.ui.RunnableWrapper.run(Unknown Source)
        at com.codename1.impl.CodenameOneThread$1.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:818)

meaning that the JSObject logger is null. On the simulator it is still 
working though.
Any idea of what change in CN1 may have caused this issue ? And what is the 
recommanded solution to create a logger in a BrowserComponent (to log js 
issues) now (without the deprecated JavascriptContext and JSObject classes?)


-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/c109ea29-9570-4ae1-ab1a-eb78f4299028%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to