Libraryless. Click here for Pure Java version (7032L/49K/165K).
1 | !7 |
2 | |
3 | sbool usePrimaryPort = true; |
4 | static new Flag taken; |
5 | static Android3 android; |
6 | static Lock lock = lock(); |
7 | |
8 | p { |
9 | if (usePrimaryPort) |
10 | android = androidAtPrecisePort(preSpunVMPort(), "A pre-spun VM.", mc()); |
11 | if (android != null) |
12 | print("Using primary port!"); |
13 | else { |
14 | print("Using regular port."); |
15 | android = makeAndroid3("A pre-spun VM."); |
16 | } |
17 | hideVM(); |
18 | taken.waitUntilUp(); |
19 | } |
20 | |
21 | static S answer(S s, L<S> history) { |
22 | lock lock; |
23 | new Matches m; |
24 | |
25 | if (match3("please start program *", s, m)) { |
26 | final S progID = formatSnippetID(unquote(m.m[0])); |
27 | return startIt(progID, ""); |
28 | } |
29 | |
30 | if (match3("please start program * with arguments *", s, m)) { |
31 | final S progID = formatSnippetID(unquote(m.m[0])); |
32 | final S args = unquote(m.m[1]); |
33 | return startIt(progID, args); |
34 | } |
35 | |
36 | if (match3("are you free to start a program?", s)) |
37 | ret !taken.isUp() ? "Yes." : "No."; |
38 | |
39 | ret null; |
40 | } |
41 | |
42 | static S startIt(final S progID, S args) { |
43 | lock lock; |
44 | if (taken.isUp()) ret "Sorry, not free anymore."; |
45 | taken.raise(); |
46 | |
47 | // Remove my injection (without cleanup) so program becomes first injection |
48 | synchronized(javax()) { |
49 | L injections = (L) get(javax(), 'injectable_programsInjected); |
50 | injections.remove(0); |
51 | } |
52 | |
53 | final S[] splitArgs = toStringArray(codeTokensOnly(javaTok(args))); // yeah this is bad... |
54 | |
55 | thread { |
56 | Class c = hotwire(progID); |
57 | callMain(c, splitArgs); |
58 | } |
59 | |
60 | thread { |
61 | setConsoleTitle(snippetTitle(progID)); |
62 | } |
63 | |
64 | if (android != null) { |
65 | android.dispose(); |
66 | android = null; |
67 | } |
68 | |
69 | if (usePreSpunVMs()) startPreSpunVM(); // Start another one |
70 | |
71 | unhideVM(); |
72 | |
73 | ret "OK."; |
74 | } |
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, dhtvkmknsjym, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001361 |
Snippet name: | Pre-spun VM (still not perfect) |
Eternal ID of this version: | #1001361/15 |
Text MD5: | 5f6797051379a31edb9b8602b41d5985 |
Transpilation MD5: | 02649ab22edfc896da60eb29ea481a35 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-11-17 04:04:24 |
Source code size: | 1726 bytes / 74 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 732 / 2035 |
Version history: | 14 change(s) |
Referenced in: | [show references] |