Uses 911K of libraries. Click here for Pure Java version (2149L/12K).
1 | !7 |
2 | |
3 | sinterface MyInterface {
|
4 | S hello(); |
5 | } |
6 | |
7 | sclass MyImpl {
|
8 | S hello() { ret "hello"; }
|
9 | S hello2() { ret "hello2"; }
|
10 | } |
11 | |
12 | cprint {
|
13 | start-thread {
|
14 | MyInterface proxy = proxy(new MyImpl, MyInterface); |
15 | assertEqualsVerbose("hello", proxy.hello());
|
16 | |
17 | // reflectively calling a method on a proxy is OK |
18 | // - if the method is in the interface |
19 | assertEqualsVerbose("hello", call(proxy, "hello"));
|
20 | |
21 | // Random method calls, OTOH, are not forwarded to the |
22 | // proxied object. |
23 | assertFailsVerbose(r { call(proxy, "hello2") });
|
24 | |
25 | // But of course we can extract the proxied object and call its methods. |
26 | O proxied = getProxiedObject(proxy); |
27 | assertEqualsVerbose("hello2", call(proxied, "hello2"));
|
28 | } |
29 | } |
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1029851 |
| Snippet name: | using call() on proxy objects test (OK) |
| Eternal ID of this version: | #1029851/6 |
| Text MD5: | 41d85fb25ec550beb2fe23758b8b572e |
| Transpilation MD5: | 17d1fb94bacf3ea08593061cbe37c6a3 |
| Author: | stefan |
| Category: | javax / web |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-09-23 11:27:09 |
| Source code size: | 771 bytes / 29 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 462 / 597 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |