Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > getMethod() works and works not

Reply
Thread Tools

getMethod() works and works not

 
 
Alexander Burger
Guest
Posts: n/a
 
      11-28-2010
Patricia Shanahan <> wrote:
>>> # ??? (java panel "add" JTextArea)

>
> What is the getMethod translation? Does the class in question have an
> "add" method member, either by declaration or inheritance, with the


Oops, you are right. I forgot to fix that line when preparing a reduced
example. 'JTextArea' should have been the variable 'area'. Anyway, it
works now

Thanks.
 
Reply With Quote
 
 
 
 
Alexander Burger
Guest
Posts: n/a
 
      11-28-2010
Mike Schilling <> wrote:
> 3. Reject the ones with the wrong number of arguments. (Be careful here if
> you're going to support variable-argument methods)


I won't. This would introduce too much runtime overhead. Instead I'll go with
passing arrays. The following works:

(java "java.lang.String" "format" "%4$2s %3$2s %2$2s %1$2s" '("a" "b" "c" "d"))
 
Reply With Quote
 
 
 
 
Alessio Stalla
Guest
Posts: n/a
 
      11-29-2010
On Nov 27, 7:24*pm, Alexander Burger <a...@software-lab.de> wrote:
> Mike Schilling <mscottschill...@hotmail.com> wrote:
> > To begin with, why is the OP using reflection at all? *It's of no value in
> > the code actually posted, which could simply call method the normal way..

>
> Sure, but this is just a prepared, reproducible example.
>
> The actual code is the Java version of PicoLisp. The plain runtime
> system ist at "http://software-lab.de/ersatz.tgz", the full system
> including sources at "http://software-lab.de/picoLisp.tgz".
>
> There is a generic 'java' function which allows to call arbitrary
> constructors and methods, on arbitrary objects. And, this indeed works
> most of the cases, but sometimes (like here for 'JPanel' and 'add') not.
>
> The lisp-level function 'java' accepts four syntax patterns:
>
> * *(java 'obj ['cnt]) -> any
> * * * Converts a Java object back to Lisp data
>
> * *(java 'obj 'msg 'any ..) -> obj
> * * * Invokes a method 'msg' on an object 'obj' with arguments 'any'
>
> * *(java 'cls 'msg 'any ..) -> obj
> * * * Invokes a static method 'msg' in class 'cls' with arguments 'any'
>
> * *(java 'cls 'T 'any ..) -> obj
> * * * Returns a new object of class 'cls' by calling the constructor of
> * * * that class with arguments 'any'.
>
> For example, this works (analog to the posted plain Java example):
>
> * *(setq
> * * * frame (java "javax.swing.JFrame" T "Title")
> * * * panel (java frame "getContentPane")
> * * * area (java "javax.swing.JTextArea" T 10 40) )
>
> * *(java frame "setSize" 300 200)
> * *(java frame "setLocation" 100 100)
>
> * *# ??? (java panel "add" JTextArea)
>
> * *(java frame "setVisible" T)
>
> Just the line with "???" does not, and this is the case which also has
> "???" in the original post.


You can have a look at how ABCL does it. Your java operator is called
jcall in ABCL, and it does perform some dynamic dispatch in the vein
of what javac does for method resolution; though it probably isn't
100% compatible with what the JLS specifies, it's "good enough" for
the cases we encountered so far. Some pointers:

(incomplete) documentation of ABCL's Java FFI:
http://trac.common-lisp.net/armedbear/wiki/JavaFfi

Implementation of jcall and other primitives:
http://trac.common-lisp.net/armedbea...lisp/Java.java

ABCL home page: http://common-lisp.net/project/armedbear

Cheers,
Alessio
 
Reply With Quote
 
Alexander Burger
Guest
Posts: n/a
 
      11-29-2010
Thanks Alessio. However, with the help of the previous posters to this
thread I've already got it running. I used it to solve a RosettaCode
task (though with a rather large amount of inline Java coding):

http://rosettacode.org/wiki/Image_Noise#PicoLisp

Cheers,
- Alex
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      11-29-2010
On 11/29/2010 8:47 AM, Alexander Burger wrote:
> Thanks Alessio. However, with the help of the previous posters to this
> thread I've already got it running. I used it to solve a RosettaCode
> task (though with a rather large amount of inline Java coding):
>
> http://rosettacode.org/wiki/Image_Noise#PicoLisp



What was your frames per second?


 
Reply With Quote
 
Alexander Burger
Guest
Posts: n/a
 
      11-29-2010
markspace <> wrote:
> What was your frames per second?


I measured slightly over 100 frames per second on an old
IBM ThinkPad (Pentium M)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
In a template, Eval () does not works in fields ofcontrols, it works abargaddon ASP .Net Web Controls 1 02-04-2008 09:16 PM
When I turn on my PC, it works, works, works. Problem! Fogar Computer Information 1 01-17-2006 12:57 AM
[py2exe.i18n] English works, German works, but not French. What do I miss? F. GEIGER Python 3 08-06-2004 10:01 AM
Webservice works once and then DOES NOT seem to work even though program does not crash Phi! ASP .Net Web Services 1 04-23-2004 08:42 AM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57