Function | Package: net.jlinker | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version

## jclass-of

Arguments: object &optional name

This function returns the name of the Java class or verifies that a remote reference is to an instance of a specified class. This operation does not require a round-trip to Java.

The first argument should be a remote reference to a Java class instance. If the second argument is omitted, the value returned is a string that names the class of the Java object. If the second argument is specified, it must be coercible to a string; the value returned is the result of comparing the class name to the second argument.

If the first argument is a Lisp string, it is treated as an instance of the Java class "java.lang.String".

If the first argument is neither a string nor a remote reference, then the function returns `nil`.

A second value is always returned, the name of the class or `nil`.

### Programming note

In the following example (taken from the jLinker servlet sample)

    (let (out println)
        (setf out (jcall "getWriter" response))
        (setf println (jmeth (jclass-of out) "println" "java.lang.String"))
        ...)

we are retrieving the "println" method of some arbitrary Java class. This code will not work if the Java VM security profile does not allow access by name to the class of the object referenced by out.

The code below appears to work in these cases

    (let (out println)
        (setf out (jcall "getWriter" response))
        (setf println (jmeth (jcall "getClass" out)
                        "println" "java.lang.String"))
        ...)

because the method is retrieved from the class object itself.

See jlinker.htm for more information on the jLinker facility.

Copyright (c) 1998-2022, Franz Inc. Lafayette, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2019.8.20.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version