B4J Question From Java line to B4J line

HARRY

Active Member
Licensed User
Longtime User
Hi,

In a B4J program from time to time an error occurs with the following data in the log file.
B4X:
main._appstart (java line: 144)
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: String index out of range: -47
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:489)
    at anywheresoftware.b4a.keywords.Common.access$0(Common.java:460)
    at anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Common.java:534)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:146)
    at b4j.example.main._appstart(main.java:144)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
    at b4j.example.main.main(main.java:29)
Caused by: java.lang.RuntimeException: java.lang.StringIndexOutOfBoundsException: String index out of range: -47
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:119)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:480)
    ... 13 more
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -47
    at java.lang.String.substring(String.java:1967)
    at b4j.example.main._stream1_newtext(main.java:1708)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
    ... 14 more
As string manipulations occur on various places in the program, I wonder whether it is possible to derive from the error message above the line number in the B4J source. This would be helpfull to find the code which causes the error.

Any possibility?
Harry
 

DonManfred

Expert
Licensed User
Longtime User
to derive from the error message above the line number in the B4J source
Check the generated java source in the Objects folder.

Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -47
at java.lang.String.substring(String.java:1967)
at b4j.example.main._stream1_newtext(main.java:1708)

check the main.java file at line 1708. This point you to a line in the Sub stream1_newtext in your Mainactivity.
 
Upvote 0
Top