[armedbear-devel] Issue finding methods in JSS

Jonathan P. Bona jonathanbona at gmail.com
Wed Aug 1 04:08:26 UTC 2012


Just to follow up on this with a little more info, I've put together a
small example that demonstrates the issue I'm seeing.

Consider this class "Outer", which includes an inner class "Inner":

public class Outer {
	public static Inner getAnInner(){
		return new Inner();
	}
	
	static class Inner{
		public Inner(){
		}
		
		public void innerm(){
			System.out.println("called innerm");
		}
	}
}

In Java, I can instantiate Inner and call its public methods, as in
the following:

public class TestMain {
	public static void main(String[] args){
		Outer.Inner myinner = new Outer.Inner();
		myinner.innerm();
	}
}	

However, in ABCL 1.0.1:

CL-USER(1): (jnew "Outer$Inner")
#<THREAD "interpreter" {7FB5438D}>: Debugger invoked on condition of
type JAVA-EXCEPTION
  Java exception 'java.lang.IllegalAccessException: Class
org.armedbear.lisp.Java$pf_jnew can not access a member of class
Outer$Inner with modifiers "public"'.

I can still get an instance to play with:

CL-USER(3): (jstatic "getAnInner" "Outer")
#<Outer$Inner Outer$Inner at 67df02c9 {62300F65}>

… but I can't call its public methods:

CL-USER(6): (jcall "innerm" (jstatic "getAnInner" "Outer"))
#<THREAD "interpreter" {7FB5438D}>: Debugger invoked on condition of
type JAVA-EXCEPTION
  Java exception 'java.lang.IllegalAccessException: Class
org.armedbear.lisp.Java can not access a member of class Outer$Inner
with modifiers "public"'.

… unless I use JSS and with-constant-signature

CL-USER(7): (require :abcl-contrib)
CL-USER(8): (require :jss)
CL-USER(9): (jss::ensure-compatibility)
CL-USER(10): (with-constant-signature ((innerm "innerm")) (innerm
(jstatic "getAnInner" "Outer"))
)
called innerm
NIL



Any help getting to the bottom of this would be greatly appreciated.

Regards,
Jonathan


On Tue, Jul 31, 2012 at 10:06 PM, Alan Ruttenberg
<alanruttenberg at gmail.com> wrote:
> Hey guys,
>
> Have any of you had a chance to look into this? This is a showstopper for me
> using the latest ABCL as I have basic infrastructure code that is failing.
>
> Would much appreciate someone having a look.
>
> Thanks,
> Alan
>
>
> On Thu, Jul 19, 2012 at 3:54 PM, Jonathan P. Bona <jonathanbona at gmail.com>
> wrote:
>>
>> Hello,
>>
>> We found this issue while working with LSW. It seems to be a bug in
>> how public methods are found for inner classes. The last line of code
>> below results in an exception rather than finding and running the
>> size() method:
>>
>> ;;;----------------
>> (require :abcl-contrib)
>> (require :jss)
>> (jss::ensure-compatibility)
>> (setq headers (#"getHeaderFields" (#"openConnection" (jss::new
>> 'java.net.url "http://google.com"))))
>>
>> ; a java.util.Collections$UnmodifiableRandomAccessList
>> (setq ural (#"get" headers (second (jss::set-to-list (#"keySet"
>> headers)))))
>>
>> ;finds:  #<method public int
>> java.util.Collections$UnmodifiableCollection.size()>
>> (find "size" (#"getMethods" (#"getClass" ural) ) :test 'string-equal
>> :key #"getName")
>>
>> ; Java exception 'java.lang.NoSuchMethodException: No applicable
>> method named size found in java.lang.Object or
>> java.util.Collections$UnmodifiableRandomAccessList'.
>> (#"size" ural)
>> ;;;----------------
>>
>> I chased this into org.armedbear.lisp.Java, where findMethod is returning
>> null.
>>
>> - Jonathan Bona
>
>
>
> _______________________________________________
> armedbear-devel mailing list
> armedbear-devel at common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel
>




More information about the armedbear-devel mailing list