Fix usage of JSS:J2LISP on Java 6

Correct cardinality declaration of JSS tests that will be executed.
parent c89030d6
......@@ -98,7 +98,10 @@ If INVERT? is non-nil than reverse the keys and values in the resulting hashtabl
(defun j2list (thing)
"Attempt to construct a Lisp list out of a Java THING"
"Attempt to construct a Lisp list out of a Java THING.
THING may be a wide range of Java collection types, their common
iterators or a Java array."
(declare (optimize (speed 3) (safety 0)))
(flet ((iterator-collect (iterator)
(with-constant-signature ((has-next "hasNext")
......@@ -116,14 +119,25 @@ If INVERT? is non-nil than reverse the keys and values in the resulting hashtabl
(let ((keyiterator (#"iterator" (#"keyset" map))))
(loop :while (has-next keyiterator)
:for key = (next keyiterator)
:collect (cons key (#"get" map key)))))))
(let ((isinstance (load-time-value (jmethod "java.lang.Class" "isInstance" "java.lang.Object"))))
(cond ((jcall isinstance (load-time-value (jclass "java.util.AbstractCollection")) thing) (iterator-collect (#"iterator" thing)))
((jcall isinstance (load-time-value (jclass "java.util.Iterator")) thing) (iterator-collect thing))
((jcall isinstance (load-time-value (jclass "java.util.Enumeration")) thing) (enumeration-collect thing))
((jcall isinstance (load-time-value (jclass "java.util.AbstractMap")) thing) (map-collect thing))
((jcall isinstance (load-time-value (jclass "java.util.Collections")) thing) (iterator-collect (#"iterator" thing)))
((jcall isinstance (load-time-value (jclass "java.util.Spliterator")) thing) (iterator-collect (#"iterator" (#"stream" 'StreamSupport thing))))
((jcall isinstance (load-time-value (jclass "java.util.Dictionary")) thing) (iterator-collect (#"elements" thing)))
((ignore-errors (#"toArray" thing)) (coerce (#"toArray" thing) 'list))
(t (error "yet another iteration type - fix it: ~a" (jclass-name (jobject-class thing))))))))
:collect (cons key (#"get" map key)))))))
(let ((isinstance
(load-time-value (jmethod "java.lang.Class" "isInstance" "java.lang.Object"))))
(cond
((jcall isinstance (load-time-value (ignore-errors (jclass "java.util.AbstractCollection")) thing))
(iterator-collect (#"iterator" thing)))
((jcall isinstance (load-time-value (ignore-errors (jclass "java.util.Iterator")) thing))
(iterator-collect thing))
((jcall isinstance (load-time-value (ignore-errors (jclass "java.util.Enumeration")) thing))
(enumeration-collect thing))
((jcall isinstance (load-time-value (ignore-errors (jclass "java.util.AbstractMap")) thing))
(map-collect thing))
((jcall isinstance (load-time-value (ignore-errors (jclass "java.util.Collections")) thing))
(iterator-collect (#"iterator" thing)))
((jcall isinstance (load-time-value (ignore-errors (jclass "java.util.Spliterator")) thing))
(iterator-collect (#"iterator" (#"stream" 'StreamSupport thing))))
((jcall isinstance (load-time-value (ignore-errors (jclass "java.util.Dictionary")) thing))
(iterator-collect (#"elements" thing)))
((ignore-errors (#"toArray" thing))
(coerce (#"toArray" thing) 'list))
(t
(error "yet another iteration type - fix it: ~a" (jclass-name (jobject-class thing))))))))
......@@ -5,7 +5,7 @@
(in-package :jss-test)
(plan 8)
(plan 6)
(is (read-from-string "#\"{bar}.{foo}\"") '(get-java-field bar foo t))
(is (read-from-string "#\"q.bar.{foo}\"") '(get-java-field (load-time-value (find-java-class "q.bar")) foo t))
......@@ -41,12 +41,14 @@
(- (#"currentTimeMillis" 'system) start)))
(plan 1)
(is-type (let ((just-loop (timeit (just-loop 10000))))
(+ 0.0
(print (/ (- (timeit (optimized-jss 10000)) just-loop)
(- (timeit (unoptimized-jss 10000)) just-loop)))))
'(float 0 0.1))
(plan 2)
(let* ((jss::*inhibit-jss-optimization* nil)
(optimized-jss (macroexpand (precompiler::precompile-form '(#"compile" 'regex.Pattern ".*") t))))
(let* ((jss::*inhibit-jss-optimization* t)
......
......@@ -2,7 +2,7 @@
(defsystem jss
:author "Alan Ruttenberg, Mark Evenson"
:long-description "<urn:abcl.org/release/1.5.0/contrib/jss#>"
:version "3.2.3"
:version "3.2.4"
:components ((:module base :pathname "" :serial t
:components ((:file "packages")
(:file "invoke")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment