Commit b799800
authored
Implement Lock and ReentrantLock APIs (#4344)
* Implement Lock and ReentrantLock APIs in JavaAPI
Implemented `java.util.concurrent.locks.Lock` and `java.util.concurrent.locks.ReentrantLock` interfaces and classes in `vm/JavaAPI`.
Added `java.util.concurrent.TimeUnit`.
Updated `java.lang.Thread` with `interrupt0`, `sleep(long, int)` and updated `join` implementation.
Added integration tests in `vm/tests` to verify locking behavior using the BytecodeTranslator.
* Implement Lock and ReentrantLock APIs in vm/JavaAPI
- Added `java.util.concurrent.locks.Lock` and `java.util.concurrent.locks.ReentrantLock`.
- Added `java.util.concurrent.TimeUnit`.
- Updated `java.lang.Thread` with `interrupt0`, `sleep(long, int)` and improved `join` logic.
- Created `vm/tests/src/test/java/com/codename1/tools/translator/LockIntegrationTest.java` to verify concurrency primitives using ByteCodeTranslator integration tests.
- Provided native stubs for missing JavaSE methods in the test environment to ensure linker success.
* Implement Lock and ReentrantLock APIs in vm/JavaAPI
- Added `java.util.concurrent.locks.Lock` interface.
- Added `java.util.concurrent.locks.ReentrantLock` implementation.
- Added `java.util.concurrent.locks.Condition` interface.
- Added `java.util.concurrent.TimeUnit` enum.
- Updated `java.lang.Thread` with `interrupt0`, `sleep`, `join` support.
- Added `LockIntegrationTest` in `vm/tests` to verify bytecode translation of new APIs.
* Implement Lock and ReentrantLock APIs in vm/JavaAPI
- Added `java.util.concurrent.locks.Lock` interface.
- Added `java.util.concurrent.locks.ReentrantLock` implementation.
- Added `java.util.concurrent.locks.Condition` interface.
- Added `java.util.concurrent.TimeUnit` enum.
- Updated `java.lang.Thread` with `interrupt0`, `sleep`, `join` support.
- Added `LockIntegrationTest` in `vm/tests` to verify bytecode translation of new APIs.
* Implement Lock and ReentrantLock APIs in vm/JavaAPI
- Added `java.util.concurrent.locks.Lock` interface.
- Added `java.util.concurrent.locks.ReentrantLock` implementation.
- Added `java.util.concurrent.locks.Condition` interface.
- Added `java.util.concurrent.TimeUnit` enum.
- Updated `java.lang.Thread` with `interrupt0`, `sleep`, `join` support.
- Added `LockIntegrationTest` in `vm/tests` to verify bytecode translation of new APIs.
- Fixed spin loop in `ReentrantLock.lock()` when interrupted.
- Fixed integration test setup to avoid conflicting native stubs.
* Implement Lock and ReentrantLock APIs in vm/JavaAPI
- Added `java.util.concurrent.locks.Lock` interface.
- Added `java.util.concurrent.locks.ReentrantLock` implementation.
- Added `java.util.concurrent.locks.Condition` interface.
- Added `java.util.concurrent.TimeUnit` enum.
- Updated `java.lang.Thread` with `interrupt0`, `sleep`, `join` support.
- Added `LockIntegrationTest` in `vm/tests` to verify bytecode translation of new APIs.
- Fixed spin loop in `ReentrantLock.lock()` when interrupted.
- Fixed integration test setup to avoid conflicting native stubs.
- Implemented `java_lang_Thread_interrupt0__` and `java_lang_Thread_isInterrupted` in `vm/ByteCodeTranslator/src/nativeMethods.m` to resolve iOS linker errors.
- Added `interrupted` field to `ThreadLocalData` struct in `cn1_globals.h`.
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>1 parent fb40429 commit b799800
File tree
8 files changed
+1243
-4
lines changed- vm
- ByteCodeTranslator/src
- JavaAPI/src/java
- lang
- util/concurrent
- locks
- tests/src/test/java/com/codename1/tools/translator
8 files changed
+1243
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
789 | 789 | | |
790 | 790 | | |
791 | 791 | | |
| 792 | + | |
792 | 793 | | |
793 | 794 | | |
794 | 795 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1090 | 1090 | | |
1091 | 1091 | | |
1092 | 1092 | | |
| 1093 | + | |
1093 | 1094 | | |
1094 | 1095 | | |
1095 | 1096 | | |
| |||
1461 | 1462 | | |
1462 | 1463 | | |
1463 | 1464 | | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
1464 | 1499 | | |
1465 | 1500 | | |
1466 | 1501 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
127 | 140 | | |
128 | 141 | | |
129 | 142 | | |
| |||
135 | 148 | | |
136 | 149 | | |
137 | 150 | | |
138 | | - | |
139 | | - | |
140 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
141 | 175 | | |
142 | 176 | | |
143 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
144 | 191 | | |
145 | 192 | | |
146 | 193 | | |
| |||
155 | 202 | | |
156 | 203 | | |
157 | 204 | | |
158 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
159 | 209 | | |
160 | 210 | | |
161 | 211 | | |
| |||
183 | 233 | | |
184 | 234 | | |
185 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
186 | 249 | | |
187 | 250 | | |
188 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments