[armedbear-devel] How to access Java fields?

dmiles@users.sourceforge.net logicmoo at gmail.com
Wed Feb 10 11:48:52 UTC 2010


ABCL doesn't need to implement all of Allegro's API.
For instance the marshalling
(*make-dist-object*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/make-dist-object.htm>
:/*discard-in-java*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/discard-in-java.htm>)
and
connection maintainence like
*jlinker-init*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jlinker-init.htm>:
from section 2.5

Some macros like
*def-java-constructor*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/def-java-constructor.htm>
,
*def-java-method*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/def-java-method.htm>
*def-java-class*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/def-java-class.htm>are
not present in ABCL but should not be hard to create.

Here is a quick list off top of head:

 *jdesc*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jdesc.htm>:
 *Function*  (DESCRIBE-JAVA-OBJECT)
 *jarrayp*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jarrayp.htm>:
 *Function*  (missing trivial)
*jarray-ref*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jarray-ref.htm>:
 *Function*: *setf*<http://www.franz.com/support/documentation/current/ansicl/dictentr/setfpset.htm>can
be used with this function to set values in a Java array.  (complete)
*jarray-set*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jarray-set.htm>:
 *Function*: use of this function is deprecated. Use
*jarray-ref*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jarray-ref.htm>and
*setf*<http://www.franz.com/support/documentation/current/ansicl/dictentr/setfpset.htm>instead.
 (complete)
*jcall*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jcall.htm>:
 *Function*  (complete)
*jclass*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jclass.htm>:
 *Function*  (complete)
*jclass-name*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jclass-name.htm>:
 *Function*  (complete)
*jclass-of*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jclass-of.htm>:
 *Function*  (complete)
*jconstructor*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jconstructor.htm>:
 *Function*  (complete)
*jfield*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jfield.htm>:
 *Function*  (complete)
*jlinker-version*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jlinker-version.htm>:
 *Function*  (un-needed)
*jlinker-buffer-size*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jlinker-buffer-size.htm>:
 *Function* (un-needed)
*jlookup*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jlookup.htm>:
 *Generic Function* (missing)
*jmethod*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jmethod.htm>:
 *Function*  (complete)
*jnew*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jnew.htm>:
 *Function*  (complete)
*jnew-array*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jnew-array.htm>:
 *Function*  (complete)
*jstatic*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jstatic.htm>:
 *Function*  (complete)
*kcons*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/kcons.htm>:
 *Function* (missing trivial)
*kmeth*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/kmeth.htm>:
 *Function* (missing trivial)
*last-use*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/last-use.htm>:
 *Generic Function* (missing)
*make-dist-object*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/make-dist-object.htm>:
 *Generic Function* (un-needed)
*make-immediate-object*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/make-immediate-object.htm>:
 *Function*  (complete)
*jnotify-lisp*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jnotify-lisp.htm>(missing)
*jregister-handler*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jregister-handler.htm>(complete)
*jquery-handler*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/jquery-handler.htm>
 (missing)
*def-java-to-lisp-wrapper*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/def-java-to-lisp-wrapper.htm>,
*gen-output-lang*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/gen-output-lang.htm>,
and *gen-java-stream*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/gen-java-stream.htm>.
(missing)

*def-java-class*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/def-java-class.htm>can
be used to define a Lisp class which corresponds to a Java class.
(missing)

 *def-java-constructor*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/def-java-constructor.htm>allows
defining constructor functions to create instances of the classes
defined with *def-java-class*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/def-java-class.htm>.
(missing)

 The macro *def-java-method*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/def-java-method.htm>can
be used to define methods.(missing)

 *def-java-static*<http://www.franz.com/support/documentation/current/doc/operators/jlinker/def-java-static.htm>defines
static methods. (missing)


Though also through other parts of ABCL some things are easier to put in
than others.
And ABCL when used with ASM.JAR can create new java classes which has
unlimited possiblities




On Wed, Feb 10, 2010 at 3:22 AM, Blake McBride <blake at mcbride.name> wrote:

>
> I didn't realize ABCL uses Allegro's Java interface API.  Is ABCL's version
> complete (according to Allegro's docs)?
>
> Thanks.
>
> Blake McBride
>
>
> On Tue, Feb 9, 2010 at 10:02 PM, dmiles at users.sourceforge.net <
> logicmoo at gmail.com> wrote:
>
>> #'jfield
>>
>> *Arguments: **class-ref-or-field field-or-instance *&optional *instance
>> value*
>>
>> This function retrieves or modifies a field in a Java class or instance.
>>
>> The valid argument patterns for this operation are:
>>
>>    - *class-ref  field-name*: to retrieve the value of a static field.
>>    - *class-ref  field-name  instance-ref*: to retrieve the value of a
>>    class field of the instance.
>>    - *class-ref  field-name  primitive-value*: to store primitive-value
>>    in a static field.
>>    - *class-ref  field-name  instance-ref  value*: to store value in a
>>    class field of the instance.
>>    - *class-ref  field-name  nil  value*: to store value in a static
>>    field (when *value* may be confused with an instance-ref).
>>    - *field-name  instance*: to retrieve the value of a field of the
>>    instance. The class is derived from the instance.
>>    - *field-name  instance  value*: to store value in a field of the
>>    instance. The class is derived from the instance.
>>
>> See jlinker.htm<http://www.franz.com/support/documentation/current/doc/jlinker.htm>for more information.
>> .
>>
>>
>>
>>   On Tue, Feb 9, 2010 at 7:15 PM, Blake McBride <blake at mcbride.name>wrote:
>>
>>>  Greetings,
>>>
>>> I know how to gain access to and execute Java methods via jmethod and
>>> jcall, however, I don't know how to get and set instance and static fields
>>> (or variables) within a Java class.  Any help would be greatly appreciated.
>>>
>>> BTW, I've now got a Lisp macro that maps all the methods in a Java class
>>> into a corresponding CLOS class.
>>>
>>> Thanks.
>>>
>>> Blake McBride
>>>
>>>
>>> _______________________________________________
>>> armedbear-devel mailing list
>>> armedbear-devel at common-lisp.net
>>> http://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/20100210/976281d4/attachment.html>


More information about the armedbear-devel mailing list