Changes between Version 4 and Version 5 of JavaFfi
- Timestamp:
- 11/04/10 21:17:12 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
JavaFfi
v4 v5 9 9 The core API is based on Java reflection. Some operators come in two flavors: a concise one that leaves some things to be computed by ABCL at runtime, and a more efficient and verbose one, which is mostly a direct translation of the Java reflection API. 10 10 11 === Definitions === 12 13 * ''Java class designator'': either a string denoting the fully qualified name of a Java class, such as "java.lang.String", or a Java class metaobject, that is, an instance of java.lang.Class, for example as returned by the function `jclass`. 14 * ''Java method designator'': in the context of Java method invocations, either a Java method metaobject (an instance of java.lang.reflect.Method), or a string representing the name of the method, for example "toString". 15 11 16 === Function JCALL, JCALL-RAW === 12 17 13 18 '''Syntax:''' 14 19 15 '''jcall''' ''method instance &rest args => T''16 17 '''jcall-raw''' ''method instance &rest args => T''20 '''jcall''' ''method instance &rest args => object'' 21 22 '''jcall-raw''' ''method instance &rest args => a JAVA-OBJECT'' 18 23 19 24 '''Arguments and Values:''' … … 44 49 '''Syntax:''' 45 50 46 '''jclass''' ''name-or-class-ref &optional class-loader => Java class metaobject''51 '''jclass''' ''name-or-class-ref &optional class-loader => a Java class metaobject'' 47 52 48 53 '''Arguments and Values:''' 49 54 50 `name-or-class-ref` -- a Java class designator , that is, a Java class metaobject (an instance of java.lang.Class), or a string representing the fully qualified name of the Java class, for example "java.lang.Object".55 `name-or-class-ref` -- a Java class designator (see [#Definitions Definitions]). 51 56 52 57 `class-loader` -- the classloader to use to resolve the class. Refer to the section Class resolution and loading. … … 59 64 60 65 `(jclass "java.util.LinkedList") => #<java.lang.Class class java.util.LinkedList {11B50A1}>` 66 67 === Function JSTATIC, JSTATIC-RAW === 68 69 '''Syntax:''' 70 71 '''jstatic''' ''method class &rest args => object'' 72 73 '''jstatic-raw''' ''method class &rest args => JAVA-OBJECT'' 74 75 '''Arguments and Values:''' 76 77 `method` -- a Java method designator. 78 79 `class` -- a Java class metaobject. 80 81 `args` -- the arguments passed to the method. 82 83 '''Description:''' 84 85 Reflectively calls a static method and returns the result of the call. `(jstatic method class args)` is equivalent to `(jcall (jmethod class method) nil args)` when `method` is a string, and to `(jcall method nil args)` when `method` is a Java method metaobject (class is thus ignored in that case). Similarly for the `-raw` variants. 86 87 `jstatic` translates the result to a Lisp object if possible. `jstatic-raw` performs no translation and always returns the original Java object. 88 89 '''Examples:''' 90 91 {{{ 92 (jstatic "getRuntime" "java.lang.Runtime") => #<java.lang.Runtime java.lang.Runtime@1ef3212 {C07527}> 93 (jstatic-raw "getRuntime" "java.lang.Runtime") => #<java.lang.Runtime java.lang.Runtime@1ef3212 {156D7C8}> 94 (jstatic "getRuntime" (jclass "java.lang.Runtime")) => #<java.lang.Runtime java.lang.Runtime@1ef3212 {C8E4DE}> 95 (jstatic (jmethod "java.lang.Runtime" "getRuntime") nil) => #<java.lang.Runtime java.lang.Runtime@1ef3212 {129DF8A}> 96 }}} 61 97 62 98 == Class resolution and loading ==