JDK-6623981 : javac StackOverFlowError in 1.4.1/1.4.2
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.4.2_20
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2003
  • CPU: x86
  • Submitted: 2007-10-31
  • Updated: 2010-12-03
  • Resolved: 2008-10-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other Other
1.4.2_18-rev b12Fixed 1.4.2_19Fixed 5.0u17Fixed
Description
One licensee reported this issue on their customer's application.

JDK: 1.4.1_03, 1.4.2_xx
OS:  Windows Server 2003

Below is collected stack trace.
----->
java.lang.StackOverflowError
	at com.sun.tools.javac.v8.comp.Resolve.resolveIdent(Resolve.java:798)
	at com.sun.tools.javac.v8.comp.Attr.visitIdent(Attr.java:1033)
	at com.sun.tools.javac.v8.tree.Tree$Ident.accept(Tree.java:1111)
	at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:256)
	at com.sun.tools.javac.v8.comp.Attr.attribArgs(Attr.java:320)
	at com.sun.tools.javac.v8.comp.Attr.visitApply(Attr.java:756)
	at com.sun.tools.javac.v8.tree.Tree$Apply.accept(Tree.java:877)
         ....
<-----

The javac compiling environment is as follows:

the total number of Java source program(put in the dir at each package): 411
the number of the referred jar(set at -classpath): 17

set cp=<jar files>
javac -classpath %cp% -d d:\biscomp\bin -sourcepath d:\biscomp\src d:\biscomp\src\....\*.java

Put the above command in each package.

The licensee tried the option "-J-Xss10m" but it did not work. After
their investigation they found the following conclusion.

1.The cause of StackOverFlowError

When compiling a source(javac ... *.java), the classes depending on
the compiled source become translation objects if not existing on
classpath. There is a max limit of source/class number set to be 502
when analyzing a source code. Analytical information that javac holds
internally grows to translate a huge amount of source program at a
time and that results in a stack overflow.

2.Why the option "-J-Xss10m" did not work

The thread where stack overflow occurred was generated by OS when
starting javac.exe. Its size was fixed to be 256KB on Windows so
"-J-Xss10m" did not work. This option is valid only for the threads
generated by Java VM.

To solve the problem, one way is not to make a recursive call in the
processing of javac. 

This problem was not seen in jdk 5.0.
Test case and instruction for reproduction has been added.
Please see Comment section.

Comments
EVALUATION Fixing by starting the javac "work" in a new thread, to avoid any possible limitation of the primordial thread stack size by the OS. This applies to 5.0 and earlier, later JDKs have the launcher start the application in a new thread.
25-08-2008