I have been trying to get the Compromise.js library working in nashorn, I have tried it on both 8 and 9.0.1 without success. I have tried to workaround the issue by modifying the js file but have not been able to get past the issue, any help or suggested workarounds are appreciated.
The issue is from line 5377 of Compromise.js, which is: ts.match('#Hyphenated #Hyphenated').match('#NumericValue #NumericValue').tag('NumberRange'); This throws: java.lang.ClassCastException: Cannot cast jdk.nashorn.internal.scripts.JD4 to jdk.nashorn.internal.runtime.ScriptFunction In trying to debug in our application I passed the ts variable to a JSObject that I had available in the context, where I was able to set a java breakpoint and see if I could reproduce the ClassCastException by calling the same match().match().tag() functions via the ScriptObjectMirror APIs. I was not able to reproduce the issue this way, there were a few times when I was debugging this way in our application that I was able to get the script to run successfully (it should print "dinosaurs"), I however have not been able to consistently make the script succeed or reproduce that success in the repo I'm sharing. I have a simple reproducing case here https://github.com/jesseschulman/nashorn_compromise where you can see the functions being called without exception from java if you uncomment line 5376 of the js file. In stepping through the code and looking at the variables in the stack when the ClassCastException is thrown, it looks like the ScriptFunction is a param in the guardWithCatch method, but when that calls reinvoke it is passing JD4 (param_2) instead of ScriptFunction (param_1). Thanks! Jesse