This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem compiling primitive array references


Hurst, Dave wrote:
Hello!

I have a function that converts an array of objects returned by a Java
function into a Scheme list.  This function works just fine in interpreted
mode.  When I try to compile the Scheme, I get an error complaining that
gnu.kawa.reflect.ArrayLength does not implement Externalizable.

This seems to have been fixed sometime between kawa-1.7 and kawa-1.7.90.


But notice this is a symptom of inefficient code:  If Kawa is able to
generate efficient bytecode, it won't need to externalize ArrayLength.

Here is example code:

(define (get-aggregation-policy pqm :: <com.lisletech.PolicyQueryManager>)
  (let ((ap-get (primitive-array-get <com.lisletech.PolicyNodeType>))
        (ap-length (primitive-array-length <com.lisletech.PolicyNodeType>))
        (policy-list (PolicyQueryManager:getAggregationPolicy pqm)))
    (let collect ((index 0))
      (if (< index (ap-length policy-list))
          (cons (ap-get policy-list index)
                (collect (+ index 1)))
          '()))))

The calls to ap-get and ap-length will require run-time reflection. You might want to define ap-get and ap-length as macros instead. It might also work to define them as constants: (define-constant ap-get (primitive-array-get <com.lisletech.PolicyNodeType>)) However, I haven't tested if this will let ap-get calls be inlined.

The current Kawa SVN has much more convenient ways to access
Java arrays, by the way.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]