To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.javaOpen lugnet.robotics.rcx.java in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / Java / 176
175  |  177
Subject: 
Re: What is exception "StackOverflowError" in method "<clinit>"
Newsgroups: 
lugnet.robotics.rcx.java
Date: 
Wed, 22 May 2002 19:49:25 GMT
Viewed: 
3847 times
  
In lugnet.robotics.rcx.java, Roger Glassey writes:
In lugnet.robotics.rcx.java, Juergen Stuber writes:
I suppose TextLCD.print should work, though I never used it,
so probably it is really a stack overflow.
Is the call deeply nested?

Jürgen
I have tried TextLCD.print() and it really does work.
Roger

Yes, you are both right (Thanks anyway)
1. TextLCD.print() works perfectly when called from simple programs
2. My code is most probably using too deep calls (Why is this not covered in
the 10/10 'Core' book of Bagnall)

BUT, QUESTION FOR YOU ALL:

From the following sample code,
how can you explain that the failing instruction
      TextLCD.print(title) in menuChoice2()
suddently works if you call another method of the same class before ?
Is there some caching or inline code triggered in some way ?

While you debug my code (hey, LEGO is a game no ?), I am searching why
another big program starts one of my motors very very slowly without me
asking for it, I guess I am now facing a memory corruption or something like
that.

/*
Compile with
>emu-lejos -o BumpyRadarEMU.bin BumpyRadar
Run in emulator with
>emu-lejosrun -v BumpyRadarEMU.bin
*/
import josx.platform.rcx.*;
import josx.robotics.*;

class BumpyRadar {
public static void main(String args[]) {
new BumpyRadar().init();
}

public void init() {
getMenuValues();
}

public void getMenuValues() {
// Calling menuChoice2 works
// Menu.menuChoice2("X");

// Calling menuChoice2 does not work bcos much depth in calls
// But, amazingly enough,
// it works if you first call menuChoice2() !!!!
Menu.menuChoice1();

}

}

class Menu {
public static void menuChoice1() {
menuChoice2("Y");
}

public static void menuChoice2(String title) {
LCD.showNumber(1);

TextLCD.print(title);

LCD.showNumber(2);
}
}



Message has 1 Reply:
  Re: What is exception "StackOverflowError" in method "<clinit>"
 
(...) The first time a method is called the class gets initialized, and the stack overflow happened in the initialization method <clinit>, so nothing mysterious there. (...) If your program uses a lot of memory (less than 3K free) this is a side (...) (22 years ago, 23-May-02, to lugnet.robotics.rcx.java)

Message is in Reply To:
  Re: What is exception "StackOverflowError" in method "<clinit>"
 
(...) I have tried TextLCD.print() and it really does work. Roger (22 years ago, 17-May-02, to lugnet.robotics.rcx.java)

5 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR