简体   繁体   English

YUICompressor崩溃 - stackoverflow错误

[英]YUICompressor crashes - stackoverflow error

I frequently get what appears to be a stackoverflow error ;-) from YUICompressor. 我经常从YUICompressor得到似乎是stackoverflow错误的东西;-)。 The following is the first part of thousands of error lines that come from attempting to compress a 24074 byte css stylesheet (not the "Caused by java.lang.StackOverflowError about 8 lines down): 以下是数千条错误行的第一部分,这些错误行来自于尝试压缩24074字节的css样式表(而不是“由java.lang.StackOverflowError引起的约8行):

iMac1:src jas$ min ../style2.min.css style2.css 
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
Caused by: java.lang.StackOverflowError
    at java.lang.Character.codePointAt(Character.java:2335)
    at java.util.regex.Pattern$CharProperty.match(Pattern.java:3344)
    at java.util.regex.Pattern$Branch.match(Pattern.java:4114)

... (plus 1021 more error lines) ...(加上1021条错误行)

The errors happen usually after adding a couple of lines to the file getting compressed. 通常在向压缩文件添加几行之后发生错误。 The css is fine, and works perfectly in the uncompressed format. CSS很好,并且在未压缩格式下完美运行。 I don't see a particular pattern to the types of selectors added to the file that cause the errors. 我没有看到添加到文件中导致错误的选择器类型的特定模式。 In this case, adding the following selector to a previously compressible file resulted in the errors: 在这种情况下,将以下选择器添加到先前可压缩的文件中会导致错误:

#thisisatest
{
    margin-left:87px;
}

I am wondering if there is perhaps a flag to java to enlarge the stack that might help. 我想知道是否有一个标志可以帮助扩大堆栈。 Or if that is not the problem, what is? 或者,如果那不是问题,那是什么?

EDIT: 编辑:

As I was posting this question, it dawned on me that I should check the java command to see if there was a parameter to enlarge the stack. 当我发布这个问题时,我突然意识到我应该检查java命令,看看是否有一个参数来放大堆栈。 Turns out that it is -Xssn, where "n" is a parameter to indicate the stack size. 原来它是-Xssn,其中“n”是表示堆栈大小的参数。 Its default value is 512k. 其默认值为512k。 So I tried 1024k but that still led to the stackoverflow. 所以我尝试了1024k,但仍然导致了stackoverflow。 Trying 2048k works however, and I think this could be the solution. 然而,尝试2048k工作,我认为这可能是解决方案。

EDIT 2: 编辑2:

While I no longer use this method for minification any longer, to be more specific here is the full command (which I have set up as a shell alias), showing how the -Xss2048k parameter is used: 虽然我不再使用此方法进行缩小,但更具体的是完整命令(我已将其设置为shell别名),显示如何使用-Xss2048k参数:

java -Xss2048k -jar ~/Documents/RepHunter/Website\\ Materials/Code/Third\\ Party\\ Libraries/YUI\\ Compressor/yuicompressor-2.4.8.jar --type css -o java -Xss2048k -jar~ / Documents / RepHunter / Website \\ Materials / Code / Third \\ Party \\ Libraries / YUI \\ Compressor / yuicompressor-2.4.8.jar --type css -o

As posted in my edit, the solution was to add the parameters to the java command. 正如我在编辑中发布的那样,解决方案是将参数添加到java命令中。 The clue was the error line at the 5-th "at" line, as follows: 线索是第5行“at”行的错误行,如下所示:

at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
Caused by: java.lang.StackOverflowError

Seeing that the issue was a "StackOverlowError" ;-) gave the suggestion to try to increase the stack size. 看到问题是“StackOverlowError”;-)给出了尝试增加堆栈大小的建议。 The default is 512k. 默认值为512k。 My first try of 1024k did not work. 我的第一次尝试1024k无法正常工作。 However increasing it to 2048k did work, and I have had no further issues. 然而,它增加到2048k确实有效,我没有进一步的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM