mikera / core.matrix

core.matrix : Multi-dimensional array programming API for Clojure
Other
702 stars 113 forks source link

Uninitialized object exists on backward branch 108 in clojurescript #341

Open Folcon opened 5 years ago

Folcon commented 5 years ago

Reviewing #81, I get the impression clojurescript should work without issue?

However I get this exception when requiring the library:

cljs.user=>  (require '[clojure.core.matrix.dataset :as dataset])
Couldn't load Clojure file: Uninitialized object exists on backward branch 108
Exception Details:
  Location:
    clojure/core/matrix/impl/wrappers/NDWrapper.get_slice_view(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; @152: goto
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: 2c01 4db8 010b 422b 014c b801 0b37 05b2
    0000010: 010e b600 99c0 009b 2ab4 0047 b900 d202
    0000020: 003a 072a b400 43c0 0110 1605 882f 0037
    0000030: 0819 07c0 0110 1608 8821 b801 1458 bb00
    0000040: 0259 2ab4 003f 2ab4 0041 c001 10be 360a
    0000050: 150a 850a 6588 360b 2ab4 0041 c001 1015
    0000060: 0bb8 011a 3a0c 1605 8885 370d 160d 150a
    0000070: 850a 6594 9c00 2b19 0cc0 0110 160d 8800
    0000080: 2ab4 0041 c001 1016 0d0a 6188 002f b801
    0000090: 1458 160d 0a61 370d a7ff d400 00bf bf01
    00000a0: 5701 5719 0c01 3a0c 2ab4 0043 c001 10be
    00000b0: 360a 150a 850a 6588 360b 2ab4 0043 c001
    00000c0: 1015 0bb8 011a 3a0c 1605 8885 370d 160d
    00000d0: 150a 850a 6594 9c00 2b19 0cc0 0110 160d
    00000e0: 8800 2ab4 0043 c001 1016 0d0a 6188 002f
    00000f0: b801 1458 160d 0a61 370d a7ff d400 00bf
    0000100: bf01 5701 5719 0c01 3a0c 2ab4 0045 c001
    0000110: 26be 360a 150a 850a 6588 360b 2ab4 0045
    0000120: c001 2615 0bb8 0129 3a0c 1605 8885 370d
    0000130: 160d 150a 850a 6594 9c00 2d19 0cc0 0126
    0000140: 160d 8800 2ab4 0045 c001 2616 0d0a 6188
    0000150: 00b8 012d b801 3057 160d 0a61 370d a7ff
    0000160: d200 00bf bf01 5701 5719 0c01 3a0c 1907
    0000170: 013a 07b7 0136 b0                      
  Stackmap Table:
    full_frame(@108,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#272],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4]})
    full_frame(@155,{},{Object[#316]})
    same_locals_1_stack_item_frame(@158,Object[#316])
    full_frame(@159,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#272],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4]})
    full_frame(@206,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#272],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4],Object[#272]})
    full_frame(@253,{},{Object[#316]})
    same_locals_1_stack_item_frame(@256,Object[#316])
    full_frame(@257,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#272],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4],Object[#272]})
    full_frame(@304,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#294],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4],Object[#272],Object[#272]})
    full_frame(@353,{},{Object[#316]})
    same_locals_1_stack_item_frame(@356,Object[#316])
    full_frame(@357,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#294],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4],Object[#272],Object[#272]})
  file:/Users/currentuser/.m2/repository/net/mikera/core.matrix/0.62.0/core.matrix-0.62.0.jar!/clojure/core/matrix/impl/wrappers.cljc   line:218  column:1

I wasn't expecting the java error to be the cause.

Folcon commented 5 years ago

I've just checked out the project as a checkout and so far all the test cases clj and cljs pass.

Folcon commented 5 years ago

Ok, updating the clojure version to 1.10.1 or 1.10.0 causes the issue, but not 1.9.0.

Updating clojurescript from 1.9.908 to 1.10.520 caused only 2 test failures in core.matrix/src/test/clojure/clojure/core/matrix/test_api.cljc:

(deftest test-norm
  (is (== (Math/sqrt 30.0) (li/norm (matrix [[1 2][3 4]]))))
  (is (== (Math/sqrt 30.0) (li/norm (matrix [[1 2][3 4]]) 2)))
  (is (== 10.0 (li/norm (matrix [[1 2][3 4]]) 1)))
  ;;fails test
  ;;(is (== (Math/cbrt 100.0) (li/norm (matrix [[1 2][3 4]]) 3)))
  (is (== 4 (li/norm (matrix [[1 2][3 -4]]) #?(:clj Double/POSITIVE_INFINITY :cljs Infinity))))
  (is (== (Math/sqrt 30.0) (li/norm (vector 1 2 3 4))))
  (is (== (Math/sqrt 30.0) (li/norm (vector 1 2 3 4) 2)))
  (is (== 10.0 (li/norm (vector 1 2 3 4) 1)))
  ;;fails test
  ;;(is (== (Math/cbrt 100.0) (li/norm (vector 1 2 3 4) 3)))
  (is (== 4 (li/norm (vector 1 2 3 4) #?(:clj Double/POSITIVE_INFINITY :cljs Infinity)))))

I believe the test case however may be in error: In clojurescript 1.9.908 Infinity appears to be valid (those tests pass), however in 1.10.520 it is js/Infinity. Changing the test to:

(deftest test-norm
  (is (== (Math/sqrt 30.0) (li/norm (matrix [[1 2][3 4]]))))
  (is (== (Math/sqrt 30.0) (li/norm (matrix [[1 2][3 4]]) 2)))
  (is (== 10.0 (li/norm (matrix [[1 2][3 4]]) 1)))
  ;;fails test
  ;;(is (== (Math/cbrt 100.0) (li/norm (matrix [[1 2][3 4]]) 3)))
  (is (== 4 (li/norm (matrix [[1 2][3 -4]]) #?(:clj Double/POSITIVE_INFINITY :cljs js/Infinity))))
  (is (== (Math/sqrt 30.0) (li/norm (vector 1 2 3 4))))
  (is (== (Math/sqrt 30.0) (li/norm (vector 1 2 3 4) 2)))
  (is (== 10.0 (li/norm (vector 1 2 3 4) 1)))
  ;;fails test
  ;;(is (== (Math/cbrt 100.0) (li/norm (vector 1 2 3 4) 3)))
  (is (== 4 (li/norm (vector 1 2 3 4) #?(:clj Double/POSITIVE_INFINITY :cljs js/Infinity)))))

Has the test passing on both 1.9.908 and 1.10.520.

I'm not sure what to do regarding the fact that clojure 1.10.0+ seems to cause the error, I don't really want to downgrade, but you may decide the issue is out of scope for the library as it stands...

Folcon commented 5 years ago

Ok, so initially isolated it to 1.10.0-alpha7, 1.10.0-alpha6 appears to work fine...

However, funnily enough 1.10.0-alpha5 is also broken, but not 1.10.0-alpha4...

Which is prompting me to exhaustively see if a newer version works...

Folcon commented 5 years ago

Nope, just tried everything north of 1.10.0-alpha7 and no dice...

Folcon commented 5 years ago

I've so far not been able to require core.matrix in 1.10.0-alpha6, trying 1.10.0-alpha4...

Folcon commented 5 years ago

Not able to require 1.10.0-alpha4 from my figwheel repl either, it doesn't error, just prints the warnings below and hangs:

cljs.user=>  (require '[clojure.core.matrix.dataset :as dataset])
Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc   line:151  column:23

  Use of undeclared Var clojure.core.matrix.utils/x

  146        arr))
  147    ([a b & more]
  148      (let [arr (long-array (+ 2 (count more)))]
  149        (aset arr 0 (long a))
  150        (aset arr 1 (long b))
  151        (doseq-indexed [x more i] (aset arr (+ 2 i) (long x)))
                             ^---
  152        arr)))
  153  
  154  (defn object-array-of
  155    "Creates a long array with the specified values."
  156    ([] (object-array 0))

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc   line:151  column:30

  Use of undeclared Var clojure.core.matrix.utils/i

  146        arr))
  147    ([a b & more]
  148      (let [arr (long-array (+ 2 (count more)))]
  149        (aset arr 0 (long a))
  150        (aset arr 1 (long b))
  151        (doseq-indexed [x more i] (aset arr (+ 2 i) (long x)))
                                    ^---
  152        arr)))
  153  
  154  (defn object-array-of
  155    "Creates a long array with the specified values."
  156    ([] (object-array 0))

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc   line:151  column:48

  Use of undeclared Var clojure.core.matrix.utils/i

  146        arr))
  147    ([a b & more]
  148      (let [arr (long-array (+ 2 (count more)))]
  149        (aset arr 0 (long a))
  150        (aset arr 1 (long b))
  151        (doseq-indexed [x more i] (aset arr (+ 2 i) (long x)))
                                                      ^---
  152        arr)))
  153  
  154  (defn object-array-of
  155    "Creates a long array with the specified values."
  156    ([] (object-array 0))

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc   line:151  column:57

  Use of undeclared Var clojure.core.matrix.utils/x

  146        arr))
  147    ([a b & more]
  148      (let [arr (long-array (+ 2 (count more)))]
  149        (aset arr 0 (long a))
  150        (aset arr 1 (long b))
  151        (doseq-indexed [x more i] (aset arr (+ 2 i) (long x)))
                                                               ^---
  152        arr)))
  153  
  154  (defn object-array-of
  155    "Creates a long array with the specified values."
  156    ([] (object-array 0))

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc   line:170  column:23

  Use of undeclared Var clojure.core.matrix.utils/x

  165        arr))
  166    ([a b & more]
  167      (let [arr (object-array (+ 2 (count more)))]
  168        (aset arr 0 a)
  169        (aset arr 1 b)
  170        (doseq-indexed [x more i] (aset arr (+ 2 i) x))
                             ^---
  171        arr)))
  172  
  173  (defn find-index
  174    "Returns the index of a value in a vector, or nil if not present" 
  175    ([^IPersistentVector v value]

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc   line:170  column:30

  Use of undeclared Var clojure.core.matrix.utils/i

  165        arr))
  166    ([a b & more]
  167      (let [arr (object-array (+ 2 (count more)))]
  168        (aset arr 0 a)
  169        (aset arr 1 b)
  170        (doseq-indexed [x more i] (aset arr (+ 2 i) x))
                                    ^---
  171        arr)))
  172  
  173  (defn find-index
  174    "Returns the index of a value in a vector, or nil if not present" 
  175    ([^IPersistentVector v value]

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc   line:170  column:48

  Use of undeclared Var clojure.core.matrix.utils/i

  165        arr))
  166    ([a b & more]
  167      (let [arr (object-array (+ 2 (count more)))]
  168        (aset arr 0 a)
  169        (aset arr 1 b)
  170        (doseq-indexed [x more i] (aset arr (+ 2 i) x))
                                                      ^---
  171        arr)))
  172  
  173  (defn find-index
  174    "Returns the index of a value in a vector, or nil if not present" 
  175    ([^IPersistentVector v value]

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc   line:170  column:51

  Use of undeclared Var clojure.core.matrix.utils/x

  165        arr))
  166    ([a b & more]
  167      (let [arr (object-array (+ 2 (count more)))]
  168        (aset arr 0 a)
  169        (aset arr 1 b)
  170        (doseq-indexed [x more i] (aset arr (+ 2 i) x))
                                                         ^---
  171        arr)))
  172  
  173  (defn find-index
  174    "Returns the index of a value in a vector, or nil if not present" 
  175    ([^IPersistentVector v value]

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/common.cljc   line:55  column:18

  Use of undeclared Var clojure.core.matrix.impl.common/ClassCastException

  50     Uses a default implementation if needed"
  51    ([impl data]
  52      (or (mp/construct-matrix impl data)
  53          (try 
  54            (mp/construct-matrix mi/*matrix-implementation* data)
  55            (catch ClassCastException t nil)) ;; fix for element type not handled
                       ^---
  56          (mp/construct-matrix [] data))))
  57  
  58  (defn mapmatrix
  59    "Maps a function over all components of a persistent vector matrix. Like mapv but for matrices.
  60     Assumes correct dimensionality / shape.

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc   line:818  column:45

  No such namespace: Long, could not locate Long.cljs, Long.cljc, or JavaScript source providing "Long"

  813    ([pairs n]
  814      (let [^objects dest (object-array n)]
  815        (loop [i (long 0)
  816               pairs (seq pairs)]
  817          (when (< i n)
  818            (aset dest (first (first pairs)) (Long/valueOf i))
                                                   ^---
  819            (recur (inc i)
  820                   (next pairs))))
  821        (vec dest))))
  822  
  823  (extend-protocol mp/PIndexRank

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc   line:818  column:45

  Use of undeclared Var Long/valueOf

  813    ([pairs n]
  814      (let [^objects dest (object-array n)]
  815        (loop [i (long 0)
  816               pairs (seq pairs)]
  817          (when (< i n)
  818            (aset dest (first (first pairs)) (Long/valueOf i))
                                                   ^---
  819            (recur (inc i)
  820                   (next pairs))))
  821        (vec dest))))
  822  
  823  (extend-protocol mp/PIndexRank

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc   line:2000  column:72

  Use of undeclared Var clojure.core.matrix.impl.defaults/class

  1995      (reshape-view [m shape]
  1996        (mp/broadcast m shape))
  1997    #?(:clj Object :cljs object)
  1998      (reshape-view [m shape]
  1999        (if (mp/is-mutable? m)
  2000          (TODO "reshape-view not supported on mutable array of type: " (class m))
                                                                               ^---
  2001          (mp/reshape m shape))))
  2002  
  2003  (extend-protocol mp/PCoercion
  2004    nil
  2005      (coerce-param [m param]

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/dataset.cljc   line:330  column:1

  Extending an existing JavaScript type - use a different symbol name instead of js/Object e.g object

  325      (convert-to-nested-vectors [ds]
  326        (let [cols ( #?(:clj .columns :cljs .-columns) ds)
  327              ix (get-index0 ds)]
  328          (mapv #(mp/get-1d % ix) cols))))
  329  
  330  (extend-protocol mp/PColumnIndex
       ^---
  331    #?(:clj Object :cljs js/Object)
  332      (column-index [ds column-name]
  333        (when-let [cnames (mp/column-names ds)]
  334          (let [cnames ^IPersistentVector (vec cnames)]
  335            (and cnames (utils/find-index cnames column-name))))))

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix/impl/dataset.cljc   line:421  column:1

  Extending an existing JavaScript type - use a different symbol name instead of js/Object e.g object

  416          (dataset-from-columns
  417           (concat (mp/column-names ds1) (mp/column-names ds2))
  418           (concat (mp/get-columns ds1) (mp/get-columns ds2)))
  419          (error "Duplicate column names: " isection)))))
  420  
  421  (extend-protocol mp/PDatasetMaps
       ^---
  422    DataSet
  423      (row-maps [ds]
  424        (let [col-names (mp/column-names ds)]
  425          (mapv #(zipmap col-names %)
  426                (mp/get-rows ds))))

Compile Warning   /Users/currentuser/Documents/Code/clojure/currentproj/checkouts/core.matrix/src/main/clojure/clojure/core/matrix.cljc   line:271  column:14

  Use of undeclared Var clojure.core.matrix/Throwable

  266     If the current implementation does not support mutable matrices, will return a mutable array
  267     from another core.matrix implementation that supports either the same element type or a broader type."
  268    ([data]
  269      (try (or (mp/mutable-matrix data)
  270              (mutable (implementation-check) data))
  271        (catch Throwable t ;; catch error in array construction, attempt to use a default implementation
                    ^---
  272          (default/construct-mutable-matrix data))))
  273    ([implementation data]
  274      (let [imp (implementation-check implementation)
  275            r (mp/construct-matrix imp data)]
  276        (or (and r (mp/ensure-mutable r)) ;; ensure contructed array is mutable, else fall through with nil

Going to test with the cljc branch, as #81 implied that worked.

Folcon commented 5 years ago

Finally got it to work with develop branch and this happened 😆...

cljs.user=>  (require '[clojure.core.matrix.dataset :as dataset])
nil
cljs.user=>  (dataset/dataset [{:a 1 :b 2} {:a 4 :b 5}])
Eval timed out!
No stacktrace available.
Folcon commented 5 years ago

I've had some success after someone suggested swapping to openjdk 8, as in I can require it, but I can't seem to get it currently working in the cljs repl. I'll do some more testing and update here if I figure anything out...

mikera commented 5 years ago

Cool thanks! I don't really understand the cljs implementation too well but happy to help merge any changes needed.

vvvvalvalval commented 4 years ago

FWIW, I'm facing the same error without involving ClojureScript at all. Minimal repro:

$ clojure -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0"} net.mikera/core.matrix {:mvn/version "0.62.0"} net.mikera/vectorz-clj {:mvn/version "0.48.0"}}}' -e "(require '[mikera.vectorz.matrix-api])"

Exception in thread "main" Syntax error compiling new at (clojure/core/matrix/impl/wrappers.cljc:218:1).
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:7114)
        at clojure.lang.Compiler.analyze(Compiler.java:6789)
        at clojure.lang.Compiler.analyze(Compiler.java:6745)
        at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6120)
        at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5467)
        at clojure.lang.Compiler$FnExpr.parse(Compiler.java:4029)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:7104)
        at clojure.lang.Compiler.analyze(Compiler.java:6789)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:7094)
        at clojure.lang.Compiler.analyze(Compiler.java:6789)
        at clojure.lang.Compiler.access$300(Compiler.java:38)
        at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:596)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:7106)
        at clojure.lang.Compiler.analyze(Compiler.java:6789)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:7094)
        at clojure.lang.Compiler.analyze(Compiler.java:6789)
        at clojure.lang.Compiler.analyze(Compiler.java:6745)
        at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6118)
        at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6436)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:7106)
        at clojure.lang.Compiler.analyze(Compiler.java:6789)
        at clojure.lang.Compiler.analyze(Compiler.java:6745)
        at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6120)
        at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5467)
        at clojure.lang.Compiler$FnExpr.parse(Compiler.java:4029)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:7104)
        at clojure.lang.Compiler.analyze(Compiler.java:6789)
        at clojure.lang.Compiler.eval(Compiler.java:7173)
        at clojure.lang.Compiler.load(Compiler.java:7635)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:463)
        at clojure.lang.RT.load(RT.java:428)
        at clojure.core$load$fn__6824.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:551)
        at clojure.core.matrix.impl.defaults$eval158$loading__6706__auto____159.invoke(defaults.cljc:1)
        at clojure.core.matrix.impl.defaults$eval158.invokeStatic(defaults.cljc:1)
        at clojure.core.matrix.impl.defaults$eval158.invoke(defaults.cljc:1)
        at clojure.lang.Compiler.eval(Compiler.java:7176)
        at clojure.lang.Compiler.eval(Compiler.java:7165)
        at clojure.lang.Compiler.load(Compiler.java:7635)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:463)
        at clojure.lang.RT.load(RT.java:428)
        at clojure.core$load$fn__6824.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:619)
        at clojure.core.matrix$eval150$loading__6706__auto____151.invoke(matrix.cljc:1)
        at clojure.core.matrix$eval150.invokeStatic(matrix.cljc:1)
        at clojure.core.matrix$eval150.invoke(matrix.cljc:1)
        at clojure.lang.Compiler.eval(Compiler.java:7176)
        at clojure.lang.Compiler.eval(Compiler.java:7165)
        at clojure.lang.Compiler.load(Compiler.java:7635)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:463)
        at clojure.lang.RT.load(RT.java:428)
        at clojure.core$load$fn__6824.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:669)
        at clojure.core$use.invokeStatic(core.clj:6093)
        at clojure.core$use.doInvoke(core.clj:6093)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at mikera.vectorz.matrix_api$eval142$loading__6706__auto____143.invoke(matrix_api.clj:1)
        at mikera.vectorz.matrix_api$eval142.invokeStatic(matrix_api.clj:1)
        at mikera.vectorz.matrix_api$eval142.invoke(matrix_api.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:7176)
        at clojure.lang.Compiler.eval(Compiler.java:7165)
        at clojure.lang.Compiler.load(Compiler.java:7635)
        at clojure.lang.RT.loadResourceScript(RT.java:381)
        at clojure.lang.RT.loadResourceScript(RT.java:372)
        at clojure.lang.RT.load(RT.java:463)
        at clojure.lang.RT.load(RT.java:428)
        at clojure.core$load$fn__6824.invoke(core.clj:6126)
        at clojure.core$load.invokeStatic(core.clj:6125)
        at clojure.core$load.doInvoke(core.clj:6109)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5908)
        at clojure.core$load_one.invoke(core.clj:5903)
        at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
        at clojure.core$load_lib.invokeStatic(core.clj:5947)
        at clojure.core$load_lib.doInvoke(core.clj:5928)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$load_libs.invokeStatic(core.clj:5985)
        at clojure.core$load_libs.doInvoke(core.clj:5969)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:667)
        at clojure.core$require.invokeStatic(core.clj:6007)
        at clojure.core$require.doInvoke(core.clj:6007)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at user$eval1.invokeStatic(NO_SOURCE_FILE:1)
        at user$eval1.invoke(NO_SOURCE_FILE:1)
        at clojure.lang.Compiler.eval(Compiler.java:7176)
        at clojure.lang.Compiler.eval(Compiler.java:7131)
        at clojure.core$eval.invokeStatic(core.clj:3214)
        at clojure.main$eval_opt.invokeStatic(main.clj:465)
        at clojure.main$eval_opt.invoke(main.clj:459)
        at clojure.main$initialize.invokeStatic(main.clj:485)
        at clojure.main$null_opt.invokeStatic(main.clj:519)
        at clojure.main$null_opt.invoke(main.clj:516)
        at clojure.main$main.invokeStatic(main.clj:598)
        at clojure.main$main.doInvoke(main.clj:561)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:37)
Caused by: java.lang.VerifyError: Uninitialized object exists on backward branch 108
Exception Details:
  Location:
    clojure/core/matrix/impl/wrappers/NDWrapper.get_slice_view(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; @152: goto
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: 2c01 4db8 010b 422b 014c b801 0b37 05b2
    0000010: 010e b600 99c0 009b 2ab4 0047 b900 d202
    0000020: 003a 072a b400 43c0 0110 1605 882f 0037
    0000030: 0819 07c0 0110 1608 8821 b801 1458 bb00
    0000040: 0259 2ab4 003f 2ab4 0041 c001 10be 360a
    0000050: 150a 850a 6588 360b 2ab4 0041 c001 1015
    0000060: 0bb8 011a 3a0c 1605 8885 370d 160d 150a
    0000070: 850a 6594 9c00 2b19 0cc0 0110 160d 8800
    0000080: 2ab4 0041 c001 1016 0d0a 6188 002f b801
    0000090: 1458 160d 0a61 370d a7ff d400 00bf bf01
    00000a0: 5701 5719 0c01 3a0c 2ab4 0043 c001 10be
    00000b0: 360a 150a 850a 6588 360b 2ab4 0043 c001
    00000c0: 1015 0bb8 011a 3a0c 1605 8885 370d 160d
    00000d0: 150a 850a 6594 9c00 2b19 0cc0 0110 160d
    00000e0: 8800 2ab4 0043 c001 1016 0d0a 6188 002f
    00000f0: b801 1458 160d 0a61 370d a7ff d400 00bf
    0000100: bf01 5701 5719 0c01 3a0c 2ab4 0045 c001
    0000110: 26be 360a 150a 850a 6588 360b 2ab4 0045
    0000120: c001 2615 0bb8 0129 3a0c 1605 8885 370d
    0000130: 160d 150a 850a 6594 9c00 2d19 0cc0 0126
    0000140: 160d 8800 2ab4 0045 c001 2616 0d0a 6188
    0000150: 00b8 012d b801 3057 160d 0a61 370d a7ff
    0000160: d200 00bf bf01 5701 5719 0c01 3a0c 1907
    0000170: 013a 07b7 0136 b0                      
  Stackmap Table:
    full_frame(@108,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#272],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4]})
    full_frame(@155,{},{Object[#316]})
    same_locals_1_stack_item_frame(@158,Object[#316])
    full_frame(@159,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#272],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4]})
    full_frame(@206,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#272],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4],Object[#272]})
    full_frame(@253,{},{Object[#316]})
    same_locals_1_stack_item_frame(@256,Object[#316])
    full_frame(@257,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#272],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4],Object[#272]})
    full_frame(@304,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#294],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4],Object[#272],Object[#272]})
    full_frame(@353,{},{Object[#316]})
    same_locals_1_stack_item_frame(@356,Object[#316])
    full_frame(@357,{Object[#2],Null,Null,Long,Long,Object[#4],Long,Integer,Integer,Object[#294],Long},{Uninitialized[#62],Uninitialized[#62],Object[#4],Object[#272],Object[#272]})

        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2658)
        at java.lang.Class.getConstructors(Class.java:1638)
        at clojure.lang.Compiler$NewExpr.<init>(Compiler.java:2575)
        at clojure.lang.Compiler$NewExpr$Parser.parse(Compiler.java:2667)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:7106)
        ... 149 more

On Mac 10.1.3 and Java HotSpot(TM) 64-Bit Server VM 1.8.0_05

vvvvalvalval commented 4 years ago

From the error message, I conjectured that the issue was linked the self-referential constructor invocation in NDWrapper. get_slice_view().

The changes proposed in the above PR remove that via Var indirection. I've checked manually that this does indeed fix the issue - (require '[clojure.core.matrix]) now completes without error in the same environment.

lein test did yield one error in the ClojureScript tests, but that error was already present before my changes, and given its contents I have every reason to believe it's unrelated:

$ lein test
Compiling 4 source files to /Users/val/projects/core.matrix/target/classes

lein test clojure.core.matrix.benchmark

lein test clojure.core.matrix.calling-benchmark

lein test clojure.core.matrix.compliance-tester

lein test clojure.core.matrix.demo.examples

lein test clojure.core.matrix.demo.geom

lein test clojure.core.matrix.demo.gravity

lein test clojure.core.matrix.demo.life

lein test clojure.core.matrix.demo.matrix-joining

lein test clojure.core.matrix.demo.neural

lein test clojure.core.matrix.demo.normalise

lein test clojure.core.matrix.demo.pagerank

lein test clojure.core.matrix.demo.polynomial

lein test clojure.core.matrix.demo.snakes

lein test clojure.core.matrix.generators

lein test clojure.core.matrix.impl.dummy

lein test clojure.core.matrix.impl.test-wrappers

lein test clojure.core.matrix.inline-benchmark

lein test clojure.core.matrix.query-benchmark

lein test clojure.core.matrix.test-api

lein test clojure.core.matrix.test-arrays

lein test clojure.core.matrix.test-blas

lein test clojure.core.matrix.test-clatrix

lein test clojure.core.matrix.test-cljs

lein test clojure.core.matrix.test-comparisons

lein test clojure.core.matrix.test-dataset

lein test clojure.core.matrix.test-double-array

lein test clojure.core.matrix.test-double-array-nd

lein test clojure.core.matrix.test-generated-arrays
{:result true, :num-tests 100, :seed 1586732680083, :test-var "instance-tests"}

lein test clojure.core.matrix.test-index

lein test clojure.core.matrix.test-ndarray-implementation

lein test clojure.core.matrix.test-nil

lein test clojure.core.matrix.test-numbers

lein test clojure.core.matrix.test-object-array

lein test clojure.core.matrix.test-operators

lein test clojure.core.matrix.test-persistent-vector-implementation

lein test clojure.core.matrix.test-pprint

lein test clojure.core.matrix.test-random

lein test clojure.core.matrix.test-selection

lein test clojure.core.matrix.test-sequence

lein test clojure.core.matrix.test-sparse-map

lein test clojure.core.matrix.test-stats

lein test clojure.core.matrix.test-utils

lein test clojure.core.matrix.test-vectorz

lein test core.matrix.calling-benchmark

lein test test.misc.loading-test

lein test test.misc.test-load

Ran 319 tests containing 22301 assertions.
0 failures, 0 errors.
Analyzing jar:file:/Users/val/.m2/repository/org/clojure/clojurescript/1.9.908/clojurescript-1.9.908.jar!/cljs/core.cljs
Analyzing out/thi/ng/typedarrays/core.cljs
Analyzing out/clojure/string.cljs
Analyzing /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/macros.cljc
Analyzing out/cljs/pprint.cljs
Analyzing /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/mathsops.cljc
Analyzing /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/macros_cljs.cljc
Analyzing /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc
WARNING: Use of undeclared Var clojure.core.matrix.utils/x at line 151 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc
WARNING: Use of undeclared Var clojure.core.matrix.utils/i at line 151 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc
WARNING: Use of undeclared Var clojure.core.matrix.utils/i at line 151 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc
WARNING: Use of undeclared Var clojure.core.matrix.utils/x at line 151 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc
WARNING: Use of undeclared Var clojure.core.matrix.utils/x at line 170 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc
WARNING: Use of undeclared Var clojure.core.matrix.utils/i at line 170 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc
WARNING: Use of undeclared Var clojure.core.matrix.utils/i at line 170 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc
WARNING: Use of undeclared Var clojure.core.matrix.utils/x at line 170 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/utils.cljc
Analyzing /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/protocols.cljc
Analyzing out/cljs/test.cljs
Analyzing out/jx/reporter/karma.cljs
Analyzing out/doo/runner.cljs
Analyzing /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/implementations.cljc
Analyzing /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/sequence.cljc
Analyzing /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/common.cljc
WARNING: Use of undeclared Var clojure.core.matrix.impl.common/ClassCastException at line 55 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/common.cljc
Analyzing /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/persistent_vector.cljc
Compiling /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/wrappers.cljc
Analyzing /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/linear.cljc
Compiling /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/double_array.cljs
Analyzing out/cljs/tools/reader/impl/utils.cljs
Compiling /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc
Analyzing out/cljs/tools/reader/reader_types.cljs
Analyzing out/cljs/tools/reader/impl/inspect.cljs
Analyzing out/cljs/tools/reader/impl/errors.cljs
Analyzing out/cljs/tools/reader/impl/commons.cljs
Analyzing out/cljs/tools/reader.cljs
Analyzing out/cljs/tools/reader/edn.cljs
WARNING: No such namespace: Long, could not locate Long.cljs, Long.cljc, or JavaScript source providing "Long" at line 818 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc
WARNING: Use of undeclared Var Long/valueOf at line 818 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc
WARNING: No such namespace: cljs, could not locate cljs.cljs, cljs.cljc, or JavaScript source providing "cljs" at line 1199 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc
WARNING: Use of undeclared Var cljs/core at line 1199 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc
WARNING: No such namespace: cljs, could not locate cljs.cljs, cljs.cljc, or JavaScript source providing "cljs" at line 1203 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc
WARNING: Use of undeclared Var cljs/core at line 1203 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc
WARNING: Use of undeclared Var clojure.core.matrix.impl.defaults/class at line 2000 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/defaults.cljc
Analyzing out/clojure/set.cljs
Compiling /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix.cljc
Analyzing file:/Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/sequence.cljc
Compiling /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/dataset.cljc
WARNING: Extending an existing JavaScript type - use a different symbol name instead of js/Object e.g object at line 330 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/dataset.cljc
WARNING: Extending an existing JavaScript type - use a different symbol name instead of js/Object e.g object at line 421 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/impl/dataset.cljc
WARNING: Use of undeclared Var clojure.core.matrix/Throwable at line 271 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix.cljc
Compiling /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/stats.cljc
Compiling /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/operators.cljc
Compiling /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/dataset.cljc
Analyzing /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/generic.cljc
Compiling out/thinktopic/aljabr/core.cljc
WARNING: No such namespace: Double, could not locate Double.cljs, Double.cljc, or JavaScript source providing "Double" at line 122 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/stats.cljc
WARNING: Use of undeclared Var Double/NEGATIVE_INFINITY at line 122 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/stats.cljc
WARNING: No such namespace: Float, could not locate Float.cljs, Float.cljc, or JavaScript source providing "Float" at line 122 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/stats.cljc
WARNING: Use of undeclared Var Float/isNaN at line 122 /Users/val/projects/core.matrix/src/main/clojure/clojure/core/matrix/stats.cljc
Analyzing out/cljs/reader.cljs
Compiling /Users/val/projects/core.matrix/src/test/clojure/clojure/core/matrix/compliance_tester.cljc
WARNING: Wrong number of args (2) passed to IndexedSeq at line 16 out/thinktopic/aljabr/core.cljc
WARNING: clojure.core.matrix/length is deprecated. at line 607 /Users/val/projects/core.matrix/src/test/clojure/clojure/core/matrix/compliance_tester.cljc
Compiling /Users/val/projects/core.matrix/src/test/clojure/clojure/core/matrix/test_dataset.cljc
Compiling /Users/val/projects/core.matrix/src/test/clojure/clojure/core/matrix/test_api.cljc
Compiling /Users/val/projects/core.matrix/src/test/cljs/clojure/core/matrix/cljs_runner.cljs
Applying optimizations :advanced to 52 sources
Apr 13, 2020 1:05:24 AM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: /Users/val/projects/core.matrix/out/cljs/core.js:3579: ERROR - Parse error. primary expression expected
case ##Inf:
      ^

Apr 13, 2020 1:05:24 AM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: /Users/val/projects/core.matrix/out/cljs/test.js:257: ERROR - Parse error. ']' expected
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [##NaN,##NaN], null);
                                                                                          ^

Apr 13, 2020 1:05:24 AM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 2 error(s), 0 warning(s)
ERROR: JSC_PARSE_ERROR. Parse error. primary expression expected at /Users/val/projects/core.matrix/out/cljs/core.js line 3579 : 6
ERROR: JSC_PARSE_ERROR. Parse error. ']' expected at /Users/val/projects/core.matrix/out/cljs/test.js line 257 : 90

;; ======================================================================
;; Testing with Nashorn:

ERROR: doo was not loaded from the compiled script.

Make sure you start your tests using doo-tests or doo-all-tests
and that you include that file in your build

Error encountered performing task 'doo' with profile(s): 'cljs'
Subprocess failed