5 Replies Latest reply on Jul 30, 2009 10:58 PM by jschellSomeoneStoleMyAlias

    build failed java.lang.StackOverflowError

    843810
      Hi,

      I'm trying to compile (ant) a program using the terminal. However i encounter this problem:

      [javac] The system is out of resources.
      [javac] Consult the following stack trace for details.
      [javac] java.lang.StackOverflowError
      [javac] at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:384)
      [javac] at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:1618)
      [javac] at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1422)
      [javac] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
      [javac] at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:384)
      [javac] at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:1618)
      [javac] at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1422)
      [javac] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
      [javac] at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:384)
      [javac] at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:1618)
      [javac] at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1422)
      [javac] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
      [javac] at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:384)
      [javac] at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:1618)
      [javac] at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1422)
      [javac] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
      [javac] at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:384)
      [javac] at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:1618)
      ...
      ...
      ... (all the same)
      ...
      ...
      [javac] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
      [javac] at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:384)
      [javac] at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:1618)
      [javac] at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1422)
      [javac] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
      [javac] at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:384)
      [javac] at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:1618)
      [javac] at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1422)
      [javac] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
      BUILD FAILED
      file:/home/jogo/mycvs/emk/src/web/build.xml:129: Compile failed; see the compiler error output for details.

      Total time: 23 seconds
      [jogo@localhost emk]$ ant
      Buildfile: build.xml
        • 1. Re: build failed java.lang.StackOverflowError
          brucechapman
          That looks interesting.

          Can you re-run the compiler direct from the command line (ANT is swallowing some information that could be useful for diagnosis).

          Also it would be really useful to know what you are compiling. I know thats hard. But maybe you could identify what recent change you made which caused this error. Maybe you could then look at that change and write a small example class that does the same thing that the change does and see if it causes a problem. A test case would be useful.

          You'd also need to tell us what version of javac you are running.


          Without more information, you're on your own.

          cheers

          Bruce
          • 2. Re: build failed java.lang.StackOverflowError
            843810
            Hi and thx 4 the reply,

            Anyway, i'm using j2sdk1.4.2_16. Actually it's been a long time since i last used ant (it was successful the last time) because i've only modified .jsp files. I know I can 'ant web' but still i think there might be some serious problems. Could someone please help me. Thanks in advance.

            -JoGo-
            • 3. Re: build failed java.lang.StackOverflowError at attribExpr(Attr.java:384)
              843810
              I have just run in to this same problem, when compiling some (generated) code using javac in Ant with "fork=false".

              If I set "fork=true" the problem doesn't occur. However we need to set "fork=false" because we have run in to a problem where the path becomes too long and the compiler fails with no error at all. (Running on Windows XP)

              Same behaviour occurs using javac 1.6.0_12 and javac 1.6.0_14 (not tried any others)
              I also increased the memory available using ANT_OPTS=-Xmx1024M to no avail.

              If I re-generate the source code fresh every time, the subsequent compilation always fails.
              If I don't do that - this problem occurs the first time I try to compile, then (without cleaning or making any other changes)
              on the second attempt it also fails, but on the third attempt the compilation succeeds.
              (but if I do the equivalent as in-line in Ant commands, setting the javac attribute "failonerror=false", it fails all 3 times -
              so it looks like the embedded compiler is leaking resources.)

              There are 294 generated .java source files, if I delete around half of them so there are only 139, the process succeeds.
              The generated classes are very simple DTO POJOs, serializable with a serialVersionUID, public members, and a toString method, no other methods.
              • 4. Re: build failed java.lang.StackOverflowError at attribExpr(Attr.java:384)
                843810
                Turns out that there is a bug in the compiler with concatenating many nested strings.
                Some of our generated code was doing a lot of this.
                Changing our code generator to work around the problem has fixed it.

                http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4776875
                Flagged as low priority, WILL NOT FIX by Sun !
                • 5. Re: build failed java.lang.StackOverflowError at attribExpr(Attr.java:384)
                  jschellSomeoneStoleMyAlias
                  edrandall wrote:
                  Turns out that there is a bug in the compiler with concatenating many nested strings.
                  Some of our generated code was doing a lot of this.
                  Changing our code generator to work around the problem has fixed it.

                  http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4776875
                  Flagged as low priority, WILL NOT FIX by Sun !
                  Computers do not have infinite resources. And thus compilers, as noted by that link, do not have them either.

                  It isn't a bug either but an enhancement request - that is how it is categorized.

                  It notes that you can increase the stack for the compiler thus increasing the default limit.

                  And fixing a code generator would always be better because the compiler failure would suggest that something is getting too big anyways.