Search code examples
javanashorn

StackOverflowError using Nashorn to analyze pac proxy file


due to standard Java Proxy detection bug i use nashorn to get the proxy for a specific url with a proxy.pac file(Which works in IE and Firefox).

I get a StackoverflowError in this code:

while (retrycounter < 50) {
      try {
           engine.eval(myscript);
           break;
          } catch (StackOverflowError e) {
             retrycounter ++;
          }
}

The weird thing is, when i run this code in debug mode, it works, when i make a breakpoint at engine.eval(myscript); and step over in the debugger.

The pac file is quite big - 900 Lines. I have a lot of shExpMatch(.....) lines in the file.

When i remove Line 400-600, my script works also in non-debug mode. When i remove Line 400-500, it does not work. When i remove Line 500-600 it does not work.

So has the Nashorn Engine Problems with the size of my file?

I don't post more code, cause it works in debug mode and when i shrink the file.

The problem exists, using Java 1.8.0_73. With 1.8.0_77 and 1.8.0_91 it works.

Is there a possibility to run the script in older versions? Maybe through settings to the engine?

best regards


Solution

  • Same code works with newer java versions. 1.8.0_91 (i think 1.8.0_7xx worked too, but not sure).