[armedbear-devel] TYPE-ERROR #<java.lang.String foo {BADEAFFE}> cannot be coerced to a string.

Mario Lang mlang at delysid.org
Mon Jun 14 19:30:07 UTC 2010


Alessio Stalla <alessiostalla at gmail.com> writes:

> On Sat, Jun 12, 2010 at 3:40 PM, Mario Lang <mlang at delysid.org> wrote:
>> Just stumbled across this one when I tried to use STRING-EQUAL
>> to compare a value I received via JINTERFACE-IMPLEMENTATION.
>>
>> Now, it appears to be very simple to allow the expression
>>
>>  (string (jnew "java.lang.String" "foo"))
>>
>> by overriding STRING() in JavaObject and checking if obj is a (java) String.
>>
>> What do you think?
>
> I think it would be a valuable addition, but why limit it to Strings?
> (string java-object) could always return the result of calling
> toString() on the wrapped object, or "null" when it's null.

Thats certainly an option, but I didn't want to make the initial proposal
to broad. :-)  toString() is a method of java.lang.Object,
so JavaObject#STRING could indeed just call toString without checking
for the class of obj.  In fact, the more I think of it the better it
sounds.

If there is consensus, I can prepare an update patch if need be (its
simple enough anyways).

-- 
CYa,
  ⡍⠁⠗⠊⠕ | Debian Developer <URL:http://debian.org/>
  .''`. | Get my public key via finger mlang/key at db.debian.org
 : :' : | 1024D/7FC1A0854909BCCDBE6C102DDFFC022A6B113E44
 `. `'
   `-      <URL:http://delysid.org/>  <URL:http://www.staff.tugraz.at/mlang/>




More information about the armedbear-devel mailing list