[armedbear-cvs] r13282 - trunk/abcl/src/org/armedbear/lisp
mevenson at common-lisp.net
mevenson at common-lisp.net
Sat Jun 4 20:25:29 UTC 2011
Author: mevenson
Date: Sat May 21 05:40:49 2011
New Revision: 13282
Log:
Make JAVA:JRESOLVE-METHOD try harder to resolve a JAVA-OBJECT instance.
Unclear if this behavior comes from a bug in how we intialize
JAVA-OBJECT's intendedClass or is a "natural" result of some casting
assumption. We assume that users of JRESOLVE-METHOD would prefer some
sort of callable result as opposed to NIL as the current JAVA
introspection APIs assumption seems to geared to guessing a reasonable
default. Those wishing strict introspection semantics are advised to
use the java.lang.reflect package directly.
Modified:
trunk/abcl/src/org/armedbear/lisp/Java.java
Modified: trunk/abcl/src/org/armedbear/lisp/Java.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Java.java Fri May 20 07:24:57 2011 (r13281)
+++ trunk/abcl/src/org/armedbear/lisp/Java.java Sat May 21 05:40:49 2011 (r13282)
@@ -771,13 +771,12 @@
};
private static final Primitive JRESOLVE_METHOD = new pf_jresolve_method();
- @DocString(name="jresolve_method", args="method-name instance &rest args",
+ @DocString(name="jresolve-method", args="method-name instance &rest args",
doc="Finds the most specific Java method METHOD-NAME on INSTANCE " +
"applicable to arguments ARGS. Returns NIL if no suitable method is " +
"found. The algorithm used for resolution is the same used by JCALL " +
"when it is called with a string as the first parameter (METHOD-REF).")
private static final class pf_jresolve_method extends Primitive {
-
pf_jresolve_method() {
super(Symbol.JRESOLVE_METHOD);
}
@@ -808,6 +807,18 @@
Method method = findMethod(instance, intendedClass, methodName, methodArgs);
if (method != null) {
return JavaObject.getInstance(method);
+ } else if (instanceArg instanceof JavaObject) {
+ // Sometimes JavaObject.intendedClass has the default
+ // value java.lang.Object, so we try again to resolve
+ // the method using a dynamically requested value for
+ // java.lang.Class.
+ intendedClass = ((JavaObject)instanceArg).getObject().getClass();
+ method = findMethod(instance, intendedClass, methodName, methodArgs);
+ } else {
+ return NIL;
+ }
+ if (method != null) {
+ return JavaObject.getInstance(method);
} else {
return NIL;
}
More information about the armedbear-cvs
mailing list