开发者

stack overflow error?

开发者 https://www.devze.com 2023-03-10 21:56 出处:网络
I was working on an accounts application. when I tried to run the invoice form something called stack overflow exception occurred...tell me what to do about it.. everything was fine I suppose before I

I was working on an accounts application. when I tried to run the invoice form something called stack overflow exception occurred...tell me what to do about it.. everything was fine I suppose before I declared an invoice object in Stock class. this was output...

run:
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
    at sun.awt.Win32GraphicsConfig.getBounds(Native Method)
    at sun.awt.Win32GraphicsConfig.getBounds(Win32GraphicsConfig.java:215)
    at java.awt.Window.init(Window.java:394)
    at java.awt.Window.<init>(Window.java:433)
    at java.awt.Frame.<init>(Frame.java:403)
    at java.awt.Frame.<init>(Frame.java:368)
    at javax.swing.JFrame.<init>(JFrame.java:158)
    at Invoice.<init>(Invoice.java:10)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at 开发者_高级运维Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)

    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
    at Stock.<init>(Stock.java:670)
    at Invoice.<init>(Invoice.java:1135)
BUILD SUCCESSFUL (total time: 5 seconds)


In the Invoice constructor, you're creating a new Stock object (in line 1135).

In the Stock constructor, you're creating a new Invoice object (in line 670).

In the Invoice constructor, you're creating a new Stock object (in line 1135).

and so on and on, until you reach the maximum stack depth. You need to figure out which one of Invoice and Stock should automatically create new instances of the other, or create the objects and then assign them to each other.


Well.. We need to see some code before we can answer you, but stackoverflow exceptions usually happens when you have some code calling itself without ever ending (Recursion, without progress). So you should look at your code, and find out under what conditions it should terminate the loop, and why it doesnt do that yet :)

0

精彩评论

暂无评论...
验证码 换一张
取 消