This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Reflection
On Wed, September 27, 2017 11:28 am, Per Bothner wrote:
> On 09/27/2017 07:55 AM, Peter wrote:
>> I'm trying to reflect on Classes, however, I'm running into some
>> problems:
>>
>>> ("foo":getClass)
>> class java.lang.String
>>> (("foo":getClass):getCanonicalName)
>> ; Evaluation aborted on java.lang.RuntimeException: no applicable method
>> named `getCanonicalName' in java.lang.String.
>>> (java.lang.String:getCanonicalName)
>> ; Evaluation aborted on java.lang.RuntimeException: no such field
>> getCanonicalName in java.lang.String.
>>> (<java.lang.String>:getCanonicalName)
>> ; Evaluation aborted on java.lang.RuntimeException: no such field
>> getCanonicalName in java.lang.String.
>
> This is explained in
> https://www.gnu.org/software/kawa/Colon-notation.html
>
> However, that doesn't say what to do instead. (I'm adding a note for
> that.)
>
> Basically, if the "receiver" (this) argument is a Class then you can't use
> colon notation, but you can use the invoke procedure:
>
> (invoke ("foo":getClass) 'getCanonicalName)
Using "*:" notation works, too:
(*:getCanonicalName ("foo":getClass))
--
Jamison Hope
jrh@theptrgroup.com