1 | (in-package :cl-user) |
---|
2 | |
---|
3 | (prove:plan 1) |
---|
4 | (prove:isnt |
---|
5 | (handler-case |
---|
6 | (java:jstatic-raw "reverseBytes" "java.lang.Short" #x7f) |
---|
7 | (error (e) (format *standard-output* "error: ~a~%" e))) |
---|
8 | nil |
---|
9 | "Calling java.lang.Short.reverseBytes(short)") |
---|
10 | |
---|
11 | (prove:plan 1) |
---|
12 | (prove:isnt |
---|
13 | (handler-case |
---|
14 | (java:jstatic-raw "valueOf" "java.lang.Byte" #x7f) |
---|
15 | (error (e) (format *standard-output* "error: ~a~%" e))) |
---|
16 | nil |
---|
17 | "Calling java.lang.Byte.valueOf(byte)") |
---|
18 | |
---|
19 | ;; <http://trac.common-lisp.net/armedbear/ticket/259> |
---|
20 | (prove:plan 1) |
---|
21 | (prove:isnt |
---|
22 | (handler-case |
---|
23 | (java:jstatic-raw "asList" "java.util.Arrays" |
---|
24 | (java:jnew-array (java:jclass "int") 1)) |
---|
25 | (error (e) (format *standard-output* "error: ~a~%" e))) |
---|
26 | nil |
---|
27 | "Calling java.util.Arrays.asList(int[1])") |
---|
28 | |
---|
29 | ;;; Begin <https://mailman.common-lisp.net/pipermail/armedbear-devel/2020-February/004037.html> |
---|
30 | ;; the following signals the "no such method" error, |
---|
31 | ;; consistent with my understanding of the intent of the new patch |
---|
32 | (prove:plan 1) |
---|
33 | (prove:is |
---|
34 | (handler-case |
---|
35 | (jstatic "reverseBytes" "java.lang.Short" 6300000) |
---|
36 | (error (e) |
---|
37 | t)) |
---|
38 | t |
---|
39 | "Dynamic static method invocation with large argument signals error") |
---|
40 | |
---|
41 | ;; however, this version does not throw [an] error, and silently narrows |
---|
42 | ;; 63000[0] the value to a short |
---|
43 | (prove:plan 1) |
---|
44 | (prove:is |
---|
45 | (handler-case |
---|
46 | (let ((method |
---|
47 | (jmethod "java.lang.Short" "reverseBytes" "short"))) |
---|
48 | (jstatic method nil 6300000)) |
---|
49 | (error (e) |
---|
50 | t)) |
---|
51 | t |
---|
52 | "Explicit static method invocation with large argument signals error") |
---|
53 | |
---|
54 | (prove:plan 1) |
---|
55 | (prove:is |
---|
56 | (handler-case |
---|
57 | (let ((buffer (jstatic-raw "allocate" "java.nio.ByteBuffer" 1)) |
---|
58 | (value #xf0)) ;; a "byte" between 127 and 255 |
---|
59 | (jcall "put" buffer value) |
---|
60 | (= value |
---|
61 | (+ 256 (jcall "get" buffer 0)))) |
---|
62 | (error (e) |
---|
63 | nil)) |
---|
64 | t |
---|
65 | "Invoking method with a byte value between 127 and 255") |
---|
66 | |
---|
67 | ;;; end <https://mailman.common-lisp.net/pipermail/armedbear-devel/2020-February/004037.html> |
---|
68 | |
---|
69 | (prove:finalize) |
---|
70 | |
---|
71 | |
---|