# HG changeset patch
# Parent 37aa1a7887b0dfe4ebf74cf79d91d82eea221ce1
(WIP) Fix compilation for SYS:RUN-PROGRAM on JDK-6
diff -r 37aa1a7887b0 build.xml
a
|
b
|
|
68 | 68 | <include name="org/armedbear/lisp/scripting/*.java" if="abcl.jsr-223.p"/> |
69 | 69 | <include name="org/armedbear/lisp/scripting/util/*.java" if="abcl.jsr-223.p"/> |
70 | 70 | <include name="org/armedbear/Main.java"/> |
| 71 | <include name="org/abcl/**/*.java"/> |
71 | 72 | </patternset> |
72 | 73 | |
73 | 74 | <patternset id="abcl.source.lisp"> |
diff -r 37aa1a7887b0 src/org/abcl/util/ASyncIO.java
-
|
+
|
|
| 1 | package org.abcl.util; |
| 2 | |
| 3 | import java.util.concurrent.ThreadPoolExecutor; |
| 4 | import java.util.concurrent.TimeUnit; |
| 5 | import java.util.concurrent.BlockingQueue; |
| 6 | import java.util.concurrent.SynchronousQueue; |
| 7 | |
| 8 | public class ASyncIO |
| 9 | { |
| 10 | static int poolSize = 1; |
| 11 | static int minPoolSize = 1; |
| 12 | static long keepAlive = 256; |
| 13 | static TimeUnit keepAliveUnit = TimeUnit.DAYS; |
| 14 | static BlockingQueue<Runnable> queue = null; |
| 15 | |
| 16 | static ThreadPoolExecutor pool = null; |
| 17 | |
| 18 | public ASyncIO() { |
| 19 | if (queue == null) { |
| 20 | queue = new SynchronousQueue(); |
| 21 | pool = new ThreadPoolExecutor(poolSize, minPoolSize, keepAlive, keepAliveUnit, |
| 22 | queue); |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
diff -r 37aa1a7887b0 src/org/abcl/util/StreamTask.java
-
|
+
|
|
| 1 | package org.abcl.util; |
| 2 | |
| 3 | public class StreamTask |
| 4 | implements Runnable |
| 5 | { |
| 6 | public void run() { |
| 7 | int i = 42; |
| 8 | } |
| 9 | } |
diff -r 37aa1a7887b0 src/org/armedbear/lisp/run-program.lisp
a
|
b
|
|
163 | 163 | process)))) |
164 | 164 | |
165 | 165 | (defconstant +inherit+ |
166 | | (java:jfield "java.lang.ProcessBuilder$Redirect" "INHERIT")) |
| 166 | (ignore-errors |
| 167 | (java:jfield "java.lang.ProcessBuilder$Redirect" "INHERIT"))) |
| 168 | |
| 169 | (defun jvm7-p () |
| 170 | (not (null +inherit+))) |
167 | 171 | |
168 | 172 | (defun coerce-to-file (value) |
169 | 173 | (java:jnew |
… |
… |
|
179 | 183 | (error "Don't know how to set up null stream on this platform.")))))) |
180 | 184 | |
181 | 185 | (defun setup-input-redirection (process-builder value if-does-not-exist) |
| 186 | "Returns boolean truth when input redirections has been successfully set up. |
| 187 | |
| 188 | As a second value, returns either nil if input should inherit from the |
| 189 | parent process, or a java.io.File reference to the file to read input from." |
182 | 190 | (let ((redirect (if (eq value T) |
183 | | +inherit+ |
| 191 | (when (jvm7-p) +inherit+) |
184 | 192 | (let ((file (coerce-to-file value))) |
185 | 193 | (when value |
186 | 194 | (if (eq if-does-not-exist :create) |
… |
… |
|
189 | 197 | (ecase if-does-not-exist |
190 | 198 | (:error (error "Input file ~S does not exist." value)) |
191 | 199 | ((NIL) (return-from setup-input-redirection)))))) |
192 | | (java:jstatic "from" "java.lang.ProcessBuilder$Redirect" file))))) |
193 | | (java:jcall "redirectInput" process-builder redirect)) |
194 | | T) |
| 200 | (if (jvm7-p) |
| 201 | (java:jstatic "from" "java.lang.ProcessBuilder$Redirect" file) |
| 202 | file))))) |
| 203 | |
| 204 | (when (jvm7-p) |
| 205 | (java:jcall "redirectInput" process-builder redirect)) |
| 206 | (values t redirect))) |
195 | 207 | |
196 | 208 | (defun setup-output-redirection (process-builder value errorp if-does-exist) |
197 | 209 | (let ((redirect (if (eq value T) |
198 | | +inherit+ |
| 210 | (when (jvm7-p) +inherit+) |
199 | 211 | (let ((file (coerce-to-file value)) |
200 | 212 | appendp) |
201 | 213 | (when (and value (probe-file value)) |
… |
… |
|
207 | 219 | :if-exists if-does-exist))) |
208 | 220 | (:append (setf appendp T)) |
209 | 221 | ((NIL) (return-from setup-output-redirection)))) |
210 | | (if appendp |
211 | | (java:jstatic "appendTo" "java.lang.ProcessBuilder$Redirect" file) |
212 | | (java:jstatic "to" "java.lang.ProcessBuilder$Redirect" file)))))) |
213 | | (if errorp |
214 | | (java:jcall "redirectError" process-builder redirect) |
215 | | (java:jcall "redirectOutput" process-builder redirect))) |
216 | | T) |
| 222 | (if (jvm7-p) |
| 223 | (if appendp |
| 224 | (java:jstatic "appendTo" "java.lang.ProcessBuilder$Redirect" file) |
| 225 | (java:jstatic "to" "java.lang.ProcessBuilder$Redirect" file)) |
| 226 | (list file appendp)))))) |
| 227 | (when (jvm7-p) |
| 228 | (if errorp |
| 229 | (java:jcall "redirectError" process-builder redirect) |
| 230 | (java:jcall "redirectOutput" process-builder redirect))) |
| 231 | (values t redirect errorp))) |
217 | 232 | |
218 | 233 | ;;; The process structure. |
219 | 234 | (defstruct (process (:constructor %make-process (jprocess))) |