ClojureScript

s/conform internal JS compile failure Nashorn Java 9

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    macOS 10.13.3

    java version "9.0.4"
    Java(TM) SE Runtime Environment (build 9.0.4+11)
    Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

Description

(This is reflected in cljs.spec-test/test-roundtrip failing in Nashorn under Java 9.)

Node, when running these tests, in addition to cleaning up .cljs_nashorn_repl/ it is important to clean up nashorn_code_cache/ in order to ensure reproducibility.

Java 8:

$ script/nashornrepljs
To quit, type: :cljs/quit
cljs.user=> (require '[cljs.spec.alpha :as s])

cljs.user=> (s/def ::even? (s/and number? even?))
:cljs.user/even?
cljs.user=> (s/def ::odd? (s/and number? odd?))
:cljs.user/odd?
cljs.user=> (def s2
  (s/cat :forty-two #{42}
    :odds (s/+ ::odd?)
    :m (s/keys :req-un [::a ::b ::c])
    :oes (s/& (s/* (s/cat :o ::odd? :e ::even?)) #(< (count %) 3))
    :ex (s/* (s/alt :odd ::odd? :even ::even?))))
#'cljs.user/s2
cljs.user=> (s/conform s2 [42 11 13 15 {:a 1 :b 2 :c 3} 1 2 3 42 43 44 11])
{:forty-two 42, :odds [11 13 15], :m {:a 1, :b 2, :c 3}, :oes [{:o 1, :e 2} {:o 3, :e 42}], :ex [[:odd 43] [:even 44] [:odd 11]]}

Under Java 9, the first s/conform fails, but the second succeeds.

$ script/nashornrepljs
To quit, type: :cljs/quit
cljs.user=> (require '[cljs.spec.alpha :as s])

cljs.user=> (s/def ::even? (s/and number? even?))
:cljs.user/even?
cljs.user=> (s/def ::odd? (s/and number? odd?))
:cljs.user/odd?
cljs.user=> (def s2
  (s/cat :forty-two #{42}
    :odds (s/+ ::odd?)
    :m (s/keys :req-un [::a ::b ::c])
    :oes (s/& (s/* (s/cat :o ::odd? :e ::even?)) #(< (count %) 3))
    :ex (s/* (s/alt :odd ::odd? :even ::even?))))
#'cljs.user/s2
cljs.user=> (s/conform s2 [42 11 13 15 {:a 1 :b 2 :c 3} 1 2 3 42 43 44 11])
Argument is not an array
	 cljs$spec$alpha$deriv (.cljs_nashorn_repl/cljs/spec/alpha.cljs:0:0)
	 cljs$spec$alpha$re_conform (.cljs_nashorn_repl/cljs/spec/alpha.cljs:1211:5)
	 cljs$spec$alpha$Spec$conform_STAR_$arity$2 (.cljs_nashorn_repl/cljs/spec/alpha.cljs:1252:9)
	 cljs$spec$alpha$conform_STAR_ (.cljs_nashorn_repl/cljs/spec/alpha.cljs:39:1)
	 cljs$spec$alpha$conform (.cljs_nashorn_repl/cljs/spec/alpha.cljs:153:3)
	 (NO_SOURCE_FILE <eval>:1:0)
	 (NO_SOURCE_FILE <eval>:1:0)
	 (NO_SOURCE_FILE <eval>:1:0)
cljs.user=> (s/conform s2 [42 11 13 15 {:a 1 :b 2 :c 3} 1 2 3 42 43 44 11])
{:forty-two 42, :odds [11 13 15], :m {:a 1, :b 2, :c 3}, :oes [{:o 1, :e 2} {:o 3, :e 42}], :ex [[:odd 43] [:even 44] [:odd 11]]}

Printing *e which is actually a Java exception seems to indicate that it is an internal error:

cljs.user=> (.printStackTrace *e)
java.lang.IllegalArgumentException: Argument is not an array
	at java.base/java.lang.reflect.Array.getLength(Native Method)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.RewriteException.toObjectArray(RewriteException.java:247)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$2983$194058AA$alpha$cu1$restOf.cljs$spec$alpha$deriv(.cljs_nashorn_repl/goog/../cljs/spec/alpha.js:0)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$2952$217830AA$alpha$cu1$restOf.cljs$spec$alpha$re_conform(.cljs_nashorn_repl/goog/../cljs/spec/alpha.js:4600)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$2760$223940AA$alpha$cu1$restOf.cljs$spec$alpha$regex_spec_impl#cljs$spec$alpha$Spec$conform_STAR_$arity$2(.cljs_nashorn_repl/goog/../cljs/spec/alpha.js:4729)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$2756$1102AA$alpha$cu1$restOf.cljs$spec$alpha$conform_STAR_(.cljs_nashorn_repl/goog/../cljs/spec/alpha.js:36)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$2754$15797AA$alpha$cu1$restOf.cljs$spec$alpha$conform(.cljs_nashorn_repl/goog/../cljs/spec/alpha.js:455)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$2724$42$\^eval\_$cu1$restOf.L:1#L:1(<eval>:1)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$2723$1$\^eval\_.L:1(<eval>:1)
	at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$2722$\^eval\_.:program(<eval>:1)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:652)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)
	at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:517)
	at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:448)
	at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:405)
	at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:401)
	at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:154)
	at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	at cljs.repl.nashorn$eval_str.invokeStatic(nashorn.clj:46)
	at cljs.repl.nashorn$eval_str.invoke(nashorn.clj:45)
	at cljs.repl.nashorn.NashornEnv._evaluate(nashorn.clj:134)
	at cljs.repl$evaluate_form.invokeStatic(repl.cljc:538)
	at cljs.repl$evaluate_form.invoke(repl.cljc:472)
	at cljs.repl$eval_cljs.invokeStatic(repl.cljc:645)
	at cljs.repl$eval_cljs.invoke(repl.cljc:638)
	at cljs.repl$repl_STAR_$read_eval_print__8396.invoke(repl.cljc:918)
	at cljs.repl$repl_STAR_$fn__8404$fn__8413.invoke(repl.cljc:965)
	at cljs.repl$repl_STAR_$fn__8404.invoke(repl.cljc:964)
	at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1285)
	at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1274)
	at cljs.repl$repl_STAR_.invokeStatic(repl.cljc:927)
	at cljs.repl$repl_STAR_.invoke(repl.cljc:798)
	at cljs.repl$repl.invokeStatic(repl.cljc:1046)
	at cljs.repl$repl.doInvoke(repl.cljc:976)
	at clojure.lang.RestFn.invoke(RestFn.java:410)
	at user$eval9072.invokeStatic(NO_SOURCE_FILE:3)
	at user$eval9072.invoke(NO_SOURCE_FILE:3)
	at clojure.lang.Compiler.eval(Compiler.java:7062)
	at clojure.lang.Compiler.eval(Compiler.java:7025)
	at clojure.core$eval.invokeStatic(core.clj:3206)
	at clojure.main$eval_opt.invokeStatic(main.clj:291)
	at clojure.main$eval_opt.invoke(main.clj:285)
	at clojure.main$initialize.invokeStatic(main.clj:311)
	at clojure.main$null_opt.invokeStatic(main.clj:345)
	at clojure.main$null_opt.invoke(main.clj:342)
	at clojure.main$main.invokeStatic(main.clj:424)
	at clojure.main$main.doInvoke(main.clj:387)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.lang.Var.applyTo(Var.java:702)
	at clojure.main.main(main.java:37)

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: