posts - 5,  comments - 0,  trackbacks - 0

 来到新公司 ,一切都还算习惯.好久没怎么写代码. 这几天没什么任务,做个工具方便打补丁包. 和同事沟通了哈.简单的说就是想做个自动编译java,并且打包的工具.以前用过点ant,于是就用它了.大概写了哈脚本.

环境如下: ant1.7

             jdk 1.42

不过很不兴 编译大概3000多个文件.过程中出现了2个问题:

1 out of memory 解决方式:在build.xml中<javac>指定memoryMaximumSize="1024m".问题解决.

2 stackoverflow 开始感觉的是在eclipse 中 指定-Xss=100m.这个是指定堆栈的大小,不过问题还是存在.

异常如下:

    [javac] Compiling 2230 source files to D:\60work\xyg60\test
    [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.v8.comp.Attr.visitApply(Attr.java:689)
    [javac]     at com.sun.tools.javac.v8.tree.Tree$Apply.accept(Tree.java:877)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:198)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.visitSelect(Attr.java:1071)
    [javac]     at com.sun.tools.javac.v8.tree.Tree$Select.accept(Tree.java:1091)
    [javac]     at com.sun.tools.javac.v8.comp.Attr.attribTree(Attr.java:198)

   ....................................................................................................

上网查了哈.发现是sun的一个bug:http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6623981

简单描述如下:

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.
Posted Date : 2007-10-31 03:57:57.0

Test case and instruction for reproduction has been added.
Please see Comment section.
Posted Date : 2007-11-27 10:13:04.0
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.
Posted Date : 2008-08-25 19:28:25.0
可恨的sun 竟然搞到1.5的update17才解决.
下了个最新的jdk1.5update20 问题解决了.
由于我打包的东东是要在jdk1.4中运行的.还要想把办法把1.5的class 转换成1.4的.....
或者可以自己修改1.4的jdk.按照他的Evaluation ,来改jdk 这个放到有时间在搞.





posted on 2009-08-14 15:09 suker 阅读(316) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 
<2009年8月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345

常用链接

留言簿

随笔档案

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜