[armedbear-cvs] r14239 - in trunk/abcl: contrib/jss src/org/armedbear/lisp
mevenson at common-lisp.net
mevenson at common-lisp.net
Fri Nov 9 17:28:13 UTC 2012
Author: mevenson
Date: Fri Nov 9 09:28:12 2012
New Revision: 14239
Log:
Fixes #229 so that JCALL works with static member classes.
Added non-working test to putative JSS test suite.
Modified:
trunk/abcl/contrib/jss/jss.asd
trunk/abcl/contrib/jss/tests.lisp
trunk/abcl/src/org/armedbear/lisp/Java.java
Modified: trunk/abcl/contrib/jss/jss.asd
==============================================================================
--- trunk/abcl/contrib/jss/jss.asd Fri Nov 9 08:07:08 2012 (r14238)
+++ trunk/abcl/contrib/jss/jss.asd Fri Nov 9 09:28:12 2012 (r14239)
@@ -1,14 +1,20 @@
;;;; -*- Mode: LISP -*-
(asdf:defsystem :jss
:author "Alan Ruttenberg, Mark Evenson"
- :version "3.0.4"
- :components
- ((:module base
- :pathname "" :serial t
- :components ((:file "packages")
- (:file "invoke")
- (:file "classpath")
- (:file "compat")))))
+ :version "3.0.5"
+ :components ((:module base
+ :pathname "" :serial t
+ :components ((:file "packages")
+ (:file "invoke")
+ (:file "classpath")
+ (:file "compat")))))
+
+#+nil FIXME
+(asdf:defsystem :jss-tests
+ :depends-on (jss abcl abcl-test-lisp)
+ :components ((:module tests
+ :pathname ""
+ :components ((:file "tests")))))
Modified: trunk/abcl/contrib/jss/tests.lisp
==============================================================================
--- trunk/abcl/contrib/jss/tests.lisp Fri Nov 9 08:07:08 2012 (r14238)
+++ trunk/abcl/contrib/jss/tests.lisp Fri Nov 9 09:28:12 2012 (r14239)
@@ -12,4 +12,16 @@
(substring "01234" 2)))
"234")
+;;; http://trac.common-lisp.net/armedbear/ticket/229
+(deftest jss.jcall.1
+ (let* ((headers (#"getHeaderFields"
+ (#"openConnection"
+ (jss::new 'java.net.url "http://google.com"))))
+
+ (second-header (#"get" *headers*
+ (second (jss::set-to-list (#"keySet"
+ *headers*))))))
+ (#"size" *ural*))
+-1)
+
Modified: trunk/abcl/src/org/armedbear/lisp/Java.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Java.java Fri Nov 9 08:07:08 2012 (r14238)
+++ trunk/abcl/src/org/armedbear/lisp/Java.java Fri Nov 9 09:28:12 2012 (r14239)
@@ -888,6 +888,12 @@
else
methodArgs[i-2] = arg.javaInstance(argTypes[i-2]);
}
+ if (!method.isAccessible()) {
+ // Possible for static member classes: see #229
+ if (Modifier.isPublic(method.getModifiers())) {
+ method.setAccessible(true);
+ }
+ }
return JavaObject.getInstance(method.invoke(instance, methodArgs),
translate,
method.getReturnType());
@@ -961,13 +967,27 @@
Class actualClass = null;
if(method == null) {
actualClass = instance.getClass();
- if(intendedClass != actualClass &&
- Modifier.isPublic(actualClass.getModifiers())) {
+ if(intendedClass != actualClass) {
method = findMethod(actualClass, methodName, methodArgs);
+ if (method != null) {
+ if (isMethodCallableOnInstance(actualClass, method)) {
+ return method;
+ }
+ }
}
}
return method;
}
+
+ private static boolean isMethodCallableOnInstance(Class instance, Method method) {
+ if (Modifier.isPublic(method.getModifiers())) {
+ return true;
+ }
+ if (instance.isMemberClass()) {
+ return isMethodCallableOnInstance(instance.getEnclosingClass(), method);
+ }
+ return false;
+ }
private static Method findMethod(Class<?> c, String methodName, Object[] javaArgs) {
Method[] methods = c.getMethods();
More information about the armedbear-cvs
mailing list