Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6133] Android: Kroll - Application crashes when a Java exception is thrown

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-01-05T17:03:04.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sRelease 1.8.0.1
ComponentsAndroid
Labelsbranch-v8, module_titanium, qe-testadded
ReporterJosh Roesslein
AssigneeMarshall Culpepper
Created2011-11-08T16:11:42.000+0000
Updated2014-06-19T12:43:16.000+0000

Description

+Expected Behavior+ When JavaScript code calls a Java proxy method and a Java exception gets thrown it should be converted to a JavaScript exception. +Actual Behavior+ The application crashes due to the Java exception not being handled correctly. +Test case+
var buffer = Ti.createBuffer();
buffer.append() // illegal call, missing required arguments.
+Log+ V8: {quote} W/System.err( 335): java.lang.ArrayIndexOutOfBoundsException W/System.err( 335): at ti.modules.titanium.BufferProxy.append(BufferProxy.java:202) W/System.err( 335): at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) W/System.err( 335): at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(Unknown Source) W/System.err( 335): at org.appcelerator.kroll.KrollRuntime.handleMessage(Unknown Source) W/System.err( 335): at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(Unknown Source) W/System.err( 335): at android.os.Handler.dispatchMessage(Handler.java:95) W/System.err( 335): at android.os.Looper.loop(Looper.java:123) W/System.err( 335): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(Unknown Source) W/dalvikvm( 335): JNI WARNING: JNI method called with exception raised W/dalvikvm( 335): in Lorg/appcelerator/kroll/runtime/v8/V8Runtime;.nativeRunModule (Ljava/lang/String;Ljava/lang/String;Lorg/appcelerator/kroll/KrollProxySupport;)V (CallObjectMethodV) W/dalvikvm( 335): Pending exception is: I/dalvikvm( 335): Ljava/lang/ArrayIndexOutOfBoundsException;: I/dalvikvm( 335): (no stack trace data found) I/dalvikvm( 335): "KrollRuntimeThread" prio=5 tid=7 NATIVE I/dalvikvm( 335): | group="main" sCount=0 dsCount=0 s=N obj=0x43e4a328 self=0x11d230 I/dalvikvm( 335): | sysTid=342 nice=0 sched=0/0 cgrp=default handle=2339192 I/dalvikvm( 335): | schedstat=( 1525760156 223823015 90 ) I/dalvikvm( 335): at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) I/dalvikvm( 335): at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule((null):-1) I/dalvikvm( 335): at org.appcelerator.kroll.KrollRuntime.handleMessage((null):-1) I/dalvikvm( 335): at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage((null):-1) I/dalvikvm( 335): at android.os.Handler.dispatchMessage(Handler.java:95) I/dalvikvm( 335): at android.os.Looper.loop(Looper.java:123) I/dalvikvm( 335): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run((null):-1) I/dalvikvm( 335): E/dalvikvm( 335): VM aborting {quote} Rhino: {quote} E/ScriptsModule( 6699): Error while executing Resources/app.js: Wrapped java.lang.ArrayIndexOutOfBoundsException: index=0 length=0 (Resources/app.js#2) E/ScriptsModule( 6699): org.mozilla.javascript.WrappedException: Wrapped java.lang.ArrayIndexOutOfBoundsException: index=0 length=0 (Resources/app.js#2) E/ScriptsModule( 6699): at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1786) E/ScriptsModule( 6699): at ti.modules.titanium.BufferProxyPrototype.append(BufferProxyPrototype.java:123) E/ScriptsModule( 6699): at ti.modules.titanium.BufferProxyPrototype.execIdCall(BufferProxyPrototype.java:594) E/ScriptsModule( 6699): at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129) E/ScriptsModule( 6699): at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701) E/ScriptsModule( 6699): at script(Resources/app.js:2) E/ScriptsModule( 6699): at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) E/ScriptsModule( 6699): at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:178) E/ScriptsModule( 6699): at org.mozilla.javascript.Context.evaluateString(Context.java:1111) E/ScriptsModule( 6699): at org.appcelerator.kroll.runtime.rhino.modules.ScriptsModule.runSource(ScriptsModule.java:63) E/ScriptsModule( 6699): at org.appcelerator.kroll.runtime.rhino.modules.ScriptsModule.access$200(ScriptsModule.java:26) E/ScriptsModule( 6699): at org.appcelerator.kroll.runtime.rhino.modules.ScriptsModule$RunInThisContext.call(ScriptsModule.java:123) E/ScriptsModule( 6699): at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97) E/ScriptsModule( 6699): at org.appcelerator.kroll.runtime.rhino.js.module._c_anonymous_7(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js:134) E/ScriptsModule( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/ScriptsModule( 6699): at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76) E/ScriptsModule( 6699): at org.appcelerator.kroll.runtime.rhino.js.module._c_anonymous_5(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js:80) E/ScriptsModule( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/ScriptsModule( 6699): at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86) E/ScriptsModule( 6699): at org.appcelerator.kroll.runtime.rhino.js.module._c_anonymous_3(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js:48) E/ScriptsModule( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/ScriptsModule( 6699): at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) E/ScriptsModule( 6699): at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) E/ScriptsModule( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/ScriptsModule( 6699): at org.appcelerator.kroll.runtime.rhino.RhinoRuntime.doRunModule(RhinoRuntime.java:61) E/ScriptsModule( 6699): at org.appcelerator.kroll.KrollRuntime.handleMessage(Unknown Source) E/ScriptsModule( 6699): at android.os.Handler.dispatchMessage(Handler.java:95) E/ScriptsModule( 6699): at android.os.Looper.loop(Looper.java:132) E/ScriptsModule( 6699): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(Unknown Source) E/ScriptsModule( 6699): Caused by: java.lang.ArrayIndexOutOfBoundsException: index=0 length=0 E/ScriptsModule( 6699): at ti.modules.titanium.BufferProxy.append(BufferProxy.java:202) E/ScriptsModule( 6699): at ti.modules.titanium.BufferProxyPrototype.append(BufferProxyPrototype.java:116) E/ScriptsModule( 6699): ... 26 more W/dalvikvm( 6699): threadid=8: thread exiting with uncaught exception (group=0x4014d760) D/dalvikvm( 6699): GC_CONCURRENT freed 259K, 5% free 7037K/7367K, paused 2ms+2ms E/TiApplication( 6699): (KrollRuntimeThread) [251,348] Sending event: exception on thread: KrollRuntimeThread msg:org.mozilla.javascript.WrappedException: Wrapped java.lang.ArrayIndexOutOfBoundsException: index=0 length=0 (Resources/app.js#2); Titanium 1.8.0.1,2011/11/08 12:46,31f6a70 E/TiApplication( 6699): org.mozilla.javascript.WrappedException: Wrapped java.lang.ArrayIndexOutOfBoundsException: index=0 length=0 (Resources/app.js#2) E/TiApplication( 6699): at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1786) E/TiApplication( 6699): at ti.modules.titanium.BufferProxyPrototype.append(BufferProxyPrototype.java:123) E/TiApplication( 6699): at ti.modules.titanium.BufferProxyPrototype.execIdCall(BufferProxyPrototype.java:594) E/TiApplication( 6699): at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129) E/TiApplication( 6699): at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701) E/TiApplication( 6699): at script(Resources/app.js:2) E/TiApplication( 6699): at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) E/TiApplication( 6699): at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:178) E/TiApplication( 6699): at org.mozilla.javascript.Context.evaluateString(Context.java:1111) E/TiApplication( 6699): at org.appcelerator.kroll.runtime.rhino.modules.ScriptsModule.runSource(ScriptsModule.java:63) E/TiApplication( 6699): at org.appcelerator.kroll.runtime.rhino.modules.ScriptsModule.access$200(ScriptsModule.java:26) E/TiApplication( 6699): at org.appcelerator.kroll.runtime.rhino.modules.ScriptsModule$RunInThisContext.call(ScriptsModule.java:123) E/TiApplication( 6699): at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97) E/TiApplication( 6699): at org.appcelerator.kroll.runtime.rhino.js.module._c_anonymous_7(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js:134) E/TiApplication( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/TiApplication( 6699): at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76) E/TiApplication( 6699): at org.appcelerator.kroll.runtime.rhino.js.module._c_anonymous_5(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js:80) E/TiApplication( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/TiApplication( 6699): at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86) E/TiApplication( 6699): at org.appcelerator.kroll.runtime.rhino.js.module._c_anonymous_3(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js:48) E/TiApplication( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/TiApplication( 6699): at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) E/TiApplication( 6699): at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) E/TiApplication( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/TiApplication( 6699): at org.appcelerator.kroll.runtime.rhino.RhinoRuntime.doRunModule(RhinoRuntime.java:61) E/TiApplication( 6699): at org.appcelerator.kroll.KrollRuntime.handleMessage(Unknown Source) E/TiApplication( 6699): at android.os.Handler.dispatchMessage(Handler.java:95) E/TiApplication( 6699): at android.os.Looper.loop(Looper.java:132) E/TiApplication( 6699): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(Unknown Source) E/TiApplication( 6699): Caused by: java.lang.ArrayIndexOutOfBoundsException: index=0 length=0 E/TiApplication( 6699): at ti.modules.titanium.BufferProxy.append(BufferProxy.java:202) E/TiApplication( 6699): at ti.modules.titanium.BufferProxyPrototype.append(BufferProxyPrototype.java:116) E/TiApplication( 6699): ... 26 more E/AndroidRuntime( 6699): FATAL EXCEPTION: KrollRuntimeThread E/AndroidRuntime( 6699): org.mozilla.javascript.WrappedException: Wrapped java.lang.ArrayIndexOutOfBoundsException: index=0 length=0 (Resources/app.js#2) E/AndroidRuntime( 6699): at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1786) E/AndroidRuntime( 6699): at ti.modules.titanium.BufferProxyPrototype.append(BufferProxyPrototype.java:123) E/AndroidRuntime( 6699): at ti.modules.titanium.BufferProxyPrototype.execIdCall(BufferProxyPrototype.java:594) E/AndroidRuntime( 6699): at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129) E/AndroidRuntime( 6699): at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701) E/AndroidRuntime( 6699): at script(Resources/app.js:2) E/AndroidRuntime( 6699): at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) E/AndroidRuntime( 6699): at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:178) E/AndroidRuntime( 6699): at org.mozilla.javascript.Context.evaluateString(Context.java:1111) E/AndroidRuntime( 6699): at org.appcelerator.kroll.runtime.rhino.modules.ScriptsModule.runSource(ScriptsModule.java:63) E/AndroidRuntime( 6699): at org.appcelerator.kroll.runtime.rhino.modules.ScriptsModule.access$200(ScriptsModule.java:26) E/AndroidRuntime( 6699): at org.appcelerator.kroll.runtime.rhino.modules.ScriptsModule$RunInThisContext.call(ScriptsModule.java:123) E/AndroidRuntime( 6699): at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97) E/AndroidRuntime( 6699): at org.appcelerator.kroll.runtime.rhino.js.module._c_anonymous_7(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js:134) E/AndroidRuntime( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/AndroidRuntime( 6699): at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76) E/AndroidRuntime( 6699): at org.appcelerator.kroll.runtime.rhino.js.module._c_anonymous_5(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js:80) E/AndroidRuntime( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/AndroidRuntime( 6699): at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86) E/AndroidRuntime( 6699): at org.appcelerator.kroll.runtime.rhino.js.module._c_anonymous_3(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js:48) E/AndroidRuntime( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/AndroidRuntime( 6699): at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) E/AndroidRuntime( 6699): at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) E/AndroidRuntime( 6699): at org.appcelerator.kroll.runtime.rhino.js.module.call(/var/folders/_p/q0xcb_090pv85yyxf3hsx2h40000gn/T/module.js) E/AndroidRuntime( 6699): at org.appcelerator.kroll.runtime.rhino.RhinoRuntime.doRunModule(RhinoRuntime.java:61) E/AndroidRuntime( 6699): at org.appcelerator.kroll.KrollRuntime.handleMessage(Unknown Source) E/AndroidRuntime( 6699): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime( 6699): at android.os.Looper.loop(Looper.java:132) E/AndroidRuntime( 6699): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(Unknown Source) E/AndroidRuntime( 6699): Caused by: java.lang.ArrayIndexOutOfBoundsException: index=0 length=0 E/AndroidRuntime( 6699): at ti.modules.titanium.BufferProxy.append(BufferProxy.java:202) E/AndroidRuntime( 6699): at ti.modules.titanium.BufferProxyPrototype.append(BufferProxyPrototype.java:116) E/AndroidRuntime( 6699): ... 26 more W/ActivityManager( 142): Force finishing activity com.joshr.mobilesandbox/.MobilesandboxActivity {quote}

Comments

  1. Marshall Culpepper 2011-11-20

    This was resolved early on with Allen's exception dialog pull request
  2. Natalie Huynh 2011-12-07

    Tested with 1.8.0.1.v20111207090257 Xoom (3.2.1) - v8 Samsung Tab 10.1 (3.1) - rhino
  3. Dustin Hyde 2012-01-05

    Added label qe-testadded.

JSON Source