Ignore:
Timestamp:
06/09/17 08:50:50 (6 years ago)
Author:
Mark Evenson
Message:

Add jss hook and test
(Alan Ruttenberg)

From <https://github.com/armedbear/abcl/pull/52/commits/155db3e3fbb19a2969221edce465bf45f1560abe>.

Part of merge <https://github.com/armedbear/abcl/pull/52>.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/contrib/jss/jss-tests.lisp

    r15046 r15064  
    2424  (loop repeat count do (#"compile" 'regex.Pattern ".*")))
    2525
    26 (defun unoptimized-jss (count)
    27   (loop repeat count do (#"compile" 'regex.Pattern ".*")))
     26(let ((jss::*inhibit-jss-optimization* t))
     27  (defun unoptimized-jss (count)
     28  (loop repeat count do (#"compile" 'regex.Pattern ".*"))))
    2829
    2930(defun just-loop (count)
     
    4546(is-type (let ((just-loop (timeit (just-loop 10000))))
    4647     (+ 0.0
    47         (print (/ (-  (timeit (optimized-jss 10000)) just-loop)
    48       (-  (timeit (unoptimized-jss 10000)) just-loop)))))
     48        (/ (-  (timeit (optimized-jss 10000)) just-loop)
     49      (-  (timeit (unoptimized-jss 10000)) just-loop))))
    4950   '(float 0 0.1))
    5051
     
    5960(finalize)
    6061
     62(plan 1)
    6163
     64(in-package :jss)
     65(defparameter expanded '(let ((jss::this jss::*object-for-this*))
     66      (jcall "getLoaded"
     67       (jcall "load"
     68        (jcall "make"
     69         (jcall "intercept"
     70          (jcall "method"
     71           (jcall "subclass"
     72            (new '|ByteBuddy|)
     73            (find-java-class '|Object|)
     74            t)
     75           (jstatic "named"
     76              '|ElementMatchers|
     77              "toString"))
     78          (jstatic "value"
     79             '|FixedValue|
     80             "Hello World!")))
     81        (jcall "getClassLoader"
     82         (jcall "getClass" jss::this))))))
     83
     84(defparameter source '#1"new ByteBuddy().subclass(Object.class,t)
     85   .method(ElementMatchers.named("toString"))
     86   .intercept(FixedValue.value("Hello World!"))
     87   .make()
     88   .load(getClass().getClassLoader())
     89   .getLoaded()" )
     90
     91(in-package :jss-test)
     92
     93(is jss::source
     94    jss::expanded)
     95
     96(finalize)
Note: See TracChangeset for help on using the changeset viewer.