Remove Unix-specific classes (#227)

This commit is contained in:
Michiel Borkent 2020-01-08 11:48:40 +01:00 committed by GitHub
parent 6633d8b674
commit 2b0cb6fb1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 174 additions and 172 deletions

View file

@ -52,7 +52,7 @@ jobs:
mkdir -p /tmp/release mkdir -p /tmp/release
lein do clean, uberjar lein do clean, uberjar
VERSION=$(cat resources/BABASHKA_VERSION) VERSION=$(cat resources/BABASHKA_VERSION)
cp target/babashka-$VERSION-standalone.jar /tmp/release/babashka-$VERSION-linux-standalone.jar cp target/babashka-$VERSION-standalone.jar /tmp/release/babashka-$VERSION-standalone.jar
- store_artifacts: - store_artifacts:
path: /tmp/release path: /tmp/release
destination: release destination: release

2
sci

@ -1 +1 @@
Subproject commit d9e6d7396374631731a9cc7b11dedb41281e867d Subproject commit 1374d2a37b64e3d2216349345ff930b1154e39b3

View file

@ -2,172 +2,166 @@
{:no-doc true} {:no-doc true}
(:require (:require
[cheshire.core :as json] [cheshire.core :as json]
[clojure.string :as str])) #_[clojure.string :as str]))
(def os-name (str/lower-case (System/getProperty "os.name"))) ;; (def os-name (str/lower-case (System/getProperty "os.name")))
(def os (cond (str/includes? os-name "mac") :mac ;; (def os (cond (str/includes? os-name "mac") :mac
(or (str/includes? os-name "nix") ;; (or (str/includes? os-name "nix")
(str/includes? os-name "nux")) :linux ;; (str/includes? os-name "nux")) :linux
(str/includes? os-name "win") :windows)) ;; (str/includes? os-name "win") :windows))
(def unix-like? (or (identical? os :linux) ;; (def unix-like? (or (identical? os :linux)
(identical? os :mac))) ;; (identical? os :mac)))
(def classes (def classes
(cond-> '{:all [java.io.BufferedReader
'{:all [java.io.BufferedReader java.io.BufferedWriter
java.io.BufferedWriter java.io.ByteArrayInputStream
java.io.ByteArrayInputStream java.io.ByteArrayOutputStream
java.io.ByteArrayOutputStream java.io.File
java.io.File java.io.InputStream
java.io.InputStream java.io.IOException
java.io.IOException java.io.OutputStream
java.io.OutputStream java.io.StringReader
java.io.StringReader java.io.StringWriter
java.io.StringWriter java.lang.ArithmeticException
java.lang.ArithmeticException java.lang.AssertionError
java.lang.AssertionError java.lang.Boolean
java.lang.Boolean java.lang.Class
java.lang.Class java.lang.Double
java.lang.Double java.lang.Exception
java.lang.Exception java.lang.Integer
java.lang.Integer java.lang.Math
java.lang.Math java.util.concurrent.LinkedBlockingQueue
java.util.concurrent.LinkedBlockingQueue java.lang.Object
java.lang.Object java.lang.String
java.lang.String java.lang.System
java.lang.System java.lang.Throwable
java.lang.Throwable java.lang.Process
java.lang.Process java.lang.ProcessBuilder
java.lang.ProcessBuilder java.lang.ProcessBuilder$Redirect
java.lang.ProcessBuilder$Redirect java.net.URI
java.net.URI java.net.HttpURLConnection
java.net.HttpURLConnection java.net.ServerSocket
java.net.ServerSocket java.net.Socket
java.net.Socket java.net.UnknownHostException
java.net.UnknownHostException java.net.URLEncoder
java.net.URLEncoder java.net.URLDecoder
java.net.URLDecoder java.nio.file.CopyOption
java.nio.file.CopyOption java.nio.file.FileAlreadyExistsException
java.nio.file.FileAlreadyExistsException java.nio.file.Files
java.nio.file.Files java.nio.file.LinkOption
java.nio.file.LinkOption java.nio.file.NoSuchFileException
java.nio.file.NoSuchFileException java.nio.file.Path
java.nio.file.Path java.nio.file.Paths
java.nio.file.Paths java.nio.file.StandardCopyOption
java.nio.file.StandardCopyOption java.nio.file.attribute.FileAttribute
java.nio.file.attribute.FileAttribute java.nio.file.attribute.FileTime
java.nio.file.attribute.FileTime java.nio.file.attribute.PosixFilePermission
java.nio.file.attribute.PosixFilePermission java.nio.file.attribute.PosixFilePermissions
java.nio.file.attribute.PosixFilePermissions java.time.format.DateTimeFormatter
java.time.format.DateTimeFormatter java.time.Clock
java.time.Clock java.time.DateTimeException
java.time.DateTimeException java.time.DayOfWeek
java.time.DayOfWeek java.time.Duration
java.time.Duration java.time.Instant
java.time.Instant java.time.LocalDate
java.time.LocalDate java.time.LocalDateTime
java.time.LocalDateTime java.time.LocalTime
java.time.LocalTime java.time.Month
java.time.Month java.time.MonthDay
java.time.MonthDay java.time.OffsetDateTime
java.time.OffsetDateTime java.time.OffsetTime
java.time.OffsetTime java.time.Period
java.time.Period java.time.Year
java.time.Year java.time.YearMonth
java.time.YearMonth java.time.ZonedDateTime
java.time.ZonedDateTime java.time.ZoneId
java.time.ZoneId java.time.ZoneOffset
java.time.ZoneOffset java.time.temporal.TemporalAccessor
java.time.temporal.TemporalAccessor java.util.regex.Pattern
java.util.regex.Pattern java.util.Base64
java.util.Base64 java.util.Base64$Decoder
java.util.Base64$Decoder java.util.Base64$Encoder
java.util.Base64$Encoder java.util.Date
java.util.Date java.util.UUID
java.util.UUID java.util.concurrent.TimeUnit
java.util.concurrent.TimeUnit java.util.zip.InflaterInputStream
java.util.zip.InflaterInputStream java.util.zip.DeflaterInputStream
java.util.zip.DeflaterInputStream java.util.zip.GZIPInputStream
java.util.zip.GZIPInputStream java.util.zip.GZIPOutputStream]
java.util.zip.GZIPOutputStream] :constructors [clojure.lang.Delay
:constructors [clojure.lang.Delay clojure.lang.MapEntry
clojure.lang.MapEntry clojure.lang.LineNumberingPushbackReader]
clojure.lang.LineNumberingPushbackReader] :methods [borkdude.graal.LockFix ;; support for locking
:methods [borkdude.graal.LockFix ;; support for locking ]
] :fields [clojure.lang.PersistentQueue]
:fields [clojure.lang.PersistentQueue] :instance-checks [clojure.lang.ExceptionInfo
:instance-checks [clojure.lang.ExceptionInfo clojure.lang.IObj
clojure.lang.IObj clojure.lang.IEditableCollection]
clojure.lang.IEditableCollection] :custom {clojure.lang.LineNumberingPushbackReader {:allPublicConstructors true
:custom {clojure.lang.LineNumberingPushbackReader {:allPublicConstructors true :allPublicMethods true}
:allPublicMethods true} java.lang.Thread
java.lang.Thread {:allPublicConstructors true
{:allPublicConstructors true ;; generated with `public-declared-method-names`, see in
;; generated with `public-declared-method-names`, see in ;; `comment` below
;; `comment` below :methods [{:name "activeCount"}
:methods [{:name "activeCount"} {:name "checkAccess"}
{:name "checkAccess"} {:name "currentThread"}
{:name "currentThread"} {:name "dumpStack"}
{:name "dumpStack"} {:name "enumerate"}
{:name "enumerate"} {:name "getAllStackTraces"}
{:name "getAllStackTraces"} {:name "getContextClassLoader"}
{:name "getContextClassLoader"} {:name "getDefaultUncaughtExceptionHandler"}
{:name "getDefaultUncaughtExceptionHandler"} {:name "getId"}
{:name "getId"} {:name "getName"}
{:name "getName"} {:name "getPriority"}
{:name "getPriority"} {:name "getStackTrace"}
{:name "getStackTrace"} {:name "getState"}
{:name "getState"} {:name "getThreadGroup"}
{:name "getThreadGroup"} {:name "getUncaughtExceptionHandler"}
{:name "getUncaughtExceptionHandler"} {:name "holdsLock"}
{:name "holdsLock"} {:name "interrupt"}
{:name "interrupt"} {:name "interrupted"}
{:name "interrupted"} {:name "isAlive"}
{:name "isAlive"} {:name "isDaemon"}
{:name "isDaemon"} {:name "isInterrupted"}
{:name "isInterrupted"} {:name "join"}
{:name "join"} {:name "run"}
{:name "run"} {:name "setContextClassLoader"}
{:name "setContextClassLoader"} {:name "setDaemon"}
{:name "setDaemon"} {:name "setDefaultUncaughtExceptionHandler"}
{:name "setDefaultUncaughtExceptionHandler"} {:name "setName"}
{:name "setName"} {:name "setPriority"}
{:name "setPriority"} {:name "setUncaughtExceptionHandler"}
{:name "setUncaughtExceptionHandler"} {:name "sleep"}
{:name "sleep"} {:name "start"}
{:name "start"} {:name "toString"}
{:name "toString"} {:name "yield"}]}
{:name "yield"}]} java.net.URL
java.net.URL {:allPublicConstructors true
{:allPublicConstructors true :allPublicFields true
:allPublicFields true ;; generated with `public-declared-method-names`, see in
;; generated with `public-declared-method-names`, see in ;; `comment` below
;; `comment` below :methods [{:name "equals"}
:methods [{:name "equals"} {:name "getAuthority"}
{:name "getAuthority"} {:name "getContent"}
{:name "getContent"} {:name "getDefaultPort"}
{:name "getDefaultPort"} {:name "getFile"}
{:name "getFile"} {:name "getHost"}
{:name "getHost"} {:name "getPath"}
{:name "getPath"} {:name "getPort"}
{:name "getPort"} {:name "getProtocol"}
{:name "getProtocol"} {:name "getQuery"}
{:name "getQuery"} {:name "getRef"}
{:name "getRef"} {:name "getUserInfo"}
{:name "getUserInfo"} {:name "hashCode"}
{:name "hashCode"} {:name "openConnection"}
{:name "openConnection"} {:name "openStream"}
{:name "openStream"} {:name "sameFile"}
{:name "sameFile"} ;; not supported: {:name "setURLStreamHandlerFactory"}
;; not supported: {:name "setURLStreamHandlerFactory"} {:name "toExternalForm"}
{:name "toExternalForm"} {:name "toString"}
{:name "toString"} {:name "toURI"}]}}})
{:name "toURI"}]}}}
unix-like? (->
(update :methods conj 'sun.nio.fs.UnixPath)
(update :all conj
'java.lang.UNIXProcess
'java.lang.UNIXProcess$ProcessPipeOutputStream))))
(defmacro gen-class-map [] (defmacro gen-class-map []
(let [classes (concat (:all classes) (let [classes (concat (:all classes)
@ -175,11 +169,17 @@
(:constructors classes) (:constructors classes)
(:methods classes) (:methods classes)
(:fields classes) (:fields classes)
(:instance-checks classes))] (:instance-checks classes))
(apply hash-map m (apply hash-map
(for [c classes (for [c classes
c [(list 'quote c) c]] c [(list 'quote c) c]]
c)))) c))]
(assoc m :public-class
(fn [v]
(cond (instance? java.nio.file.Path v)
java.nio.file.Path
(instance? java.lang.Process v)
java.lang.Process)))))
(def class-map (gen-class-map)) (def class-map (gen-class-map))

View file

@ -169,6 +169,8 @@
(deftest process-builder-test (deftest process-builder-test
(is (str/includes? (bb nil " (is (str/includes? (bb nil "
(def ls (-> (ProcessBuilder. [\"ls\"]) (.start))) (def ls (-> (ProcessBuilder. [\"ls\"]) (.start)))
(def input (.getOutputStream ls))
(.write (io/writer input) \"hello\") ;; dummy test just to see if this works
(def output (.getInputStream ls)) (def output (.getInputStream ls))
(assert (int? (.waitFor ls))) (assert (int? (.waitFor ls)))
(slurp output)") (slurp output)")
@ -281,8 +283,8 @@
f2 (.toFile p')] f2 (.toFile p')]
(bb nil (format (bb nil (format
"(let [f (io/file \"%s\") "(let [f (io/file \"%s\")
p (.toPath (io/file f)) p (.toPath (io/file f))
p' (.resolveSibling p \"f2\")] p' (.resolveSibling p \"f2\")]
(.delete (.toFile p')) (.delete (.toFile p'))
(dotimes [_ 2] (dotimes [_ 2]
(try (try