source: trunk/abcl/test/lisp/abcl/runtime-class.lisp

Last change on this file was 14903, checked in by Mark Evenson, 5 years ago

[PATCH 4/5] Runtime class improvements (ferada)

From faceaa2be78d92b6a6c43f5925fae926f9607bce Mon Sep 17 00:00:00 2001
Work in progress to get to a more functioning runtime class support.

Make static functions and :int parameters work.
Fix return conversion for null.
Ensure that the same classloader is used.

Because otherwise the name of the superclass couldn't be found as it's
not cached anywhere.

It would probably make sense to make the normal classloader a caching
one, so that custom classes can be found by other parts of the (Java)
system?

<http://abcl.org/trac/timeline/14903>

vc:reverts <http://abcl.org/trac/changeset/14882> ;
vc:restores <http://abcl.org/trac/changeset/14858> .

File size: 1.8 KB
Line 
1(in-package :abcl.test.lisp)
2
3;; method with no arguments
4(deftest runtime-class.1
5    (java:jclass-name
6     (java:jnew-runtime-class
7      "Actor"
8      :fields '(("name" "java.lang.String" :getter NIL))
9      :methods '(("getName" "java.lang.String" NIL
10                  (lambda (this)
11                    (java:jfield "name" this))))))
12  "Actor")
13
14;; method with primitive type
15(deftest runtime-class.2
16    (java:jclass-name
17     (java:jnew-runtime-class
18      "Actor"
19      :fields '(("name" "java.lang.String" :getter NIL))
20      :methods '(("getName" "java.lang.String" (:int)
21                  (lambda (this x)
22                    (declare (ignore x))
23                    (java:jfield "name" this))))))
24  "Actor")
25
26;; inheritance of type
27(deftest runtime-class.3
28    (let ((class-loader (java::make-memory-class-loader)))
29      (java:jnew-runtime-class
30       "foo.Actor"
31       :fields '(("name" "java.lang.String"))
32       :class-loader class-loader)
33      (java:jclass-name
34       (java:jnew-runtime-class
35        "foo.StageActor"
36        :superclass "foo.Actor"
37        :fields '(("givenName" "java.lang.String"))
38        :class-loader class-loader)))
39  "foo.StageActor")
40
41;; constructor
42(deftest runtime-class.4
43    (java:jcall "getName"
44                (java:jnew
45                 (java:jnew-runtime-class
46                  "Actor"
47                  :constructors '((("java.lang.String")
48                                   (lambda (this name)
49                                     (setf (java:jfield "name" this) name))))
50                  :methods '(("getName" "java.lang.String" NIL
51                              (lambda (this)
52                                (java:jfield "name" this))))
53                  :fields '(("name" "java.lang.String" :getter NIL)))
54                 "Someone"))
55  "Someone")
Note: See TracBrowser for help on using the repository browser.