Use GraalVM 22.3.1 on JDK 19.0.2 with virtual thread support (#1500)
This commit is contained in:
parent
332c7c6ac8
commit
3ad043769c
15 changed files with 110 additions and 82 deletions
|
|
@ -80,7 +80,7 @@
|
||||||
:working_directory "~/repo"
|
:working_directory "~/repo"
|
||||||
:environment {:LEIN_ROOT "true"
|
:environment {:LEIN_ROOT "true"
|
||||||
:BABASHKA_PLATFORM "linux"
|
:BABASHKA_PLATFORM "linux"
|
||||||
:GRAALVM_VERSION "22.3.0"
|
:GRAALVM_VERSION "22.3.1"
|
||||||
:GRAALVM_HOME graalvm-home}
|
:GRAALVM_HOME graalvm-home}
|
||||||
:resource_class "large"
|
:resource_class "large"
|
||||||
:steps
|
:steps
|
||||||
|
|
@ -119,7 +119,7 @@ java -jar \"$jar\" --config .build/bb.edn --deps-root . release-artifact \"$refl
|
||||||
(defn unix
|
(defn unix
|
||||||
[shorted? static? musl? arch executor-conf resource-class graalvm-home platform]
|
[shorted? static? musl? arch executor-conf resource-class graalvm-home platform]
|
||||||
(let [env {:LEIN_ROOT "true"
|
(let [env {:LEIN_ROOT "true"
|
||||||
:GRAALVM_VERSION "22.3.0"
|
:GRAALVM_VERSION "22.3.1"
|
||||||
:GRAALVM_HOME graalvm-home
|
:GRAALVM_HOME graalvm-home
|
||||||
:BABASHKA_PLATFORM (if (= "mac" platform)
|
:BABASHKA_PLATFORM (if (= "mac" platform)
|
||||||
"macos"
|
"macos"
|
||||||
|
|
@ -175,7 +175,7 @@ java -jar \"$jar\" --config .build/bb.edn --deps-root . release-artifact \"$refl
|
||||||
{:persist_to_workspace {:root "/tmp"
|
{:persist_to_workspace {:root "/tmp"
|
||||||
:paths ["release"]}}
|
:paths ["release"]}}
|
||||||
{:save_cache
|
{:save_cache
|
||||||
{:paths ["~/.m2" "~/graalvm-ce-java11-22.3.0"]
|
{:paths ["~/.m2" "~/graalvm-ce-java19-22.3.1"]
|
||||||
:key cache-key}}
|
:key cache-key}}
|
||||||
{:store_artifacts {:path "/tmp/release"
|
{:store_artifacts {:path "/tmp/release"
|
||||||
:destination "release"}}
|
:destination "release"}}
|
||||||
|
|
@ -187,8 +187,8 @@ java -jar \"$jar\" --config .build/bb.edn --deps-root . release-artifact \"$refl
|
||||||
(let [docker-executor-conf {:docker [{:image "circleci/clojure:openjdk-11-lein-2.9.8-bullseye"}]}
|
(let [docker-executor-conf {:docker [{:image "circleci/clojure:openjdk-11-lein-2.9.8-bullseye"}]}
|
||||||
machine-executor-conf {:machine {:image "ubuntu-2004:202111-01"}}
|
machine-executor-conf {:machine {:image "ubuntu-2004:202111-01"}}
|
||||||
mac-executor-conf {:macos {:xcode "14.0.0"}}
|
mac-executor-conf {:macos {:xcode "14.0.0"}}
|
||||||
linux-graalvm-home "/home/circleci/graalvm-ce-java11-22.3.0"
|
linux-graalvm-home "/home/circleci/graalvm-ce-java19-22.3.1"
|
||||||
mac-graalvm-home "/Users/distiller/graalvm-ce-java11-22.3.0/Contents/Home"]
|
mac-graalvm-home "/Users/distiller/graalvm-ce-java19-22.3.1/Contents/Home"]
|
||||||
(ordered-map
|
(ordered-map
|
||||||
:version 2.1
|
:version 2.1
|
||||||
:commands
|
:commands
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ task:
|
||||||
skip: "changesIncludeOnly('logo/*', '**.md')"
|
skip: "changesIncludeOnly('logo/*', '**.md')"
|
||||||
env:
|
env:
|
||||||
LEIN_ROOT: "true"
|
LEIN_ROOT: "true"
|
||||||
GRAALVM_VERSION: "22.3.0"
|
GRAALVM_VERSION: "22.3.1"
|
||||||
GRAALVM_HOME: ${HOME}/graalvm-ce-java11-22.3.0/Contents/Home
|
GRAALVM_HOME: ${HOME}/graalvm-ce-java19-22.3.1/Contents/Home
|
||||||
BABASHKA_PLATFORM: macos # used in release script
|
BABASHKA_PLATFORM: macos # used in release script
|
||||||
BABASHKA_ARCH: aarch64
|
BABASHKA_ARCH: aarch64
|
||||||
BABASHKA_TEST_ENV: native
|
BABASHKA_TEST_ENV: native
|
||||||
|
|
|
||||||
1
.portal/vs-code.edn
Normal file
1
.portal/vs-code.edn
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{:host "localhost", :port 51379}
|
||||||
12
Dockerfile
12
Dockerfile
|
|
@ -5,7 +5,7 @@ RUN apt update
|
||||||
RUN apt install --no-install-recommends -yy build-essential zlib1g-dev
|
RUN apt install --no-install-recommends -yy build-essential zlib1g-dev
|
||||||
WORKDIR "/opt"
|
WORKDIR "/opt"
|
||||||
|
|
||||||
ENV GRAALVM_VERSION="22.3.0"
|
ENV GRAALVM_VERSION="22.3.1"
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
# Do not set those directly, use TARGETARCH instead
|
# Do not set those directly, use TARGETARCH instead
|
||||||
ENV BABASHKA_ARCH=
|
ENV BABASHKA_ARCH=
|
||||||
|
|
@ -16,14 +16,14 @@ RUN if [ "${TARGETARCH}" = "" ] || [ "${TARGETARCH}" = "amd64" ]; then \
|
||||||
export GRAALVM_ARCH=aarch64; \
|
export GRAALVM_ARCH=aarch64; \
|
||||||
fi && \
|
fi && \
|
||||||
echo "Installing GraalVM for ${GRAALVM_ARCH}" && \
|
echo "Installing GraalVM for ${GRAALVM_ARCH}" && \
|
||||||
curl -sLO https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAALVM_VERSION}/graalvm-ce-java11-linux-${GRAALVM_ARCH}-${GRAALVM_VERSION}.tar.gz && \
|
curl -sLO https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAALVM_VERSION}/graalvm-ce-java19-linux-${GRAALVM_ARCH}-${GRAALVM_VERSION}.tar.gz && \
|
||||||
tar -xzf graalvm-ce-java11-linux-${GRAALVM_ARCH}-${GRAALVM_VERSION}.tar.gz && \
|
tar -xzf graalvm-ce-java19-linux-${GRAALVM_ARCH}-${GRAALVM_VERSION}.tar.gz && \
|
||||||
rm graalvm-ce-java11-linux-${GRAALVM_ARCH}-${GRAALVM_VERSION}.tar.gz
|
rm graalvm-ce-java19-linux-${GRAALVM_ARCH}-${GRAALVM_VERSION}.tar.gz
|
||||||
|
|
||||||
ARG BABASHKA_XMX="-J-Xmx4500m"
|
ARG BABASHKA_XMX="-J-Xmx4500m"
|
||||||
|
|
||||||
ENV GRAALVM_HOME="/opt/graalvm-ce-java11-${GRAALVM_VERSION}"
|
ENV GRAALVM_HOME="/opt/graalvm-ce-java19-${GRAALVM_VERSION}"
|
||||||
ENV JAVA_HOME="/opt/graalvm-ce-java11-${GRAALVM_VERSION}/bin"
|
ENV JAVA_HOME="/opt/graalvm-ce-java19-${GRAALVM_VERSION}/bin"
|
||||||
ENV PATH="$JAVA_HOME:$PATH"
|
ENV PATH="$JAVA_HOME:$PATH"
|
||||||
ENV BABASHKA_XMX=$BABASHKA_XMX
|
ENV BABASHKA_XMX=$BABASHKA_XMX
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ image: Visual Studio 2017
|
||||||
clone_folder: C:\projects\babashka
|
clone_folder: C:\projects\babashka
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
GRAALVM_HOME: C:\projects\babashka\graalvm\graalvm-ce-java11-22.3.0
|
GRAALVM_HOME: C:\projects\babashka\graalvm\graalvm-ce-java19-22.3.1
|
||||||
JAVA_HOME: C:\projects\babashka\graalvm\graalvm-ce-java11-22.3.0
|
JAVA_HOME: C:\projects\babashka\graalvm\graalvm-ce-java19-22.3.1
|
||||||
BABASHKA_XMX: "-J-Xmx5g"
|
BABASHKA_XMX: "-J-Xmx5g"
|
||||||
|
|
||||||
skip_commits:
|
skip_commits:
|
||||||
|
|
@ -38,7 +38,7 @@ clone_script:
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- cmd: >-
|
- cmd: >-
|
||||||
powershell -Command "if (Test-Path('graalvm')) { return } else { (New-Object Net.WebClient).DownloadFile('https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java11-windows-amd64-22.3.0.zip', 'graalvm.zip') }"
|
powershell -Command "if (Test-Path('graalvm')) { return } else { (New-Object Net.WebClient).DownloadFile('https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-java19-windows-amd64-22.3.1.zip', 'graalvm.zip') }"
|
||||||
|
|
||||||
powershell -Command "if (Test-Path('graalvm')) { return } else { Expand-Archive graalvm.zip graalvm }"
|
powershell -Command "if (Test-Path('graalvm')) { return } else { Expand-Archive graalvm.zip graalvm }"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,24 @@
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
- Install [lein](https://leiningen.org/) for producing uberjars
|
- Install [lein](https://leiningen.org/) for producing uberjars
|
||||||
- Download [GraalVM](https://www.graalvm.org/downloads/). Currently we use *java11-22.3.0*.
|
- Download [GraalVM](https://www.graalvm.org/downloads/). Currently we use *java19-22.3.1*.
|
||||||
- For Windows, installing Visual Studio 2019 with the "Desktop development
|
- For Windows, installing Visual Studio 2019 with the "Desktop development
|
||||||
with C++" workload is recommended.
|
with C++" workload is recommended.
|
||||||
- Set `$GRAALVM_HOME` to the GraalVM distribution directory. On macOS this can look like:
|
- Set `$GRAALVM_HOME` to the GraalVM distribution directory. On macOS this can look like:
|
||||||
|
|
||||||
``` shell
|
``` shell
|
||||||
export GRAALVM_HOME=~/Downloads/graalvm-ce-java11-22.3.0/Contents/Home
|
export GRAALVM_HOME=~/Downloads/graalvm-ce-java19-22.3.1/Contents/Home
|
||||||
```
|
```
|
||||||
|
|
||||||
On linux:
|
On linux:
|
||||||
|
|
||||||
``` shell
|
``` shell
|
||||||
export GRAALVM_HOME=~/Downloads/graalvm-ce-java11-22.3.0
|
export GRAALVM_HOME=~/Downloads/graalvm-ce-java19-22.3.1
|
||||||
```
|
```
|
||||||
|
|
||||||
On Windows, from the [Visual Studio 2019 x64 Native Tools Command Prompt](https://github.com/oracle/graal/issues/2116#issuecomment-590470806) or `cmd.exe` (not Powershell):
|
On Windows, from the [Visual Studio 2019 x64 Native Tools Command Prompt](https://github.com/oracle/graal/issues/2116#issuecomment-590470806) or `cmd.exe` (not Powershell):
|
||||||
```
|
```
|
||||||
set GRAALVM_HOME=%USERPROFILE%\Downloads\graalvm-ce-java11-22.3.0
|
set GRAALVM_HOME=%USERPROFILE%\Downloads\graalvm-ce-java19-22.3.1
|
||||||
```
|
```
|
||||||
If you are not running from the x64 Native Tools Command Prompt, you will need to set additional environment variables using:
|
If you are not running from the x64 Native Tools Command Prompt, you will need to set additional environment variables using:
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ reasons:
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
You need [lein](https://leiningen.org/) for running JVM tests and/or producing uberjars. For building binaries you need GraalVM. Currently we use java11-22.3.0.
|
You need [lein](https://leiningen.org/) for running JVM tests and/or producing uberjars. For building binaries you need GraalVM. Currently we use java19-22.3.1.
|
||||||
|
|
||||||
## Clone repository
|
## Clone repository
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
org.clojure/data.priority-map {:mvn/version "1.1.0"}
|
org.clojure/data.priority-map {:mvn/version "1.1.0"}
|
||||||
insn/insn {:mvn/version "0.5.2"}
|
insn/insn {:mvn/version "0.5.2"}
|
||||||
org.clojure/core.rrb-vector {:mvn/version "0.1.2"}
|
org.clojure/core.rrb-vector {:mvn/version "0.1.2"}
|
||||||
org.babashka/cli {:mvn/version "0.6.45"}
|
org.babashka/cli {:mvn/version "0.6.46"}
|
||||||
org.babashka/http-client {:mvn/version "0.1.4"}}
|
org.babashka/http-client {:mvn/version "0.1.4"}}
|
||||||
:aliases {:babashka/dev
|
:aliases {:babashka/dev
|
||||||
{:main-opts ["-m" "babashka.main"]}
|
{:main-opts ["-m" "babashka.main"]}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
;; GraalVM Community Edition 19.3.2 based on OpenJDK 8u252
|
;; GraalVM Community Edition 19.3.2 based on OpenJDK 8u252
|
||||||
;; GraalVM Community Edition 19.3.2 based on OpenJDK 11.0.7
|
;; GraalVM Community Edition 19.3.2 based on OpenJDK 11.0.7
|
||||||
;;
|
;;
|
||||||
;; Currently we use GraalVM java11-20.1.0
|
;; Currently we use GraalVM java19-20.1.0
|
||||||
|
|
||||||
(ns bump-graal-version
|
(ns bump-graal-version
|
||||||
(:require [clojure.string :as str]
|
(:require [clojure.string :as str]
|
||||||
|
|
@ -31,8 +31,8 @@
|
||||||
""
|
""
|
||||||
"./bump_graal_version.clj -g 19.3.2 (the new version)"
|
"./bump_graal_version.clj -g 19.3.2 (the new version)"
|
||||||
"or"
|
"or"
|
||||||
"./bump_graal_version.clj -g 19.3.2 --java java11"
|
"./bump_graal_version.clj -g 19.3.2 --java java19"
|
||||||
"(for GraalVM java11-19.3.2)"
|
"(for GraalVM java19-19.3.2)"
|
||||||
""]
|
""]
|
||||||
(str/join \newline))))
|
(str/join \newline))))
|
||||||
|
|
||||||
|
|
@ -54,8 +54,8 @@
|
||||||
;; OR
|
;; OR
|
||||||
;;
|
;;
|
||||||
;; We could have them as environment variables
|
;; We could have them as environment variables
|
||||||
(def current-graal-version "22.3.0")
|
(def current-graal-version "22.3.1")
|
||||||
(def current-java-version "java11")
|
(def current-java-version "java19")
|
||||||
|
|
||||||
(def cl-options
|
(def cl-options
|
||||||
[["-g" "--graal VERSION" "graal version"]
|
[["-g" "--graal VERSION" "graal version"]
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ args=("-jar" "$BABASHKA_JAR"
|
||||||
"--no-fallback"
|
"--no-fallback"
|
||||||
"--native-image-info"
|
"--native-image-info"
|
||||||
# --trace-class-initialization=jdk.internal.net.http.common.DebugLogger,jdk.internal.net.http.websocket.WebSocketImpl,jdk.internal.net.http.common.Utils
|
# --trace-class-initialization=jdk.internal.net.http.common.DebugLogger,jdk.internal.net.http.websocket.WebSocketImpl,jdk.internal.net.http.common.Utils
|
||||||
"$BABASHKA_XMX")
|
"$BABASHKA_XMX"
|
||||||
|
"--enable-preview")
|
||||||
|
|
||||||
BABASHKA_STATIC=${BABASHKA_STATIC:-}
|
BABASHKA_STATIC=${BABASHKA_STATIC:-}
|
||||||
BABASHKA_MUSL=${BABASHKA_MUSL:-}
|
BABASHKA_MUSL=${BABASHKA_MUSL:-}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ call %GRAALVM_HOME%\bin\native-image.cmd ^
|
||||||
"-H:+ReportExceptionStackTraces" ^
|
"-H:+ReportExceptionStackTraces" ^
|
||||||
"--verbose" ^
|
"--verbose" ^
|
||||||
"--no-fallback" ^
|
"--no-fallback" ^
|
||||||
|
"--enable-preview" ^
|
||||||
"%BABASHKA_XMX%"
|
"%BABASHKA_XMX%"
|
||||||
|
|
||||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||||
|
|
|
||||||
|
|
@ -7,31 +7,34 @@ INSTALL_DIR="${1:-$HOME}"
|
||||||
GRAALVM_VERSION="${GRAALVM_VERSION:-21.2.0}"
|
GRAALVM_VERSION="${GRAALVM_VERSION:-21.2.0}"
|
||||||
|
|
||||||
case "$BABASHKA_PLATFORM" in
|
case "$BABASHKA_PLATFORM" in
|
||||||
macos)
|
macos)
|
||||||
GRAALVM_PLATFORM="darwin"
|
GRAALVM_PLATFORM="darwin"
|
||||||
;;
|
;;
|
||||||
linux)
|
linux)
|
||||||
GRAALVM_PLATFORM="linux"
|
GRAALVM_PLATFORM="linux"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case "${BABASHKA_ARCH:-}" in
|
case "${BABASHKA_ARCH:-}" in
|
||||||
aarch64)
|
aarch64)
|
||||||
GRAALVM_ARCH="aarch64"
|
GRAALVM_ARCH="aarch64"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
GRAALVM_ARCH="amd64"
|
GRAALVM_ARCH="amd64"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
GRAALVM_FILENAME="graalvm-ce-java11-$GRAALVM_PLATFORM-$GRAALVM_ARCH-$GRAALVM_VERSION.tar.gz"
|
GRAALVM_FILENAME="graalvm-ce-java19-$GRAALVM_PLATFORM-$GRAALVM_ARCH-$GRAALVM_VERSION.tar.gz"
|
||||||
|
|
||||||
pushd "$INSTALL_DIR" >/dev/null
|
pushd "$INSTALL_DIR" >/dev/null
|
||||||
|
|
||||||
if ! [ -d "graalvm-ce-java11-$GRAALVM_VERSION" ]; then
|
if ! [ -d "graalvm-ce-java19-$GRAALVM_VERSION" ]; then
|
||||||
echo "Downloading GraalVM $GRAALVM_PLATFORM-$GRAALVM_ARCH-$GRAALVM_VERSION on '$PWD'..."
|
echo "Downloading GraalVM $GRAALVM_PLATFORM-$GRAALVM_ARCH-$GRAALVM_VERSION on '$PWD'..."
|
||||||
curl -O -sL "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-$GRAALVM_VERSION/$GRAALVM_FILENAME"
|
echo "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-$GRAALVM_VERSION/$GRAALVM_FILENAME"
|
||||||
tar xzf "$GRAALVM_FILENAME"
|
curl -LO "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-$GRAALVM_VERSION/$GRAALVM_FILENAME"
|
||||||
|
ls -la
|
||||||
|
tar xzvf "$GRAALVM_FILENAME"
|
||||||
|
ls -la "graalvm-ce-java19-$GRAALVM_VERSION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@
|
||||||
[sci.core :as sci]
|
[sci.core :as sci]
|
||||||
[sci.impl.types :as t]))
|
[sci.impl.types :as t]))
|
||||||
|
|
||||||
|
(def has-of-virtual?
|
||||||
|
(some #(= "ofVirtual" (.getName ^java.lang.reflect.Method %))
|
||||||
|
(.getMethods Thread)))
|
||||||
|
|
||||||
(def base-custom-map
|
(def base-custom-map
|
||||||
`{clojure.lang.LineNumberingPushbackReader {:allPublicConstructors true
|
`{clojure.lang.LineNumberingPushbackReader {:allPublicConstructors true
|
||||||
:allPublicMethods true}
|
:allPublicMethods true}
|
||||||
|
|
@ -47,7 +51,8 @@
|
||||||
{:name "sleep"}
|
{:name "sleep"}
|
||||||
{:name "start"}
|
{:name "start"}
|
||||||
{:name "toString"}
|
{:name "toString"}
|
||||||
{:name "yield"}]}
|
{:name "yield"}
|
||||||
|
~@(when has-of-virtual? [{:name "ofVirtual"}])]}
|
||||||
java.net.URL
|
java.net.URL
|
||||||
{:allPublicConstructors true
|
{:allPublicConstructors true
|
||||||
:allPublicFields true
|
:allPublicFields true
|
||||||
|
|
@ -433,6 +438,7 @@
|
||||||
java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy
|
java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy
|
||||||
java.util.concurrent.ThreadPoolExecutor$DiscardOldestPolicy
|
java.util.concurrent.ThreadPoolExecutor$DiscardOldestPolicy
|
||||||
java.util.concurrent.ThreadPoolExecutor$DiscardPolicy
|
java.util.concurrent.ThreadPoolExecutor$DiscardPolicy
|
||||||
|
java.util.concurrent.ExecutorService
|
||||||
java.util.concurrent.ScheduledExecutorService
|
java.util.concurrent.ScheduledExecutorService
|
||||||
java.util.concurrent.Future
|
java.util.concurrent.Future
|
||||||
java.util.concurrent.FutureTask
|
java.util.concurrent.FutureTask
|
||||||
|
|
@ -663,6 +669,8 @@
|
||||||
java.util.concurrent.Future
|
java.util.concurrent.Future
|
||||||
(instance? java.util.concurrent.ScheduledExecutorService v)
|
(instance? java.util.concurrent.ScheduledExecutorService v)
|
||||||
java.util.concurrent.ScheduledExecutorService
|
java.util.concurrent.ScheduledExecutorService
|
||||||
|
(instance? java.util.concurrent.ExecutorService v)
|
||||||
|
java.util.concurrent.ExecutorService
|
||||||
(instance? java.util.Iterator v)
|
(instance? java.util.Iterator v)
|
||||||
java.util.Iterator
|
java.util.Iterator
|
||||||
(instance? javax.crypto.SecretKey v)
|
(instance? javax.crypto.SecretKey v)
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
expected-sha (String. (.encode (java.util.Base64/getEncoder)
|
expected-sha (String. (.encode (java.util.Base64/getEncoder)
|
||||||
(hmac-sha-256 (.getBytes key-s) data))
|
(hmac-sha-256 (.getBytes key-s) data))
|
||||||
"utf-8")]
|
"utf-8")]
|
||||||
|
(prn expected-sha)
|
||||||
(is (= expected-sha (bb '(do (ns net
|
(is (= expected-sha (bb '(do (ns net
|
||||||
(:import (javax.crypto Mac)
|
(:import (javax.crypto Mac)
|
||||||
(javax.crypto.spec SecretKeySpec)))
|
(javax.crypto.spec SecretKeySpec)))
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,19 @@
|
||||||
[clojure.test :as t :refer [deftest is testing]]
|
[clojure.test :as t :refer [deftest is testing]]
|
||||||
[matcher-combinators.test]))
|
[matcher-combinators.test]))
|
||||||
|
|
||||||
|
(defn process-difference [line]
|
||||||
|
(-> line str/trimr
|
||||||
|
;; take into account JDK14+ and native image differences
|
||||||
|
(str/replace "class clojure.lang" "clojure.lang")
|
||||||
|
(str/replace #" \(.*\)$" "")))
|
||||||
|
|
||||||
(defmacro multiline-equals [s1 s2]
|
(defmacro multiline-equals [s1 s2]
|
||||||
`(let [lines-s1# (str/split-lines ~s1)
|
`(let [lines-s1# (str/split-lines ~s1)
|
||||||
lines-s2# (str/split-lines ~s2)
|
lines-s2# (str/split-lines ~s2)
|
||||||
max-lines# (max (count lines-s1#) (count lines-s2#))
|
max-lines# (max (count lines-s1#) (count lines-s2#))
|
||||||
lines-s1# (take max-lines# lines-s1#)
|
lines-s1# (take max-lines# lines-s1#)
|
||||||
lines-s2# (take max-lines# lines-s2#)]
|
lines-s2# (take max-lines# lines-s2#)]
|
||||||
(is (~'match? (map str/trimr lines-s1#) (map str/trimr lines-s2#)))
|
(is (~'match? (map process-difference lines-s1#) (map process-difference lines-s2#)))
|
||||||
#_(run! (fn [i]
|
#_(run! (fn [i]
|
||||||
(let [l1 (get lines-s1 i)
|
(let [l1 (get lines-s1 i)
|
||||||
l2 (get lines-s2 i)]
|
l2 (get lines-s2 i)]
|
||||||
|
|
@ -117,58 +123,63 @@ user - <expr>:1:1")))))
|
||||||
|
|
||||||
|
|
||||||
(deftest error-while-macroexpanding-test
|
(deftest error-while-macroexpanding-test
|
||||||
(let [output (try (tu/bb nil "-e" "(defmacro foo [x] (subs nil 1) `(do ~x ~x)) (foo 1)")
|
(let [output (try (tu/bb nil "-e" "(defmacro foo [x] (assoc :foo 1 2) `(do ~x ~x)) (foo 1)")
|
||||||
(catch Exception e (ex-message e)))]
|
(catch Exception e (ex-message e)))]
|
||||||
(multiline-equals output
|
(multiline-equals output
|
||||||
"----- Error --------------------------------------------------------------------
|
"----- Error --------------------------------------------------------------------
|
||||||
Type: java.lang.NullPointerException
|
Type: java.lang.ClassCastException
|
||||||
|
Message: clojure.lang.Keyword cannot be cast to clojure.lang.Associative
|
||||||
Location: <expr>:1:19
|
Location: <expr>:1:19
|
||||||
Phase: macroexpand
|
Phase: macroexpand
|
||||||
|
|
||||||
----- Context ------------------------------------------------------------------
|
----- Context ------------------------------------------------------------------
|
||||||
1: (defmacro foo [x] (subs nil 1) `(do ~x ~x)) (foo 1)
|
1: (defmacro foo [x] (assoc :foo 1 2) `(do ~x ~x)) (foo 1)
|
||||||
^---
|
^--- clojure.lang.Keyword cannot be cast to clojure.lang.Associative
|
||||||
|
|
||||||
----- Stack trace --------------------------------------------------------------
|
----- Stack trace --------------------------------------------------------------
|
||||||
clojure.core/subs - <built-in>
|
clojure.core/assoc--5481 - <built-in>
|
||||||
user/foo - <expr>:1:19
|
clojure.core/assoc - <built-in>
|
||||||
user/foo - <expr>:1:1
|
user/foo - <expr>:1:19
|
||||||
user - <expr>:1:45")))
|
user/foo - <expr>:1:1
|
||||||
|
user - <expr>:1:49")))
|
||||||
|
|
||||||
(deftest error-in-macroexpansion-test
|
(deftest error-in-macroexpansion-test
|
||||||
(let [output (try (tu/bb nil "-e" "(defmacro foo [x] `(subs nil ~x)) (foo 1)")
|
(let [output (try (tu/bb nil "-e" "(defmacro foo [x] `(assoc :foo ~x 2)) (foo 1)")
|
||||||
(catch Exception e (ex-message e)))]
|
(catch Exception e (ex-message e)))]
|
||||||
(multiline-equals output
|
(multiline-equals output
|
||||||
"----- Error --------------------------------------------------------------------
|
"----- Error --------------------------------------------------------------------
|
||||||
Type: java.lang.NullPointerException
|
Type: java.lang.ClassCastException
|
||||||
Location: <expr>:1:35
|
Message: clojure.lang.Keyword cannot be cast to clojure.lang.Associative
|
||||||
|
Location: <expr>:1:39
|
||||||
|
|
||||||
----- Context ------------------------------------------------------------------
|
----- Context ------------------------------------------------------------------
|
||||||
1: (defmacro foo [x] `(subs nil ~x)) (foo 1)
|
1: (defmacro foo [x] `(assoc :foo ~x 2)) (foo 1)
|
||||||
^---
|
^--- clojure.lang.Keyword cannot be cast to clojure.lang.Associative
|
||||||
|
|
||||||
----- Stack trace --------------------------------------------------------------
|
----- Stack trace --------------------------------------------------------------
|
||||||
clojure.core/subs - <built-in>
|
clojure.core/assoc--5481 - <built-in>
|
||||||
user - <expr>:1:35
|
clojure.core/assoc - <built-in>
|
||||||
"))
|
user - <expr>:1:39"))
|
||||||
(testing "calling a var inside macroexpansion"
|
(testing "calling a var inside macroexpansion"
|
||||||
(let [output (try (tu/bb nil "-e" "(defn quux [] (subs nil 1)) (defmacro foo [x & xs] `(do (quux) ~x)) (defn bar [] (foo 1)) (bar)")
|
(let [output (try (tu/bb nil "-e" "(defn quux [] (assoc :foo 1 2)) (defmacro foo [x & xs] `(do (quux) ~x)) (defn bar [] (foo 1)) (bar)")
|
||||||
(catch Exception e (ex-message e)))]
|
(catch Exception e (ex-message e)))]
|
||||||
(multiline-equals output
|
(multiline-equals output
|
||||||
"----- Error --------------------------------------------------------------------
|
"----- Error --------------------------------------------------------------------
|
||||||
Type: java.lang.NullPointerException
|
Type: java.lang.ClassCastException
|
||||||
|
Message: clojure.lang.Keyword cannot be cast to clojure.lang.Associative
|
||||||
Location: <expr>:1:15
|
Location: <expr>:1:15
|
||||||
|
|
||||||
----- Context ------------------------------------------------------------------
|
----- Context ------------------------------------------------------------------
|
||||||
1: (defn quux [] (subs nil 1)) (defmacro foo [x & xs] `(do (quux) ~x)) (defn bar [] (foo 1)) (bar)
|
1: (defn quux [] (assoc :foo 1 2)) (defmacro foo [x & xs] `(do (quux) ~x)) (defn bar [] (foo 1)) (bar)
|
||||||
^---
|
^--- clojure.lang.Keyword cannot be cast to clojure.lang.Associative
|
||||||
|
|
||||||
----- Stack trace --------------------------------------------------------------
|
----- Stack trace --------------------------------------------------------------
|
||||||
clojure.core/subs - <built-in>
|
clojure.core/assoc--5481 - <built-in>
|
||||||
user/quux - <expr>:1:15
|
clojure.core/assoc - <built-in>
|
||||||
user/quux - <expr>:1:1
|
user/quux - <expr>:1:15
|
||||||
user/bar - <expr>:1:69
|
user/quux - <expr>:1:1
|
||||||
user - <expr>:1:91"))))
|
user/bar - <expr>:1:73
|
||||||
|
user - <expr>:1:95"))))
|
||||||
|
|
||||||
(deftest print-exception-data-test
|
(deftest print-exception-data-test
|
||||||
(testing "output of uncaught ExceptionInfo"
|
(testing "output of uncaught ExceptionInfo"
|
||||||
|
|
@ -232,29 +243,31 @@ clojure.lang.ExceptionInfo: Divide by zero")))
|
||||||
"{:type :sci/error, :line 1, :column 12, :message \"Divide by zero\",")))))
|
"{:type :sci/error, :line 1, :column 12, :message \"Divide by zero\",")))))
|
||||||
|
|
||||||
(deftest macro-test
|
(deftest macro-test
|
||||||
(let [output (try (tu/bb nil "--debug" "(defmacro foo [x] (subs nil 1) `(do ~x ~x)) (foo 1)")
|
(let [output (try (tu/bb nil "--debug" "(defmacro foo [x] (assoc :foo 1 2) `(do ~x ~x)) (foo 1)")
|
||||||
(is false)
|
(is false)
|
||||||
(catch Exception e (ex-message e)))
|
(catch Exception e (ex-message e)))
|
||||||
output (tu/normalize output)
|
output (tu/normalize output)
|
||||||
actual-lines (str/join "\n" (take 17 (str/split-lines output)))]
|
actual-lines (str/join "\n" (take 19 (str/split-lines output)))]
|
||||||
(multiline-equals actual-lines
|
(multiline-equals actual-lines
|
||||||
"----- Error --------------------------------------------------------------------
|
"----- Error --------------------------------------------------------------------
|
||||||
Type: java.lang.NullPointerException
|
Type: java.lang.ClassCastException
|
||||||
|
Message: clojure.lang.Keyword cannot be cast to clojure.lang.Associative
|
||||||
Location: <expr>:1:19
|
Location: <expr>:1:19
|
||||||
Phase: macroexpand
|
Phase: macroexpand
|
||||||
|
|
||||||
----- Context ------------------------------------------------------------------
|
----- Context ------------------------------------------------------------------
|
||||||
1: (defmacro foo [x] (subs nil 1) `(do ~x ~x)) (foo 1)
|
1: (defmacro foo [x] (assoc :foo 1 2) `(do ~x ~x)) (foo 1)
|
||||||
^---
|
^--- clojure.lang.Keyword cannot be cast to clojure.lang.Associative
|
||||||
|
|
||||||
----- Stack trace --------------------------------------------------------------
|
----- Stack trace --------------------------------------------------------------
|
||||||
clojure.core/subs - <built-in>
|
clojure.core/assoc--5481 - <built-in>
|
||||||
user/foo - <expr>:1:19
|
clojure.core/assoc - <built-in>
|
||||||
user/foo - <expr>:1:1
|
user/foo - <expr>:1:19
|
||||||
user - <expr>:1:45
|
user/foo - <expr>:1:1
|
||||||
|
user - <expr>:1:49
|
||||||
|
|
||||||
----- Exception ----------------------------------------------------------------
|
----- Exception ----------------------------------------------------------------
|
||||||
clojure.lang.ExceptionInfo: null")))
|
clojure.lang.ExceptionInfo: clojure.lang.Keyword cannot be cast to clojure.lang.Associative")))
|
||||||
|
|
||||||
(deftest native-stacktrace-test
|
(deftest native-stacktrace-test
|
||||||
(let [output (try (tu/bb nil "(merge 1 2 3)")
|
(let [output (try (tu/bb nil "(merge 1 2 3)")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue