Jump to content




Java Error in my Lua Program!?

java lua networking

3 replies to this topic

#1 jaffacakesareamazing

  • Members
  • 17 posts

Posted 07 June 2014 - 11:25 AM

I have modified the chat program slightly to act as a real life system that is like iMessage. (I DO NOT PLAN ON DISTRIBUTING THE CODE AS THIS IS COPYRIGHT BREAKING) I have added a signal bar at the top like any phone and also a wifi bar for when near wifi networks (the user needs to connect to them first in a different program) and it seems to work fine until a Java error appears, breaking/stopping the program!

I have downloaded a big city map to run this whole 'internet' system in and the error seems to be happening when the chat program is 'supposedly' out of range of a transmitter/computer (i have the main chat server in the center and repeaters going around nearly the whole map) and the signal bar updates automatically as you move around. If you are out of range of a repeater/transmitter the program will not allow you to send/receive any messages.

However a Java error appears randomly I think, it displays this:

window: 277: vm error: java.lang.ArrayIndexOutOfBoundsException

and then it just disconnects. When I then try and connect again, it just constantly searches for a transmitter(computer) to connect to (even if you go and stand right next to one!) Can anyone help with this error? Thanks :)

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 07 June 2014 - 11:32 AM

If you had of read the Read This Before Asking Questions sticky thread you'd have noticed that this error is covered in the 'Common Errors' section.

Basically it is caused by a stack overflow due to use of recursion.

#3 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 07 June 2014 - 11:34 AM

We can't help you with your code if we cannot see it.

EDIT: just had a read through window API's code. This kind of error could have happened because of some kind of window-parent function recursion:

window1 has a child window2. window2 has a child window3. window1's parent is window3. window1 calls isColor which is invoked on window3 which calls isColor on it's parent - window2, and then window2 calls isColor on window1, because it is his parent. Recursion begins. Although, I don't really understand how could that happen...

The line on which the error occurs is as follows:

updateCursorColor()

And the source of updateCursorColor is:

local function updateCursorColor()
  parent.setTextColor( nTextColor )
end

Edited by MKlegoman357, 07 June 2014 - 11:47 AM.


#4 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 08 June 2014 - 02:07 AM

View PostMKlegoman357, on 07 June 2014 - 11:34 AM, said:

Although, I don't really understand how could that happen...

It can't. A window must always be defined as having a parent which already exists, and it can't be switched to a different parent afterwards.

Odds are RandomGuyDom has built infinite recursion into his own code, and as that code likely makes additional calls to other functions (eg the ones in the window API, among others), it'd be quite unpredictable as to which call would finally blow the stack.

Edit: Kinda worth pointing out that under CC 1.6+, all advanced systems automatically fire up multishell on boot, which uses the window API to render pretty much everything - including any scripts you run. Thus any script which overflows the function stack has the potential to do so within the window API, if it involves any rendering to the system's inbuilt display.

Edited by Bomb Bloke, 08 June 2014 - 02:11 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users