This is the mail archive of the kawa@sources.redhat.com 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]

ClassCastExceptions on cond results


Using the following function:

(define (map-change-data value)
  (cond ((instance? value <com.mvista.changesys.om.Change>) => (invoke (as <com.mvista.changesys.om.Change> value) 'getChangeId))     
        ((instance? value <com.mvista.changesys.om.Feature>) => (invoke (as <com.mvista.changesys.om.Feature> value) 'getFeatureId))                
        ((instance? value <com.mvista.changesys.om.Repository>) => (invoke (as <com.mvista.changesys.om.Repository> value) 'getRepositoryId))
        ((instance? value <gnu.lists.FString>) => (as <java.lang.String> (invoke value 'toString)))
        ((and (instance? value <java.lang.Boolean>) (equal? value #t)) => (as <integer> 1))
        ((and (instance? value <java.lang.Boolean>) (equal? value #f)) => (as <integer> 0)) 
        (else value)))

Cases which fall through to the else result in the expected result.
However, any other case results in a ClassCastException called for the
class of the result of the cond. For instance:

#|kawa:9|# (map-change-data #t)
Invalid parameter, was: java.lang.Integer
java.lang.ClassCastException: java.lang.Integer
        at atInteractiveLevel.mapChangeData(Unknown Source)

or

#|kawa:8|# (map-change-data (car (get-features)))
Invalid parameter, was: org.apache.torque.om.NumberKey
java.lang.ClassCastException: org.apache.torque.om.NumberKey
        at atInteractiveLevel.mapChangeData(Unknown Source)

where torque.om.NumberKey is the return type of getFeatureId().


Any insight as to what's going on would be appreciated. Thanks!

Attachment: signature.asc
Description: This is a digitally signed message part


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