String.toLowerCase中的StackOverflowError

时间:2013-04-16 08:22:59

标签: java string htmlunit stack-overflow

它看起来像一个太长的String导致以下异常:

Caused by: java.lang.StackOverflowError
    at java.lang.String.toLowerCase(String.java:2496)
    at com.gargoylesoftware.htmlunit.html.NamedAttrNodeMapImpl.fixName(DomElement.java:489)
    at com.gargoylesoftware.htmlunit.html.NamedAttrNodeMapImpl.get(DomElement.java:602)
    at com.gargoylesoftware.htmlunit.html.DomElement.getAttribute(DomElement.java:215)
    at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.getStyleMap(CSSStyleDeclaration.java:634)
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getStyleMap(ComputedCSSStyleDeclaration.java:243)
    at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.getStyleAttribute(CSSStyleDeclaration.java:472)
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getStyleAttribute(ComputedCSSStyleDeclaration.java:162)
    at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.jsxGet_position(CSSStyleDeclaration.java:4008)
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.jsxGet_position(ComputedCSSStyleDeclaration.java:1304)
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getPositionWithInheritance(ComputedCSSStyleDeclaration.java:1883)
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1737)
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1769)
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1769)
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1769)
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1769)
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1769)

我想ComputedCSSStyleDeclaration中的循环导致了这个问题。

字符串的物理限制是多少? 我可以限制ComputedCSSStyleDeclaration

的环路检测器

2 个答案:

答案 0 :(得分:1)

原因是代码中存在递归调用。请检查。

在更深层次的JVM知识中解释这个问题:java虚拟机规范已经排除了两种Java堆栈异常情况:

  1. 允许Java堆栈自动扩展,它会抛出 如果无法申请足够的内存,则会出现OOM(OutOfMemory)错误。
  2. Java堆栈由堆栈帧和每个java构成     方法推送一个框架,它会抛出StackOverflowError时     当前线程的堆栈深度大于允许的jvm。
  3. 也许可以帮到你:)。

答案 1 :(得分:1)

是否已经有关于此的错误? http://sourceforge.net/p/htmlunit/bugs/1233/