RFR: StringIndexOutOfBoundsException from /.*((a[^a]+){2})c$/.exec('ababc')

Hannes Wallnöfer hannes.wallnoefer at oracle.com
Fri Aug 18 08:48:15 UTC 2017


+1

I can provide some background information for this patch, whithout which it is probably hard to understand. 

The Joni matcher has different implementations of the stack pop operations that just discard stack entries or reset group boundaries and/or repeat counts, depending on the regular expression being executed. Because of the delayed compilation introduced in JDK-8011884 (Regexp literals are compiled twice) Joni was using the wrong implementation of stack pop in this case, causing the repeat count to be too high. 

Now since we actually added a LRU cache for compiled regular expressions in JDK-8066407 (Function with same body not reparsed after SyntaxError) the safest way to fix this is to revert back to the original regex instantiation/compilation order, which is what this patch does.

Hannes


> Am 18.08.2017 um 07:36 schrieb Priya Lakshmi Muthuswamy <priya.lakshmi.muthuswamy at oracle.com>:
> 
> Hi,
> 
> Please review JDK-8175362 : StringIndexOutOfBoundsException from /.*((a[^a]+){2})c$/.exec('ababc')
> JBS : https://bugs.openjdk.java.net/browse/JDK-8175362
> webrev : http://cr.openjdk.java.net/~pmuthuswamy/8175362/webrev.00/
> 
> Thanks,
> Priya



More information about the nashorn-dev mailing list