java - a nashorn engine bug? -
i try execute simple short scripts test nashorn :
basedir="/cassandara2/cassandra" ba="/cassandara2/cassandra/lib/st4-4.0.8.jar"; lib = ""; lib += ' <root url="jar://' + ba.replace(basedir, "$project_dir"); print(lib); it works when add sign $ after "$project_dir" ==> "$project_dir$" , got error:
> java.lang.stringindexoutofboundsexception: string index out of range: > 13 @ java.lang.string.charat(string.java:646) @ > jdk.nashorn.internal.objects.nativeregexp.appendreplacement(nativeregexp.java:738) > @ > jdk.nashorn.internal.objects.nativeregexp.replace(nativeregexp.java:674) > @ > > jdk.nashorn.internal.objects.nativestring.replace(nativestring.java:763) > bla... is bug of jdk 8 nashorn ( used jdk8 u45) code :
public static void main(string[] args) { try { scriptenginemanager factory = new scriptenginemanager(); scriptengine engine = factory.getenginebyname("nashorn"); object eval = engine.eval("load(\"" + "script/demo.js" + "\");"); system.out.println(eval); } catch (exception ex) { ex.printstacktrace(); } }
bug filed. https://bugs.openjdk.java.net/browse/jdk-8081608 $ @ end of replace string causes index out of range error
js> "string".replace("i", "$"); java.lang.stringindexoutofboundsexception: string index out of range: 1 jjs> "string".replace("i", "$ "); str$ ng
Comments
Post a Comment