[armedbear-devel] Issue finding methods in JSS

Alan Ruttenberg alanruttenberg at gmail.com
Wed Aug 1 05:03:36 UTC 2012


Well, that's cute.
with constant signature expands into a call to jss:invoke-find-method
called with the arguments to the first function call, saves that, and
subsequently always uses jcall to call that specific method. The lookup
calls jresolve method then setAccessible on the result. Perhaps it is the
setAccessible that is doing the magic?

You should svn update - I've committed some changes elsewhere. I'm dealing
with an annoyance - I updated abcl to trunk and am trying java 1.7. I get a
startup (fatal) error unless I first delete the slime/swank compiled files.
No clue what that's about. If you want you can see if you can reproduce and
then file a report. Otherwise I'll get to it.

The java 1.7 I get from the Oracle site.

-Alan

On Wed, Aug 1, 2012 at 12:08 AM, Jonathan P. Bona <jonathanbona at gmail.com>wrote:

> 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
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20120801/3a4fd2a4/attachment.html>


More information about the armedbear-devel mailing list