Mike Schilling said:
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.