[armedbear-devel] Question about calling Java

Alessio Stalla alessiostalla at gmail.com
Tue Feb 2 22:45:38 UTC 2010


On Tue, Feb 2, 2010 at 6:02 PM, Ville Voutilainen
<ville.voutilainen at gmail.com> wrote:
> 2010/2/2 Mark Evenson <evenson at panix.com>:
>> returns.  Is there any way to tell JCALL not to perform such translation
>> on its arguments?  JCALL-RAW doesn't convert its return value, but maybe
>> we need a JCALL-NAKED that doesn't translate its arguments?  I suspect
>
> Maybe we need an argument converter function that can decide on a per-argument
> basis whether an argument needs conversion or not? You can then do
> jcall-raw/jcall-naked
> invocations as macros on top of it.

We just need a way to wrap a LispObject in a JavaObject, say, (jraw
foo) == new JavaObject(foo). Then plain jcall/jcall-raw will work as
intended.

I also think that this problem is partly related to another, old
problem of ABCL, i.e. that javaInstance(Class) does not have
consistently the semantics of returning an instance of the class
passed as argument.
If Mark had used (jcall (jmethod ...) ...) ABCL would have had the
argument type information available and would have used that to call
javaInstance(Class). However, that wouldn't have worked anyway because
SimpleString.javaInstance(Class) does not take the class into
consideration at all. Imho it should do something like:

if(clazz.isAssignableFrom(String.class)) {
  return javaInstance();
} else {
  return super.javaInstance(clazz);
}

where super.javaInstance(clazz) is

if(clazz.isAssignableFrom(getClass())) {
  return this;
} else {
  return error(...);
}

I believe that if these semantics were consistently given to all the
javaInstance(Class) methods some parts of ABCL would become a little
saner and it would be generally easier to turn Lisp objects into Java
objects. We could also generify javaInstance(Class) to make things
like String s = foo.javaInstance(String.class) work.

Just my 2 cents.
Alessio




More information about the armedbear-devel mailing list