diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 4af7873898..43a1d65c41 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -45,6 +45,8 @@
+
+
@@ -53,6 +55,8 @@
+
+
@@ -73,11 +77,17 @@
+
+
+
+
+
+
@@ -122,6 +132,8 @@
+
+
@@ -139,6 +151,10 @@
+
+
+
+
@@ -200,10 +216,15 @@
+
+
+
+
+
@@ -239,6 +260,8 @@
+
+
diff --git a/sgx-jvm/hsm-tool/build.gradle b/hsm-tool/build.gradle
similarity index 100%
rename from sgx-jvm/hsm-tool/build.gradle
rename to hsm-tool/build.gradle
diff --git a/sgx-jvm/hsm-tool/libs/CryptoServerCXI.jar b/hsm-tool/libs/CryptoServerCXI.jar
similarity index 100%
rename from sgx-jvm/hsm-tool/libs/CryptoServerCXI.jar
rename to hsm-tool/libs/CryptoServerCXI.jar
diff --git a/sgx-jvm/hsm-tool/libs/CryptoServerJCE.jar b/hsm-tool/libs/CryptoServerJCE.jar
similarity index 100%
rename from sgx-jvm/hsm-tool/libs/CryptoServerJCE.jar
rename to hsm-tool/libs/CryptoServerJCE.jar
diff --git a/sgx-jvm/hsm-tool/src/main/kotlin/com/r3cev/sgx/config/ToolConfig.kt b/hsm-tool/src/main/kotlin/com/r3cev/sgx/config/ToolConfig.kt
similarity index 100%
rename from sgx-jvm/hsm-tool/src/main/kotlin/com/r3cev/sgx/config/ToolConfig.kt
rename to hsm-tool/src/main/kotlin/com/r3cev/sgx/config/ToolConfig.kt
diff --git a/sgx-jvm/hsm-tool/src/main/kotlin/com/r3cev/sgx/hsmtool/Main.kt b/hsm-tool/src/main/kotlin/com/r3cev/sgx/hsmtool/Main.kt
similarity index 100%
rename from sgx-jvm/hsm-tool/src/main/kotlin/com/r3cev/sgx/hsmtool/Main.kt
rename to hsm-tool/src/main/kotlin/com/r3cev/sgx/hsmtool/Main.kt
diff --git a/sgx-jvm/hsm-tool/src/main/kotlin/com/r3cev/sgx/utils/ConfigUtilities.kt b/hsm-tool/src/main/kotlin/com/r3cev/sgx/utils/ConfigUtilities.kt
similarity index 100%
rename from sgx-jvm/hsm-tool/src/main/kotlin/com/r3cev/sgx/utils/ConfigUtilities.kt
rename to hsm-tool/src/main/kotlin/com/r3cev/sgx/utils/ConfigUtilities.kt
diff --git a/sgx-jvm/hsm-tool/src/main/kotlin/com/r3cev/sgx/utils/HsmErrors.kt b/hsm-tool/src/main/kotlin/com/r3cev/sgx/utils/HsmErrors.kt
similarity index 100%
rename from sgx-jvm/hsm-tool/src/main/kotlin/com/r3cev/sgx/utils/HsmErrors.kt
rename to hsm-tool/src/main/kotlin/com/r3cev/sgx/utils/HsmErrors.kt
diff --git a/sgx-jvm/hsm-tool/src/main/resources/com/r3cev/sgx/config/sgxtool.cfg b/hsm-tool/src/main/resources/com/r3cev/sgx/config/sgxtool.cfg
similarity index 100%
rename from sgx-jvm/hsm-tool/src/main/resources/com/r3cev/sgx/config/sgxtool.cfg
rename to hsm-tool/src/main/resources/com/r3cev/sgx/config/sgxtool.cfg
diff --git a/sgx-jvm/hsm-tool/src/main/resources/com/r3cev/sgx/utils/hsm_errors b/hsm-tool/src/main/resources/com/r3cev/sgx/utils/hsm_errors
similarity index 100%
rename from sgx-jvm/hsm-tool/src/main/resources/com/r3cev/sgx/utils/hsm_errors
rename to hsm-tool/src/main/resources/com/r3cev/sgx/utils/hsm_errors
diff --git a/settings.gradle b/settings.gradle
index db94bf05d5..4528f85bcc 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -82,11 +82,6 @@ include 'samples:cordapp-configuration'
include 'serialization'
include 'serialization-deterministic'
include 'cordform-common'
-include 'verify-enclave'
include 'hsm-tool'
-project(':hsm-tool').with {
- name = 'sgx-hsm-tool'
- projectDir = file("$settingsDir/sgx-jvm/hsm-tool")
-}
include 'launcher'
include 'node:dist'
diff --git a/sgx-jvm/.gitignore b/sgx-jvm/.gitignore
deleted file mode 100644
index 2d9cc6c751..0000000000
--- a/sgx-jvm/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-.idea/
-.vscode/
-obj/
-build/
-log/
-tags
diff --git a/sgx-jvm/Makefile b/sgx-jvm/Makefile
deleted file mode 100644
index 79ff685f51..0000000000
--- a/sgx-jvm/Makefile
+++ /dev/null
@@ -1,93 +0,0 @@
-MAKEFILE_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
-SHELL=/bin/bash
-
-JDK_IMAGE=$(MAKEFILE_DIR)/jdk8u/build/linux-x86_64-normal-server-release/images/j2re-image
-
-.PHONY: all
-
-all: \
- jvm-enclave/standalone/build/standalone_sgx_verify \
- linux-sgx-driver/isgx.ko
-
-# === JVM Enclave ===
-
-jvm-enclave/standalone/build/standalone_sgx_verify: \
- avian linux-sgx/build/linux/aesm_service
- JAVA_HOME=$(JAVA_HOME) JDK_IMAGE=$(JDK_IMAGE) $(MAKE) -C jvm-enclave
-
-# === Avian with SGX Support ===
-
-AVIAN_EXTRA_CFLAGS="-I/usr/include -I/usr/include/x86_64-linux-gnu"
-AVIAN_EXTRA_LDFLAGS="-L/usr/lib -L/usr/lib/x86_64-linux-gnu -ldl -lpthread -lz"
-.PHONY: avian
-avian: | $(JDK_IMAGE)
- PATH=/usr/bin:$(PATH) $(MAKE) -C avian \
- build-lflags=$(AVIAN_EXTRA_LDFLAGS) \
- extra-lflags=$(AVIAN_EXTRA_LDFLAGS) \
- extra-build-cflags+=$(AVIAN_EXTRA_CFLAGS) \
- extra-cflags+=$(AVIAN_EXTRA_CFLAGS) \
- mode=debug \
- openjdk=$(JAVA_HOME) \
- openjdk-src=$(MAKEFILE_DIR)/jdk8u/jdk/src \
- openjdk-image=$(JDK_IMAGE) \
- system=sgx
-
-# === Deterministic JDK ===
-
-jdk8u:
- git clone -b deterministic-jvm8 --single-branch https://github.com/corda/openjdk $@
-
-$(JDK_IMAGE): jdk8u
- cd jdk8u && \
- ALSA_NOT_NEEDED=yes CUPS_NOT_NEEDED=yes FREETYPE_NOT_NEEDED=yes \
- PULSE_NOT_NEEDED=yes X11_NOT_NEEDED=yes $(SHELL) ./configure && \
- $(MAKE) JOBS=2 images docs
-
-# === SGX SDK ===
-
-# Poor man's up-to-date check (they don't have one in the SDK)
-LINUX_SGX_SOURCES=$(shell find linux-sgx \
- \( \
- -name '*.c' -o \
- -name '*.cpp' -o \
- -name '*.h' -o \
- -name '*.edl' \
- \) ! \( \
- -name '*_u.?' -o \
- -name '*_t.?' -o \
- -name '*.pb.h' -o \
- -path 'linux-sgx/sdk/cpprt/linux/libunwind/*' -o \
- -path 'linux-sgx/external/rdrand/src/config.h' \
- \))
-linux-sgx/build/linux/aesm_service: \
- $(LINUX_SGX_SOURCES) \
- linux-sgx/external/ippcp_internal/inc
- $(MAKE) -C linux-sgx DEBUG=1
-
-linux-sgx/external/ippcp_internal/inc:
- cd linux-sgx && $(SHELL) ./download_prebuilt.sh
-
-# === SGX Driver ===
-
-linux-sgx-driver/isgx.ko:
- $(MAKE) -C linux-sgx-driver
-
-# === Directories and Clean ===
-
-build:
- mkdir -p $@
-
-.PHONY: clean
-clean:
- $(MAKE) -C jvm-enclave clean
- $(MAKE) -C linux-sgx clean
- $(MAKE) -C linux-sgx-driver clean
- [ ! -d jdk8u ] || $(MAKE) -C jdk8u clean
- ../gradlew -p .. verify-enclave:clean
- $(MAKE) -C avian clean
-
-.PHONY: distclean
-distclean: clean
- $(RM) -r jdk8u
- $(RM) -r linux-sgx/external/{ippcp_internal,libirc,libm}
-
diff --git a/sgx-jvm/README.md b/sgx-jvm/README.md
deleted file mode 100644
index 3c6c439b36..0000000000
--- a/sgx-jvm/README.md
+++ /dev/null
@@ -1,84 +0,0 @@
-The build
-=========
-
-Prerequisites
--------------
-
-* Install gcc/g++(6), autoconf, automake, ocaml, opendjk(8), libtool, python(2.7)
-* Make sure JAVA_HOME points to your OpenJDK 8 installation
-* Make sure CXX points to g++ (the project does NOT compile with other compilers like clang!)
-* If your hardware supports SGX and you want to use it directly you need to install and load the sgx kernel module (verify by running `lsmod | grep isgx`) and have the sgx service running (on a systemd setup verify by running `systemctl status aesmd`). Note that this is only required for actually running the binary, the build should work fine without.
-* The SGX SDK has a simulation mode that doesn't require hardware support. To use this edit `sgx-jvm/jvm-enclave/common/CMakeLists.txt` and change `set(SGX_USE_HARDWARE TRUE)` to `FALSE`
-
-Toplevel Makefile targets
--------------------------
-
-* `make` will download all other dependencies and build the sgx\_standalone\_verify binary, residing at `sgx-jvm/jvm-enclave/standalone/build/sgx\_standalone\_verify`, as well as a JNI .so residing at `sgx-jvm/jvm-enclave/jni/build/untrusted_corda_sgx.so`
-* `make clean` will clean all build targets.
-* `make distclean` will clean all build targets and downloaded dependencies. Ordinarily you shouldn't need to run this.
-
-Each project has its own build that may be run individually (check the toplevel Makefile to see how to invoke these)
-
-At this point I suggest running `make` before reading further, it takes a while to download all dependencies.
-
-Some reading
-============
-
-Before delving into the code it's strongly recommended to read up on SGX. Some links:
-
-* Short high-level paper on the attestation design: https://software.intel.com/sites/default/files/article/413939/hasp-2013-innovative-technology-for-attestation-and-sealing.pdf
-* Medium length description of an example attestation protocol: https://software.intel.com/en-us/articles/intel-software-guard-extensions-remote-attestation-end-to-end-example
-* Lengthy programmer's reference including description of SGX specific instructions: https://software.intel.com/sites/default/files/managed/48/88/329298-002.pdf
-* Lengthy low-level paper disecting the SGX design, going into hardware details: https://eprint.iacr.org/2016/086.pdf
-* Lengthy SDK reference: https://download.01.org/intel-sgx/linux-1.7/docs/Intel_SGX_SDK_Developer_Reference_Linux_1.7_Open_Source.pdf
-
-
-Corda SGX
-=========
-
-The high level goal of the SGX work in Corda is to provide a secure way of verifying transactions. In order to do this we need to be able to run a JVM inside an enclave capable of running contract code. The design decision that contract verification code is without side-effects is imperative here.
-
-The dream is to have a functioning JVM running inside SGX with as few limitations as possible. Clients would then be able to connect to the enclave, the TCB would attest that it is running the JVM image on secure hardware, after which the client can safely submit signed JARs for execution.
-
-Corda would then be able to use this to submit contract code and transactions to run the contract code on.
-
-This is the first iteration of the work, with a lot of limitations. The current JVM is based on Avian which can produce a standalone statically linked binary. The build statically links the enclavelet JAR into the static enclave binary (`sgx-jvm/jvm-enclave/build/enclave/cordaenclave.so`) which is then loaded and run by `jvm/jvm-enclave/build/sgx\_experiments`.
-
-Breakdown of the build
-======================
-
-The current SGX work in Corda is based on 4 semi-distinct projects:
-
-* The Avian JVM (in the `sgx-jvm/avian` subtree. Note this is our own fork)
-* The SGX linux sdk (in the `sgx-jvm/linux-sgx` subtree. Note this is our own fork)
-* The JVM enclave code itself, residing in `sgx-jvm/jvm-enclave`. This includes the untrusted and trusted part of the SGXified JVM, mostly C++.
-* Finally the Corda enclavelet. This is the JAR that will be loaded and run inside the enclave. (built by `./gradlew verify-enclave:jar`
-
-Avian
------
-
-Avian has a code layout perfectly suited for SGX hacking. Each target platform (originally `posix` or `windows`) needs to implement a fairly straight-forward `System` interface providing OS-specific functionality like threading/synchronisation/memory/filesystem primitives. Check `sgx-jvm/avian/src/system` for code. We use this to implement an SGX "platform", which is basically a stripped down OS environment. Some additional #ifndef-ing was needed to strip some non-os-specific avian functionality that assumed the existence of a filesystem or networking. This work is maintained in a private fork, it is instructive to read through the diff, see https://bitbucket.org/R3-CEV/avian-sgx/.
-
-SGX SDK
--------
-
-There are some modifications in the upstream SGX SDK that we require to run the JVM. An example would be the ability to make the heap executable for JIT compilation, or exposing hooks into malloc to detect OOM conditions. All of these should be mergeable, but we maintain a fork to speed up development on our side.
-
-Corda Enclavelet
-----------------
-
-This is the JAR that will be run inside the enclave. Check `verify-enclave/src/../Enclavelet.kt` for the code.
-
-Currently the JAR is not loaded at runtime, but is rather embedded statically into the enclave itself using Avian's binaryToObject utility. This basically does an objcopy and lets the linker do the embedding later. This will later be changed to dynamic loading of signed JARs.
-
-The JVM enclave
----------------
-
-This consists of two parts: the untrusted code that loads the enclave and provides the OCALLs (see `sgx-jvm/jvm-enclave/main.cpp`), and the trusted enclave that constructs the JVM using JNI and runs the enclavelet class. (see `sgx-jvm/jvm-enclave/enclave/enclave.cpp`).
-
-Dynamic loading, linkage
-------------------------
-
-Avian by default loads some JVM specific code dynamically, and looks up these symbols at runtime. We link these symbols statically and provide a simple binary search lookup at runtime to find the symbols corresponding to symbol name strings. To see how this is done check `sgx-jvm/jvm-enclave/enclave/gen_dispatch_table.py`.
-
-Avian also statically links against system libraries providing usual OS functionality. We deal with this by stubbing all of the undefined symbols and implementing/mocking them as needed. The stub generation simply greps for undefined symbols when running make, check `sgx-jvm/jvm-enclave/enclave/gen-stubsyms.sh` for this. The implemented/mocked OS functions reside in `sgx-jvm/jvm-enclave/enclave/os_support.cpp`
diff --git a/sgx-jvm/avian/.clang-format b/sgx-jvm/avian/.clang-format
deleted file mode 100644
index 910160fcbe..0000000000
--- a/sgx-jvm/avian/.clang-format
+++ /dev/null
@@ -1,7 +0,0 @@
----
-BasedOnStyle: Chromium
-IndentCaseLabels: false
-BreakBeforeBraces: Stroustrup
-AllowShortFunctionsOnASingleLine: false
-BreakBeforeBinaryOperators: true
-...
diff --git a/sgx-jvm/avian/.gitignore b/sgx-jvm/avian/.gitignore
deleted file mode 100644
index 6767701eae..0000000000
--- a/sgx-jvm/avian/.gitignore
+++ /dev/null
@@ -1,18 +0,0 @@
-.gdb_history
-/build
-*~
-.classpath
-.project
-.settings
-bin
-/lib
-/distrib
-*.pdb
-*.swp
-/.gradle
-/*.sublime-*
-workspace/
-src/.cproject
-/cmake-build
-/cmake-build
-.idea/*
diff --git a/sgx-jvm/avian/.mailmap b/sgx-jvm/avian/.mailmap
deleted file mode 100644
index 12fd7d9627..0000000000
--- a/sgx-jvm/avian/.mailmap
+++ /dev/null
@@ -1,27 +0,0 @@
-Carsten Elton Sørensen
-Carsten Elton Sørensen
-Dain Darnell
-Dain Darnell
-Edison Guo
-Jason Treadwell
-Jason Treadwell
-Jason Treadwell
-Jason Treadwell
-Jason Treadwell
-Jason Treadwell
-Jason Treadwell
-Jason Treadwell
-Jason Treadwell
-Joel Dice
-Joel Dice
-Joel Dice
-Joel Dice
-Anonymous
-Joshua Warner
-Matt Weaver
-Mike Jensen
-Mike Jensen
-Mike Jensen
-Terek Campbell
-Thiago Bedin Frustaci
-Zsombor Gegesy
diff --git a/sgx-jvm/avian/.travis.yml b/sgx-jvm/avian/.travis.yml
deleted file mode 100644
index 42265efb47..0000000000
--- a/sgx-jvm/avian/.travis.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-language: cpp
-cache: apt
-
-os:
- - linux
- - osx
-
-env:
- matrix:
- - BUILD_STEP=""
-# disabled until/unless jfrog.org credentials are updated and someone
-# decides they care about published artifacts:
-# - BUILD_STEP="PUBLISH"
- global:
- - TERM=dumb
- - secure: rh1utD4shKmYtokItuRYEF9WsfTnvZO5XqnTU4DHTS7quHHgLihtOO2/3+B+2W2hEd5Obr2or8zx+zmzWcNUyLokZ0j/FRLWSScNkLzTtm12pupLrncY+/g1NIdfbhn+OLRIzBz6zB6m6a2qWFEJ+bScUNGD/7wZVtzkujqlDEE=
- - secure: j9DOzZMCYk/BzhKK9u4XMKpCzyGOsvP2cLTp6cXE7/tkWDAPVv6BFmeqNbiLTEqk0aGX+HYbY/2YVtpRZmDzfeWtnBFF5mL1Y1tgzx1Kf155C+P6rZgt5PiQTUdXlp2umuRifY1BbXAPc3DZ2UOPUjWKnLHVbZLQRgO1zimmMx8=
-
-matrix:
- fast_finish: true
- exclude:
- - os: osx
- env: BUILD_STEP=""
-
-script: ./test/ci.sh ${BUILD_STEP}
diff --git a/sgx-jvm/avian/.utility/push-javadoc-to-gh-pages.sh b/sgx-jvm/avian/.utility/push-javadoc-to-gh-pages.sh
deleted file mode 100755
index c3690b49de..0000000000
--- a/sgx-jvm/avian/.utility/push-javadoc-to-gh-pages.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-# This script was originally written by maxiaohao in the aws-mock GitHub project.
-# https://github.com/treelogic-swe/aws-mock/
-
-if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
-
- echo "Start to publish lastest Javadoc to gh-pages..."
-
- cd build/
-
- if test -d gh-pages/avian-web
- then
- cd gh-pages/avian-web
- git pull
- else
- git clone --quiet https://${GH_TOKEN}@github.com/ReadyTalk/readytalk.github.io gh-pages > /dev/null
- cd gh-pages/avian-web
- git config user.email "travis@travis-ci.org"
- git config user.name "travis-ci"
- fi
-
- git rm -rf ./javadoc
- cp -Rf ../javadoc ./javadoc
- git add -f .
- git commit -m "Latest javadoc on successful Travis build $TRAVIS_BUILD_NUMBER auto-pushed to readytalk.github.io"
- if ! git push -fq origin master &> /dev/null; then
- echo "Error pushing gh-pages to origin. Bad GH_TOKEN? GitHub down?"
- else
- echo "Done magic with auto publishment to readytalk.github.io."
- fi
-fi
diff --git a/sgx-jvm/avian/CMakeLists.txt b/sgx-jvm/avian/CMakeLists.txt
deleted file mode 100644
index 19c4b900b6..0000000000
--- a/sgx-jvm/avian/CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-# NOTE that this CMake file doesn't current build all of avian.
-# It only builds what's required for example/kaleidoscope.
-
-cmake_minimum_required (VERSION 2.6)
-project (avian)
-
-include_directories (include src)
-
-add_definitions (
- -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_MACHO
-
- -DAVIAN_TARGET_ARCH=AVIAN_ARCH_X86_64
-
- -DTARGET_BYTES_PER_WORD=8
- -D__STDC_LIMIT_MACROS
- -D__STDC_CONSTANT_MACROS
-)
-
-include ("cmake/Platform.cmake")
-
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CXX_FLAGS}")
-
-include (CTest)
-
-# Sadly, we can't use the 'test' target, as that's coopted by ctest
-add_custom_target(check ${CMAKE_CTEST_COMMAND} -V)
-
-add_subdirectory (src)
-add_subdirectory (unittest)
diff --git a/sgx-jvm/avian/LICENSE.txt b/sgx-jvm/avian/LICENSE.txt
deleted file mode 100644
index 71731a35a9..0000000000
--- a/sgx-jvm/avian/LICENSE.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-ISC License
-
-Copyright (c) 2008-2015, Avian Contributors
-
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/sgx-jvm/avian/README.md b/sgx-jvm/avian/README.md
deleted file mode 100644
index 80434004dc..0000000000
--- a/sgx-jvm/avian/README.md
+++ /dev/null
@@ -1,750 +0,0 @@
-Avian - A lightweight Java Virtual Machine (JVM)
-================================================
-
-[](https://travis-ci.org/ReadyTalk/avian)
-
-Quick Start
------------
-
-These are examples of building Avian on various operating systems for
-the x86_64 architecture. You may need to modify JAVA_HOME according
-to where the JDK is installed on your system. In all cases, be sure
-to use forward slashes in the path.
-
-#### on Linux:
- $ export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
- $ make
- $ build/linux-x86_64/avian -cp build/linux-x86_64/test Hello
-
-#### on Mac OS X:
- $ export JAVA_HOME=$(/usr/libexec/java_home)
- $ make
- $ build/macosx-x86_64/avian -cp build/macosx-x86_64/test Hello
-
-#### on Windows (Cygwin):
- $ git clone git@github.com:ReadyTalk/win64.git ../win64
- $ export JAVA_HOME="/cygdrive/c/Program Files/Java/jdk1.7.0_45"
- $ make
- $ build/windows-x86_64/avian -cp build/windows-x86_64/test Hello
-
-#### on FreeBSD:
- $ export JAVA_HOME=/usr/local/openjdk7
- $ gmake
- $ build/freebsd-x86_64/avian -cp build/freebsd-x86_64/test Hello
-
-
-Introduction
-------------
-
-Avian is a lightweight virtual machine and class library designed to
-provide a useful subset of Java's features, suitable for building
-self-contained applications. More information is available at the
-project [web site](http://readytalk.github.io/avian).
-
-If you have any trouble building, running, or embedding Avian, please
-post a message to our [discussion group](http://groups.google.com/group/avian).
-
-That's also the place for any other questions, comments, or
-suggestions you might have.
-
-
-Supported Platforms
--------------------
-
-Avian can currently target the following platforms:
-
- * Linux (i386, x86_64, ARM, and ARM64)
- * Windows (i386 and x86_64)
- * Mac OS X (i386 and x86_64)
- * Apple iOS (i386, x86_64, ARM, and ARM64)
- * FreeBSD (i386, x86_64)
-
-
-Building
---------
-
-Build requirements include:
-
- * GNU make 3.80 or later
- * GCC 4.6 or later
- or LLVM Clang 3.1 or later (see use-clang option below)
- * JDK 1.6 or later
- * MinGW 3.4 or later (only if compiling for Windows)
- * zlib 1.2.3 or later
-
-Earlier versions of some of these packages may also work but have not
-been tested.
-
-The build is directed by a single makefile and may be influenced via
-certain flags described below, all of which are optional.
-
- $ make \
- platform={linux,windows,macosx,ios,freebsd} \
- arch={i386,x86_64,arm,arm64} \
- process={compile,interpret} \
- mode={debug,debug-fast,fast,small} \
- lzma= \
- bootimage={true,false} \
- tails={true,false} \
- continuations={true,false} \
- use-clang={true,false} \
- openjdk= \
- openjdk-src= \
- android=
-
- * `platform` - the target platform
- * _default:_ output of $(uname -s | tr [:upper:] [:lower:]),
-normalized in some cases (e.g. CYGWIN_NT-5.1 -> windows)
-
- * `arch` - the target architecture
- * _default:_ output of $(uname -m), normalized in some cases
-(e.g. i686 -> i386)
-
- * `process` - choice between pure interpreter or JIT compiler
- * _default:_ compile
-
- * `mode` - which set of compilation flags to use to determine
-optimization level, debug symbols, and whether to enable
-assertions
- * _default:_ fast
-
- * `lzma` - if set, support use of LZMA to compress embedded JARs and
-boot images. The value of this option should be a directory
-containing a recent LZMA SDK (available [here](http://www.7-zip.org/sdk.html)). Currently, only version 9.20 of
-the SDK has been tested, but other versions might work.
- * _default:_ not set
-
- * `armv6` - if true, don't use any instructions newer than armv6. By
-default, we assume the target is armv7 or later, and thus requires explicit
-memory barrier instructions to ensure cache coherency
-
- * `bootimage` - if true, create a boot image containing the pre-parsed
-class library and ahead-of-time compiled methods. This option is
-only valid for process=compile builds. Note that you may need to
-specify both build-arch=x86_64 and arch=x86_64 on 64-bit systems
-where "uname -m" prints "i386".
- * _default:_ false
-
- * `tails` - if true, optimize each tail call by replacing the caller's
-stack frame with the callee's. This convention ensures proper
-tail recursion, suitable for languages such as Scheme. This
-option is only valid for process=compile builds.
- * _default:_ false
-
- * `continuations` - if true, support continuations via the
-avian.Continuations methods callWithCurrentContinuation and
-dynamicWind. See Continuations.java for details. This option is
-only valid for process=compile builds.
- * _default:_ false
-
- * `use-clang` - if true, use LLVM's clang instead of GCC to build.
-Note that this does not currently affect cross compiles, only
-native builds.
- * _default:_ false
-
- * `openjdk` - if set, use the OpenJDK class library instead of the
-default Avian class library. See "Building with the OpenJDK Class
-Library" below for details.
- * _default:_ not set
-
- * `openjdk-src` - if this and the openjdk option above are both set,
-build an embeddable VM using the OpenJDK class library. The JNI
-components of the OpenJDK class library will be built from the
-sources found under the specified directory. See "Building with
-the OpenJDK Class Library" below for details.
- * _default:_ not set
-
- * `android` - if set, use the Android class library instead of the
-default Avian class library. See "Building with the Android Class
-Library" below for details.
- * _default:_ not set
-
-These flags determine the name of the directory used for the build.
-The name always starts with _${platform}-${arch}_, and each non-default
-build option is appended to the name. For example, a debug build with
-bootimage enabled on Linux/x86_64 would be built in
-_build/linux-x86_64-debug-bootimage_. This allows you to build with
-several different sets of options independently and even
-simultaneously without doing a clean build each time.
-
-Note that not all combinations of these flags are valid. For instance,
-non-jailbroken iOS devices do not allow JIT compilation, so only
-process=interpret or bootimage=true builds will run on such
-devices. See [here](https://github.com/ReadyTalk/hello-ios) for an
-example of an Xcode project for iOS which uses Avian.
-
-If you are compiling for Windows, you may either cross-compile using
-MinGW or build natively on Windows under Cygwin.
-
-#### Installing Cygwin:
-
- __1.__ Download and run setup.exe from [cygwin's website](http://www.cygwin.com), installing the base
- system and these packages: make, gcc-mingw-g++,
- mingw64-i686-gcc-g++, mingw64-x86_64-gcc-g++, and (optionally) git.
-
-You may also find our win32 repository useful: (run this from the
-directory containing the avian directory)
-
- $ git clone git@github.com:ReadyTalk/win32.git
-
-This gives you the Windows JNI headers, zlib headers and library, and
-a few other useful libraries like OpenSSL, libjpeg, and libpng.
-There's also a win64 repository for 64-bit builds:
-
- $ git clone git@github.com:ReadyTalk/win64.git
-
-
-Building with the Microsoft Visual C++ Compiler
------------------------------------------------
-
-You can also build using the MSVC compiler, which makes debugging with
-tools like WinDbg and Visual Studio much easier. Note that you will
-still need to have GCC installed - MSVC is only used to compile the
-C++ portions of the VM, while the assembly code and helper tools are
-built using GCC.
-
-*Note that the MSVC build isn't tested regularly, so is fairly likely to be broken.*
-
-Avian targets MSVC 11 and above (it uses c++ features not available in older versions).
-
-To build with MSVC, install Cygwin as described above and set the
-following environment variables:
-
- $ export PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/Program Files/Microsoft Visual Studio 11.0/Common7/IDE:/cygdrive/c/Program Files/Microsoft Visual Studio 11.0/VC/BIN:/cygdrive/c/Program Files/Microsoft Visual Studio 11.0/Common7/Tools:/cygdrive/c/WINDOWS/Microsoft.NET/Framework/v3.5:/cygdrive/c/WINDOWS/Microsoft.NET/Framework/v2.0.50727:/cygdrive/c/Program Files/Microsoft Visual Studio 11.0/VC/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v6.0A/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem"
- $ export LIBPATH="C:\WINDOWS\Microsoft.NET\Framework\v3.5;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 11.0\VC\LIB;"
- $ export VCINSTALLDIR="C:\Program Files\Microsoft Visual Studio 11.0\VC"
- $ export LIB="C:\Program Files\Microsoft Visual Studio 11.0\VC\LIB;C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib;"
- $ export INCLUDE="C:\Program Files\Microsoft Visual Studio 11.0\VC\INCLUDE;C:\Program Files\Microsoft SDKs\Windows\v6.0A\include;"
-
-Adjust these definitions as necessary according to your MSVC
-installation.
-
-Finally, build with the msvc flag set to the MSVC tool directory:
-
- $ make msvc="/cygdrive/c/Program Files/Microsoft Visual Studio 11.0/VC"
-
-
-Building with the OpenJDK Class Library
----------------------------------------
-
-By default, Avian uses its own lightweight class library. However,
-that library only contains a relatively small subset of the classes
-and methods included in the JRE. If your application requires
-features beyond that subset, you may want to tell Avian to use
-OpenJDK's class library instead. To do so, specify the directory
-where OpenJDK is installed, e.g.:
-
- $ make openjdk=/usr/lib/jvm/java-7-openjdk
-
-This will build Avian as a conventional JVM (e.g. libjvm.so) which
-loads its boot class library and native libraries (e.g. libjava.so)
-from _/usr/lib/jvm/java-7-openjdk/jre_ at runtime. Note that you must
-use an absolute path here, or else the result will not work when run
-from other directories. In this configuration, OpenJDK needs to
-remain installed for Avian to work, and you can run applications like
-this:
-
- $ build/linux-x86_64-openjdk/avian-dynamic -cp /path/to/my/application \
- com.example.MyApplication
-
-Alternatively, you can enable a stand-alone build using OpenJDK by
-specifying the location of the OpenJDK source code, e.g.:
-
- $ make openjdk=$(pwd)/../jdk7/build/linux-amd64/j2sdk-image \
- openjdk-src=$(pwd)/../jdk7/jdk/src
-
-You must ensure that the path specified for openjdk-src does not have
-any spaces in it; make gets confused when dependency paths include
-spaces, and we haven't found away around that except to avoid paths
-with spaces entirely.
-
-The result of such a build is a self-contained binary which does not
-depend on external libraries, jars, or other files. In this case, the
-specified paths are used only at build time; anything needed at
-runtime is embedded in the binary. Thus, the process of running an
-application is simplified:
-
- $ build/linux-x86_64-openjdk-src/avian -cp /path/to/my/application \
- com.example.MyApplication
-
-Note that the resulting binary will be very large due to the size of
-OpenJDK's class library. This can be mitigated using UPX, preferably
-an LZMA-enabled version:
-
- $ upx --lzma --best build/linux-x86_64-openjdk-src/avian
-
-You can reduce the size futher for embedded builds by using ProGuard
-and the supplied openjdk.pro configuration file (see "Embedding with
-ProGuard and a Boot Image" below). Note that you'll still need to use
-vm.pro in that case -- openjdk.pro just adds additional constraints
-specific to the OpenJDK port. Also see
-[app.mk](https://github.com/ReadyTalk/avian-swt-examples/blob/master/app.mk)
-in the _avian-swt-examples_ project for an example of using Avian,
-OpenJDK, ProGuard, and UPX in concert.
-
-Here are some examples of how to install OpenJDK and build Avian with
-it on various OSes:
-
-#### Debian-based Linux:
-_Conventional build:_
-
- $ apt-get install openjdk-7-jdk
- $ make openjdk=/usr/lib/jvm/java-7-openjdk test
-
-_Stand-alone build:_
-
- $ apt-get install openjdk-7-jdk
- $ apt-get source openjdk-7-jdk
- $ apt-get build-dep openjdk-7-jdk
- $ (cd openjdk-7-7~b147-2.0 && dpkg-buildpackage)
- $ make openjdk=/usr/lib/jvm/java-7-openjdk \
- openjdk-src=$(pwd)/openjdk-7-7~b147-2.0/build/openjdk/jdk/src \
- test
-
-####Mac OS X:
-_Prerequisite:_ Build OpenJDK 7 according to [this site](https://wikis.oracle.com/display/OpenJDK/Mac+OS+X+Port).
-
-_Conventional build:_
-
- $ make openjdk=$(pwd)/../jdk7u-dev/build/macosx-amd64/j2sdk-image test
-
-_Stand-alone build:_
-
- $ make openjdk=$(pwd)/../jdk7u-dev/build/macosx-amd64/j2sdk-image \
- openjdk-src=$(pwd)/../p/jdk7u-dev/jdk/src test
-
-####Windows (Cygwin):
-_Prerequisite:_ Build OpenJDK 7 according to [this site](http://weblogs.java.net/blog/simonis/archive/2011/10/28/yaojowbi-yet-another-openjdk-windows-build-instruction). Alternatively, use https://github.com/alexkasko/openjdk-unofficial-builds.
-
-_Conventional build:_
-
- $ make openjdk=$(pwd)/../jdk7u-dev/build/windows-i586/j2sdk-image test
-
-_Stand-alone build:_
-
- $ make openjdk=$(pwd)/../jdk7u-dev/build/windows-i586/j2sdk-image \
- openjdk-src=$(pwd)/../p/jdk7u-dev/jdk/src test
-
-Currently, only OpenJDK 7 is supported. Later versions might work,
-but have not yet been tested.
-
-
-Building with the Android Class Library
----------------------------------------
-As an alternative to both the Avian and OpenJDK class libaries, you
-can also build with the Android class library. Now it should work on Linux, OS X and Windows.
-
-The simpliest way to build Avian with Android classpath is to use `avian-pack` project: https://github.com/bigfatbrowncat/avian-pack
-
-Avian-pack consists of Avian itself with some Android components (such as libcore and icu4c).
-
-Note that we use the upstream OpenSSL repository and apply the
-Android patches to it. This is because it is not clear how to build
-the Android fork of OpenSSL directly without checking out and building
-the entire platform. As of this writing, the patches apply cleanly
-against OpenSSL 1.0.1h, so that's the tag we check out, but this may
-change in the future when the Android fork rebases against a new
-OpenSSL version.
-
-Installing
-----------
-
-Installing Avian is as simple as copying the executable to the desired
-directory:
-
- $ cp build/${platform}-${arch}/avian ~/bin/
-
-
-Embedding
----------
-
-The following series of commands illustrates how to produce a
-stand-alone executable out of a Java application using Avian.
-
-Note: if you are building on Cygwin, prepend "x86_64-w64-mingw32-" or
-"i686-w64-mingw32-" to the ar, g++, gcc, strip, and dlltool commands
-below (e.g. x86_64-w64-mingw32-gcc).
-
-__1.__ Build Avian, create a new directory, and populate it with the
-VM object files and bootstrap classpath jar.
-
- $ make
- $ mkdir hello
- $ cd hello
- $ ar x ../build/${platform}-${arch}/libavian.a
- $ cp ../build/${platform}-${arch}/classpath.jar boot.jar
-
-__2.__ Build the Java code and add it to the jar.
-
- $ cat >Hello.java <embedded-jar-main.cpp <("-Xbootclasspath:[bootJar]");
-
- JavaVM* vm;
- void* env;
- JNI_CreateJavaVM(&vm, &env, &vmArgs);
- JNIEnv* e = static_cast(env);
-
- jclass c = e->FindClass("Hello");
- if (not e->ExceptionCheck()) {
- jmethodID m = e->GetStaticMethodID(c, "main", "([Ljava/lang/String;)V");
- if (not e->ExceptionCheck()) {
- jclass stringClass = e->FindClass("java/lang/String");
- if (not e->ExceptionCheck()) {
- jobjectArray a = e->NewObjectArray(ac-1, stringClass, 0);
- if (not e->ExceptionCheck()) {
- for (int i = 1; i < ac; ++i) {
- e->SetObjectArrayElement(a, i-1, e->NewStringUTF(av[i]));
- }
-
- e->CallStaticVoidMethod(c, m, a);
- }
- }
- }
- }
-
- int exitCode = 0;
- if (e->ExceptionCheck()) {
- exitCode = -1;
- e->ExceptionDescribe();
- }
-
- vm->DestroyJavaVM();
-
- return exitCode;
- }
- EOF
-
-__on Linux:__
-
- $ g++ -I$JAVA_HOME/include -I$JAVA_HOME/include/linux \
- -D_JNI_IMPLEMENTATION_ -c embedded-jar-main.cpp -o main.o
-
-__on Mac OS X:__
-
- $ g++ -I$JAVA_HOME/include -I$JAVA_HOME/include/darwin \
- -D_JNI_IMPLEMENTATION_ -c embedded-jar-main.cpp -o main.o
-
-__on Windows:__
-
- $ g++ -fno-exceptions -fno-rtti -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/win32" \
- -D_JNI_IMPLEMENTATION_ -c embedded-jar-main.cpp -o main.o
-
-__5.__ Link the objects produced above to produce the final
-executable, and optionally strip its symbols.
-
-__on Linux:__
-
- $ g++ -rdynamic *.o -ldl -lpthread -lz -o hello
- $ strip --strip-all hello
-
-__on Mac OS X:__
-
- $ g++ -rdynamic *.o -ldl -lpthread -lz -o hello -framework CoreFoundation
- $ strip -S -x hello
-
-__on Windows:__
-
- $ dlltool -z hello.def *.o
- $ dlltool -d hello.def -e hello.exp
- $ gcc hello.exp *.o -L../../win32/lib -lmingwthrd -lm -lz -lws2_32 \
- -lIphlpapi -mwindows -mconsole -o hello.exe
- $ strip --strip-all hello.exe
-
-Embedding with ProGuard and a Boot Image
-----------------------------------------
-
-The following illustrates how to embed an application as above, except
-this time we preprocess the code using ProGuard and build a boot image
-from it for quicker startup. The pros and cons of using ProGuard are
-as follow:
-
- * Pros: ProGuard will eliminate unused code, optimize the rest, and
- obfuscate it as well for maximum space savings
-
- * Cons: increased build time, especially for large applications, and
- extra effort needed to configure it for applications which rely
- heavily on reflection and/or calls to Java from native code
-
-For boot image builds:
-
- * Pros: the boot image build pre-parses all the classes and compiles
- all the methods, obviating the need for JIT compilation at runtime.
- This also makes garbage collection faster, since the pre-parsed
- classes are never visited.
-
- * Cons: the pre-parsed classes and AOT-compiled methods take up more
- space in the executable than the equivalent class files. In
- practice, this can make the executable 30-50% larger. Also, AOT
- compilation does not yet yield significantly faster or smaller code
- than JIT compilation. Finally, floating point code may be slower
- on 32-bit x86 since the compiler cannot assume SSE2 support will be
- available at runtime, and the x87 FPU is not supported except via
- out-of-line helper functions.
-
-Note you can use ProGuard without using a boot image and vice-versa,
-as desired.
-
-The following instructions assume we are building for Linux/x86_64.
-Please refer to the previous example for guidance on other platforms.
-
-__1.__ Build Avian, create a new directory, and populate it with the
-VM object files.
-
- $ make bootimage=true
- $ mkdir hello
- $ cd hello
- $ ar x ../build/linux-x86_64-bootimage/libavian.a
-
-__2.__ Create a stage1 directory and extract the contents of the
-class library jar into it.
-
- $ mkdir stage1
- $ (cd stage1 && jar xf ../../build/linux-x86_64-bootimage/classpath.jar)
-
-__3.__ Build the Java code and add it to stage1.
-
- $ cat >Hello.java <hello.pro <bootimage-main.cpp <("-Davian.bootimage=bootimageBin");
-
- options[1].optionString
- = const_cast("-Davian.codeimage=codeimageBin");
-
- JavaVM* vm;
- void* env;
- JNI_CreateJavaVM(&vm, &env, &vmArgs);
- JNIEnv* e = static_cast(env);
-
- jclass c = e->FindClass("Hello");
- if (not e->ExceptionCheck()) {
- jmethodID m = e->GetStaticMethodID(c, "main", "([Ljava/lang/String;)V");
- if (not e->ExceptionCheck()) {
- jclass stringClass = e->FindClass("java/lang/String");
- if (not e->ExceptionCheck()) {
- jobjectArray a = e->NewObjectArray(ac-1, stringClass, 0);
- if (not e->ExceptionCheck()) {
- for (int i = 1; i < ac; ++i) {
- e->SetObjectArrayElement(a, i-1, e->NewStringUTF(av[i]));
- }
-
- e->CallStaticVoidMethod(c, m, a);
- }
- }
- }
- }
-
- int exitCode = 0;
- if (e->ExceptionCheck()) {
- exitCode = -1;
- e->ExceptionDescribe();
- }
-
- vm->DestroyJavaVM();
-
- return exitCode;
- }
- EOF
-
- $ g++ -I$JAVA_HOME/include -I$JAVA_HOME/include/linux \
- -D_JNI_IMPLEMENTATION_ -c bootimage-main.cpp -o main.o
-
-__8.__ Link the objects produced above to produce the final
- executable, and optionally strip its symbols.
-
- $ g++ -rdynamic *.o -ldl -lpthread -lz -o hello
- $ strip --strip-all hello
-
-
-Trademarks
-----------
-
-Oracle and Java are registered trademarks of Oracle and/or its
-affiliates. Other names may be trademarks of their respective owners.
-
-The Avian project is not affiliated with Oracle.
diff --git a/sgx-jvm/avian/android.pro b/sgx-jvm/avian/android.pro
deleted file mode 100644
index 00941ff874..0000000000
--- a/sgx-jvm/avian/android.pro
+++ /dev/null
@@ -1,89 +0,0 @@
-# these are referenced in JniConstants.cpp:
-
--keep class java.text.Bidi$Run
--keep class java.math.BigDecimal
--keep class java.lang.Boolean
--keep class java.lang.Byte
--keep class java.nio.charset.CharsetICU {
- CharsetICU(java.lang.String, java.lang.String, java.lang.String[]);
- }
--keep class java.lang.reflect.Constructor
--keep class java.util.zip.Deflater
--keep class java.lang.Double
--keep class libcore.io.ErrnoException
--keep class java.lang.reflect.Field
--keep class libcore.icu.NativeDecimalFormat$FieldPositionIterator {
- void setData(int[]);
- }
--keep class java.io.FileDescriptor
--keep class libcore.io.GaiException
--keep class java.net.Inet6Address
--keep class java.net.InetAddress
--keep class java.net.InetSocketAddress
--keep class java.net.InetUnixAddress
--keep class java.util.zip.Inflater
--keep class java.lang.Integer
--keep class libcore.icu.LocaleData
--keep class java.lang.Long
--keep class java.lang.reflect.Method
--keep class libcore.util.MutableInt
--keep class libcore.util.MutableLong
--keep class java.text.ParsePosition
--keep class java.util.regex.PatternSyntaxException
--keep class java.lang.RealToString
--keep class java.net.Socket
--keep class java.net.SocketImpl
--keep class java.lang.String
--keep class libcore.io.StructAddrinfo {
- ;
- }
--keep class libcore.io.StructFlock
--keep class libcore.io.StructGroupReq
--keep class libcore.io.StructLinger
--keep class libcore.io.StructPasswd {
- StructPasswd(java.lang.String, int, int, java.lang.String, java.lang.String);
- }
--keep class libcore.io.StructPollfd
--keep class libcore.io.StructStat {
- StructStat(long, long, int, long, int, int, long, long, long, long, long, long, long);
- }
--keep class libcore.io.StructStatFs
--keep class libcore.io.StructTimeval
--keep class libcore.io.StructUtsname {
- StructUtsname(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String);
- }
--keep class libcore.io.StructUcred
-
-# referenced from libcore native code
-
--keep class libcore.icu.LocaleData {
- ;
- }
-
--keep class org.conscrypt.OpenSSLBIOInputStream {
- ;
- }
-
--keep class java.util.Calendar {
- void set(int, int, int, int, int, int);
- }
-
-# called from the VM
-
--keep class java.lang.Thread {
- Thread(java.lang.ThreadGroup, java.lang.String, int, boolean);
- }
-
--keep class avian.Classes {
- java.lang.Class forName(java.lang.String, boolean, java.lang.ClassLoader);
- int findField(avian.VMClass, java.lang.String);
- int findMethod(avian.VMClass, java.lang.String, java.lang.Class[]);
- java.lang.annotation.Annotation getAnnotation(java.lang.ClassLoader, java.lang.Object[]);
- }
-
--keep class java.lang.VMThread {
- VMThread(java.lang.Thread);
- }
-
-# loaded reflectively to handle embedded resources:
--keep class avian.avianvmresource.Handler
diff --git a/sgx-jvm/avian/build.gradle b/sgx-jvm/avian/build.gradle
deleted file mode 100644
index 7c49e302bc..0000000000
--- a/sgx-jvm/avian/build.gradle
+++ /dev/null
@@ -1,323 +0,0 @@
-buildscript {
- repositories {
- jcenter()
- }
-
- dependencies {
- classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.4'
- }
-}
-
-apply plugin: 'native-component'
-apply plugin: 'ivy-publish'
-apply plugin: 'java'
-apply plugin: 'artifactory-publish'
-
-enum SupportedOS implements OperatingSystem {
- LINUX, WINDOWS, MACOSX;
-
- public static final SupportedOS CURRENT;
-
- static {
- String p = System.properties['os.name']
- switch(p.replaceAll(' ', '').toLowerCase()) {
- case ~/.*linux.*/: CURRENT = LINUX; break;
- case ~/.*darwin.*/: CURRENT = MACOSX; break;
- case ~/.*osx.*/: CURRENT = MACOSX; break;
- case ~/.*win.*/: CURRENT = WINDOWS; break;
- default:
- String m = "SupportedOS: unrecognized platform: ${p}"
- println(m)
- throw new IllegalArgumentException(m)
- }
- }
-
- public String getName() {
- return toString().toLowerCase()
- }
-
- public String getDisplayName() {
- return getName()
- }
- public boolean isCurrent() { return this == CURRENT }
- public boolean isFreeBSD() { return false }
- public boolean isLinux() { return this == LINUX }
- public boolean isMacOsX() { return this == MACOSX }
- public boolean isSolaris() { return false }
- public boolean isWindows() { return this == WINDOWS }
-
-}
-
-public String adjustArch(String arch) {
- switch(arch) {
- case ~/.*64.*/: return 'x86_64'
- default: return 'i386'
- }
-}
-
-ext {
- currentPlatform = SupportedOS.CURRENT.getName()
- currentArch = adjustArch(System.properties['os.arch'])
- currentPlatformArch = "${currentPlatform}-${currentArch}"
-
- platform = project.hasProperty('platform') ? platform : currentPlatform
- arch = project.hasProperty('arch') ? arch : currentArch
- platformArch = "${platform}-${arch}"
-
- java_home = System.properties.'java.home'
- if(java_home.endsWith("/jre")) {
- java_home = java_home.substring(0, java_home.length() - "/jre".length())
- }
- java_home = java_home
-
- libDir = "${buildDir}/lib"
- lzmaDir = "${libDir}/lzma"
-
- buildOptions = ['', '-lzma']
-}
-
-repositories {
- ivy {
- name "ivyLocal"
- url "${System.env.HOME}/.ivy2/local"
- layout 'maven'
- }
-
- ivy {
- name "jcenter"
- if(version.contains("SNAPSHOT")) {
- url "http://oss.jfrog.org/artifactory/oss-snapshot-local"
- } else {
- url "http://oss.jfrog.org/artifactory/oss-release-local"
- }
- layout 'maven'
- }
-}
-
-configurations {
- create('windows-i386')
- create('windows-x86_64')
-}
-
-dependencies {
- 'windows-i386' "com.readytalk:win32:1.0.0-SNAPSHOT"
- 'windows-x86_64' "com.readytalk:win64:1.0.0-SNAPSHOT"
-}
-
-model {
- platforms {
- create(platformArch) {
- operatingSystem SupportedOS.valueOf(platform.toUpperCase())
- architecture "${arch}"
- }
- }
-
- tasks {
- buildOptions.each { buildOption ->
- platforms.each { platform ->
- if(platform.operatingSystem.name == "windows") {
- def artifactName = platform.architecture.name == "i386" ? 'win32' : 'win64'
-
- task "extract${platform.name}${buildOption}"(type: Copy) {
- from {
- tarTree(configurations."${platform.name}".find { it.name =~ artifactName })
- }
- into "${libDir}/tools"
- }
- }
-
- task "build${platform.name}${buildOption}"(type: Exec) {
- executable "make"
- args "platform=${platform.operatingSystem.name}",
- "arch=${platform.architecture.name}"
-
- if(buildOption == "-lzma") {
- dependsOn 'extractLzma'
- args "lzma=${lzmaDir}"
- }
-
- if(platform.operatingSystem.name == "windows") {
- dependsOn "extract${platform.name}${buildOption}"
- args "win32=${libDir}/tools/win32",
- "win64=${libDir}/tools/win64"
- }
- environment JAVA_HOME: java_home
- }
-
- assemble {
- dependsOn "build${platform.name}${buildOption}"
- }
- }
- }
- }
-}
-
-tasks.withType(JavaCompile) {
- sourceCompatibility = "1.6"
- targetCompatibility = "1.6"
-
- options.with {
- encoding = "UTF-8"
- bootClasspath = sourceSets.main.output.classesDir
- }
-}
-
-sourceSets {
- main {
- java {
- srcDir 'classpath'
- }
- }
-}
-
-javadoc {
- title = "Avian v${version} Class Library API"
-}
-
-task javadocJar(type: Jar) {
- dependsOn javadoc
- classifier = 'javadoc'
- from {
- javadoc.destinationDir
- }
-}
-
-jar {
- baseName "classpath-avian"
-}
-
-task downloadLzma(type: Exec) {
- commandLine "curl"
- args "--create-dirs", "-o", "${lzmaDir}/lzma920.tar.bz2", "-f", "http://oss.readytalk.com/avian-web/lzma920.tar.bz2"
-}
-
-task extractLzma(type: Copy) {
- dependsOn downloadLzma
- from {
- tarTree(resources.bzip2("${lzmaDir}/lzma920.tar.bz2"))
- }
- into lzmaDir
-}
-
-task install {
- dependsOn assemble, publish
-}
-
-publishing {
- repositories {
- add(project.repositories."ivyLocal")
- }
-
- publications {
-
- ivy(IvyPublication) {
- from components.java
-
- artifact(javadocJar)
-
- artifact("vm.pro") {
- name "vm"
- type "proguard"
- extension "pro"
- }
-
- module "classpath-avian"
- }
-
- create("tools-avian-${currentPlatformArch}", IvyPublication) {
- module "tools-avian-${currentPlatformArch}"
-
- def publishBinSuffix = currentPlatform == "windows" ? "exe" : "bin"
- def binSuffix = currentPlatform == "windows" ? ".exe" : ""
- artifact("${buildDir}/${currentPlatform}-${currentArch}/binaryToObject/binaryToObject${binSuffix}") {
- name "binaryToObject"
- type publishBinSuffix
- extension publishBinSuffix
- }
- }
-
- buildOptions.each { buildOption ->
- platforms.each { platform ->
- def binSuffix=""
- def publishBinSuffix="bin"
-
- create("${platform.name}${buildOption}", IvyPublication) {
- def nativeBuildDir = "${buildDir}/${platform.operatingSystem.name}-${platform.architecture.name}${buildOption}"
-
- if(platform.operatingSystem.name == "windows") {
- publishBinSuffix = "exe"
- binSuffix = ".${publishBinSuffix}"
- }
-
- module "runtime-avian${buildOption}-${platform.name}"
-
- artifact("${nativeBuildDir}/avian${binSuffix}") {
- name "avian"
- type publishBinSuffix
- extension publishBinSuffix
- }
-
- artifact("${nativeBuildDir}/libavian.a") {
- name "libavian"
- type "a"
- extension "a"
- }
-
- if (buildOption == "-lzma") {
- artifact("${nativeBuildDir}/libavian-lzma.a") {
- name "libavian-lzma"
- type "a"
- extension "a"
- }
-
- artifact("${nativeBuildDir}/lzma/lzma${binSuffix}") {
- name "lzma"
- type publishBinSuffix
- extension publishBinSuffix
- }
- }
- }
- }
- }
- }
-}
-
-artifactoryPublish {
- onlyIf {
- // TRAVIS_BRANCH reports master if it is a master build or a PR going to master
- // TRAVIS_PULL_REQUEST reports false if not a pull request and the PR number if it is
- System.env.'TRAVIS_BRANCH' == "master" && System.env.'TRAVIS_PULL_REQUEST' == "false"
- }
- dependsOn assemble
-}
-
-artifactory {
- contextUrl = "http://oss.jfrog.org"
-
- resolve {
- repository {
- repoKey = 'libs-releases'
- }
- }
-
- publish {
- repository {
- repoKey = 'oss-snapshot-local'
- username = System.env.BINTRAY_USER
- password = System.env.BINTRAY_API_KEY
- ivy {
- ivyLayout = "[organisation]/[module]/[revision]/ivy-[revision].xml"
- }
- }
-
- defaults {
- platforms.each {
- publications it.name
- }
- }
- }
-}
-
-task wrapper(type: Wrapper) {
- distributionUrl = 'http://services.gradle.org/distributions/gradle-2.0-bin.zip'
-}
diff --git a/sgx-jvm/avian/classpath/avian/Addendum.java b/sgx-jvm/avian/classpath/avian/Addendum.java
deleted file mode 100644
index 79c9a75577..0000000000
--- a/sgx-jvm/avian/classpath/avian/Addendum.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright (c) 2008-2015, Avian Contributors
-
- Permission to use, copy, modify, and/or distribute this software
- for any purpose with or without fee is hereby granted, provided
- that the above copyright notice and this permission notice appear
- in all copies.
-
- There is NO WARRANTY for this software. See license.txt for
- details. */
-
-package avian;
-
-public class Addendum {
- public Singleton pool;
- public Object annotationTable;
- public Object signature;
-}
diff --git a/sgx-jvm/avian/classpath/avian/AnnotationInvocationHandler.java b/sgx-jvm/avian/classpath/avian/AnnotationInvocationHandler.java
deleted file mode 100644
index a15e716f2e..0000000000
--- a/sgx-jvm/avian/classpath/avian/AnnotationInvocationHandler.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (c) 2008-2015, Avian Contributors
-
- Permission to use, copy, modify, and/or distribute this software
- for any purpose with or without fee is hereby granted, provided
- that the above copyright notice and this permission notice appear
- in all copies.
-
- There is NO WARRANTY for this software. See license.txt for
- details. */
-
-package avian;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationHandler;
-
-public class AnnotationInvocationHandler implements InvocationHandler {
- private Object[] data;
-
- public AnnotationInvocationHandler(Object[] data) {
- this.data = data;
- }
-
- public Object invoke(Object proxy, Method method, Object[] arguments) {
- String name = method.getName();
- for (int i = 2; i < data.length; i += 2) {
- if (name.equals(data[i])) {
- return data[i + 1];
- }
- }
- return method.getDefaultValue();
- }
-}
diff --git a/sgx-jvm/avian/classpath/avian/Assembler.java b/sgx-jvm/avian/classpath/avian/Assembler.java
deleted file mode 100644
index 64a06fdf81..0000000000
--- a/sgx-jvm/avian/classpath/avian/Assembler.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/* Copyright (c) 2008-2015, Avian Contributors
-
- Permission to use, copy, modify, and/or distribute this software
- for any purpose with or without fee is hereby granted, provided
- that the above copyright notice and this permission notice appear
- in all copies.
-
- There is NO WARRANTY for this software. See license.txt for
- details. */
-
-package avian;
-
-import static avian.Stream.write1;
-import static avian.Stream.write2;
-import static avian.Stream.write4;
-
-import avian.ConstantPool.PoolEntry;
-
-import java.util.List;
-import java.io.OutputStream;
-import java.io.IOException;
-
-public class Assembler {
- public static final int ACC_PUBLIC = 1 << 0;
- public static final int ACC_STATIC = 1 << 3;
-
- public static final int aaload = 0x32;
- public static final int aastore = 0x53;
- public static final int aload = 0x19;
- public static final int aload_0 = 0x2a;
- public static final int aload_1 = 0x2b;
- public static final int astore_0 = 0x4b;
- public static final int anewarray = 0xbd;
- public static final int areturn = 0xb0;
- public static final int dload = 0x18;
- public static final int dreturn = 0xaf;
- public static final int dup = 0x59;
- public static final int fload = 0x17;
- public static final int freturn = 0xae;
- public static final int getfield = 0xb4;
- public static final int goto_ = 0xa7;
- public static final int iload = 0x15;
- public static final int invokeinterface = 0xb9;
- public static final int invokespecial = 0xb7;
- public static final int invokestatic = 0xb8;
- public static final int invokevirtual = 0xb6;
- public static final int ireturn = 0xac;
- public static final int jsr = 0xa8;
- public static final int ldc_w = 0x13;
- public static final int lload = 0x16;
- public static final int lreturn = 0xad;
- public static final int new_ = 0xbb;
- public static final int pop = 0x57;
- public static final int putfield = 0xb5;
- public static final int ret = 0xa9;
- public static final int return_ = 0xb1;
-
- public static void writeClass(OutputStream out,
- List pool,
- int name,
- int super_,
- int[] interfaces,
- FieldData[] fields,
- MethodData[] methods)
- throws IOException
- {
- int codeAttributeName = ConstantPool.addUtf8(pool, "Code");
-
- write4(out, 0xCAFEBABE);
- write2(out, 0); // minor version
- write2(out, 50); // major version
-
- write2(out, pool.size() + 1);
- for (PoolEntry e: pool) {
- e.writeTo(out);
- }
-
- write2(out, ACC_PUBLIC); // flags
- write2(out, name + 1);
- write2(out, super_ + 1);
-
- write2(out, interfaces.length);
- for (int i: interfaces) {
- write2(out, i + 1);
- }
-
- write2(out, fields.length);
- for (FieldData f: fields) {
- write2(out, f.flags);
- write2(out, f.nameIndex + 1);
- write2(out, f.specIndex + 1);
- write2(out, 0); // attribute count
- }
-
- write2(out, methods.length);
- for (MethodData m: methods) {
- write2(out, m.flags);
- write2(out, m.nameIndex + 1);
- write2(out, m.specIndex + 1);
-
- write2(out, 1); // attribute count
- write2(out, codeAttributeName + 1);
- write4(out, m.code.length);
- out.write(m.code);
- }
-
- write2(out, 0); // attribute count
- }
-
- public static class MethodData {
- public final int flags;
- public final int nameIndex;
- public final int specIndex;
- public final byte[] code;
-
- public MethodData(int flags, int nameIndex, int specIndex, byte[] code) {
- this.flags = flags;
- this.nameIndex = nameIndex;
- this.specIndex = specIndex;
- this.code = code;
- }
- }
-
- public static class FieldData {
- public final int flags;
- public final int nameIndex;
- public final int specIndex;
-
- public FieldData(int flags, int nameIndex, int specIndex) {
- this.flags = flags;
- this.nameIndex = nameIndex;
- this.specIndex = specIndex;
- }
- }
-}
diff --git a/sgx-jvm/avian/classpath/avian/Atomic.java b/sgx-jvm/avian/classpath/avian/Atomic.java
deleted file mode 100644
index 53b52da665..0000000000
--- a/sgx-jvm/avian/classpath/avian/Atomic.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (c) 2008-2015, Avian Contributors
-
- Permission to use, copy, modify, and/or distribute this software
- for any purpose with or without fee is hereby granted, provided
- that the above copyright notice and this permission notice appear
- in all copies.
-
- There is NO WARRANTY for this software. See license.txt for
- details. */
-
-package avian;
-
-import java.lang.reflect.Field;
-
-public class Atomic {
- public static native long getOffset(Field field);
-
- public static native boolean compareAndSwapObject
- (Object o, long offset, Object old, Object new_);
-}
diff --git a/sgx-jvm/avian/classpath/avian/Callback.java b/sgx-jvm/avian/classpath/avian/Callback.java
deleted file mode 100644
index 57c0976452..0000000000
--- a/sgx-jvm/avian/classpath/avian/Callback.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright (c) 2008-2015, Avian Contributors
-
- Permission to use, copy, modify, and/or distribute this software
- for any purpose with or without fee is hereby granted, provided
- that the above copyright notice and this permission notice appear
- in all copies.
-
- There is NO WARRANTY for this software. See license.txt for
- details. */
-
-package avian;
-
-public interface Callback {
- public void handleResult(T result);
- public void handleException(Throwable exception);
-}
diff --git a/sgx-jvm/avian/classpath/avian/Cell.java b/sgx-jvm/avian/classpath/avian/Cell.java
deleted file mode 100644
index 1425955fec..0000000000
--- a/sgx-jvm/avian/classpath/avian/Cell.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (c) 2008-2015, Avian Contributors
-
- Permission to use, copy, modify, and/or distribute this software
- for any purpose with or without fee is hereby granted, provided
- that the above copyright notice and this permission notice appear
- in all copies.
-
- There is NO WARRANTY for this software. See license.txt for
- details. */
-
-package avian;
-
-public class Cell {
- public T value;
- public Cell next;
-
- public Cell(T value, Cell next) {
- this.value = value;
- this.next = next;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("(");
- for (Cell c = this; c != null; c = c.next) {
- sb.append(value);
- if (c.next != null) {
- sb.append(" ");
- }
- }
- sb.append(")");
- return sb.toString();
- }
-
- public static Cell cons(Car car, Cell cdr) {
- return new Cell(car, cdr);
- }
-
- public static boolean equal(T a, T b) {
- return (a == null && b == null) || (a != null && a.equals(b));
- }
-
- public static boolean equal(Cell a, Cell b) {
- while (a != null) {
- if (b == null || (! equal(a.value, b.value))) {
- return false;
- }
- a = a.next;
- b = b.next;
- }
-
- return b == null;
- }
-}
diff --git a/sgx-jvm/avian/classpath/avian/ClassAddendum.java b/sgx-jvm/avian/classpath/avian/ClassAddendum.java
deleted file mode 100644
index ef558b59c4..0000000000
--- a/sgx-jvm/avian/classpath/avian/ClassAddendum.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (c) 2008-2015, Avian Contributors
-
- Permission to use, copy, modify, and/or distribute this software
- for any purpose with or without fee is hereby granted, provided
- that the above copyright notice and this permission notice appear
- in all copies.
-
- There is NO WARRANTY for this software. See license.txt for
- details. */
-
-package avian;
-
-public class ClassAddendum extends Addendum {
- public Object[] interfaceTable;
- public InnerClassReference[] innerClassTable;
- /**
- * If this value is negative, all the methods in VMClass.methodTable
- * were declared in that class. Otherwise, only the first
- * declaredMethodCount methods in that table were declared in that
- * class, while the rest were declared in interfaces implemented or
- * extended by that class.
- */
- public int declaredMethodCount;
-
- public byte[] enclosingClass;
-
- public Pair enclosingMethod;
-
- public VMMethod[] bootstrapMethodTable;
-
- public VMMethod[] bootstrapLambdaTable;
-}
diff --git a/sgx-jvm/avian/classpath/avian/Classes.java b/sgx-jvm/avian/classpath/avian/Classes.java
deleted file mode 100644
index b827ab2c71..0000000000
--- a/sgx-jvm/avian/classpath/avian/Classes.java
+++ /dev/null
@@ -1,602 +0,0 @@
-/* Copyright (c) 2008-2015, Avian Contributors
-
- Permission to use, copy, modify, and/or distribute this software
- for any purpose with or without fee is hereby granted, provided
- that the above copyright notice and this permission notice appear
- in all copies.
-
- There is NO WARRANTY for this software. See license.txt for
- details. */
-
-package avian;
-
-import static avian.Stream.read1;
-import static avian.Stream.read2;
-
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.security.CodeSource;
-import java.security.AllPermission;
-import java.security.Permissions;
-import java.security.ProtectionDomain;
-import java.security.cert.Certificate;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Method;
-import java.lang.reflect.Field;
-import java.lang.reflect.Proxy;
-import java.lang.annotation.Annotation;
-import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-public class Classes {
- private static final int LinkFlag = 1 << 8;
-
- public static native VMClass defineVMClass
- (ClassLoader loader, byte[] b, int offset, int length);
-
- public static native VMClass primitiveClass(char name);
-
- public static native void initialize(VMClass vmClass);
-
- public static native boolean isAssignableFrom(VMClass a, VMClass b);
-
- public static native VMClass toVMClass(Class c);
-
- public static native VMMethod toVMMethod(Method m);
-
- private static native VMClass resolveVMClass(ClassLoader loader, byte[] spec)
- throws ClassNotFoundException;
-
- public static VMClass loadVMClass(ClassLoader loader,
- byte[] nameBytes, int offset, int length)
- {
- byte[] spec = new byte[length + 1];
- System.arraycopy(nameBytes, offset, spec, 0, length);
-
- try {
- VMClass c = resolveVMClass(loader, spec);
- if (c == null) {
- throw new NoClassDefFoundError();
- }
- return c;
- } catch (ClassNotFoundException e) {
- NoClassDefFoundError error = new NoClassDefFoundError
- (new String(nameBytes, offset, length));
- error.initCause(e);
- throw error;
- }
- }
-
- private static Object parseAnnotationValue(ClassLoader loader,
- Object pool,
- InputStream in)
- throws IOException
- {
- switch (read1(in)) {
- case 'Z':
- return Boolean.valueOf(Singleton.getInt(pool, read2(in) - 1) != 0);
-
- case 'B':
- return Byte.valueOf((byte) Singleton.getInt(pool, read2(in) - 1));
-
- case 'C':
- return Character.valueOf((char) Singleton.getInt(pool, read2(in) - 1));
-
- case 'S':
- return Short.valueOf((short) Singleton.getInt(pool, read2(in) - 1));
-
- case 'I':
- return Integer.valueOf(Singleton.getInt(pool, read2(in) - 1));
-
- case 'F':
- return Float.valueOf
- (Float.intBitsToFloat(Singleton.getInt(pool, read2(in) - 1)));
-
- case 'J': {
- return Long.valueOf(Singleton.getLong(pool, read2(in) - 1));
- }
-
- case 'D': {
- return Double.valueOf
- (Double.longBitsToDouble(Singleton.getLong(pool, read2(in) - 1)));
- }
-
- case 's': {
- byte[] data = (byte[]) Singleton.getObject(pool, read2(in) - 1);
-
- return new String(data, 0, data.length - 1);
- }
-
- case 'e': {
- byte[] typeName = (byte[]) Singleton.getObject(pool, read2(in) - 1);
- byte[] name = (byte[]) Singleton.getObject(pool, read2(in) - 1);
-
- return Enum.valueOf
- (SystemClassLoader.getClass
- (loadVMClass(loader, typeName, 1, typeName.length - 3)),
- new String(name, 0, name.length - 1));
- }
-
- case 'c':{
- byte[] name = (byte[]) Singleton.getObject(pool, read2(in) - 1);
-
- return SystemClassLoader.getClass
- (loadVMClass(loader, name, 1, name.length - 3));
- }
-
- case '@':
- return getAnnotation(loader, parseAnnotation(loader, pool, in));
-
- case '[': {
- Object[] array = new Object[read2(in)];
- for (int i = 0; i < array.length; ++i) {
- array[i] = parseAnnotationValue(loader, pool, in);
- }
- return array;
- }
-
- default: throw new AssertionError();
- }
- }
-
- private static Object[] parseAnnotation(ClassLoader loader,
- Object pool,
- InputStream in)
- throws IOException
- {
- byte[] typeName = (byte[]) Singleton.getObject(pool, read2(in) - 1);
- Object[] annotation = new Object[(read2(in) + 1) * 2];
- annotation[1] = SystemClassLoader.getClass
- (loadVMClass(loader, typeName, 1, typeName.length - 3));
-
- for (int i = 2; i < annotation.length; i += 2) {
- byte[] name = (byte[]) Singleton.getObject(pool, read2(in) - 1);
- annotation[i] = new String(name, 0, name.length - 1);
- annotation[i + 1] = parseAnnotationValue(loader, pool, in);
- }
-
- return annotation;
- }
-
- private static Object[] parseAnnotationTable(ClassLoader loader,
- Object pool,
- InputStream in)
- throws IOException
- {
- Object[] table = new Object[read2(in)];
- for (int i = 0; i < table.length; ++i) {
- table[i] = parseAnnotation(loader, pool, in);
- }
- return table;
- }
-
- private static void parseAnnotationTable(ClassLoader loader,
- Addendum addendum)
- {
- if (addendum != null && addendum.annotationTable instanceof byte[]) {
- try {
- addendum.annotationTable = parseAnnotationTable
- (loader, addendum.pool, new ByteArrayInputStream
- ((byte[]) addendum.annotationTable));
- } catch (IOException e) {
- AssertionError error = new AssertionError();
- error.initCause(e);
- throw error;
- }
- }
- }
-
- private static int resolveSpec(ClassLoader loader, byte[] spec, int start) {
- int result;
- int end;
- switch (spec[start]) {
- case 'L':
- ++ start;
- end = start;
- while (spec[end] != ';') ++ end;
- result = end + 1;
- break;
-
- case '[':
- end = start + 1;
- while (spec[end] == '[') ++ end;
- switch (spec[end]) {
- case 'L':
- ++ end;
- while (spec[end] != ';') ++ end;
- ++ end;
- break;
-
- default:
- ++ end;
- }
- result = end;
- break;
-
- default:
- return start + 1;
- }
-
- loadVMClass(loader, spec, start, end - start);
-
- return result;
- }
-
- private static int declaredMethodCount(VMClass c) {
- ClassAddendum a = c.addendum;
- if (a != null) {
- int count = a.declaredMethodCount;
- if (count >= 0) {
- return count;
- }
- }
- VMMethod[] table = c.methodTable;
- return table == null ? 0 : table.length;
- }
-
- public static void link(VMClass c, ClassLoader loader) {
- acquireClassLock();
- try {
- if ((c.vmFlags & LinkFlag) == 0) {
- if (c.super_ != null) {
- link(c.super_, loader);
- }
-
- parseAnnotationTable(loader, c.addendum);
-
- if (c.interfaceTable != null) {
- int stride = ((c.flags & Modifier.INTERFACE) != 0 ? 1 : 2);
- for (int i = 0; i < c.interfaceTable.length; i += stride) {
- link((VMClass) c.interfaceTable[i], loader);
- }
- }
-
- VMMethod[] methodTable = c.methodTable;
- if (methodTable != null) {
- for (int i = 0; i < methodTable.length; ++i) {
- VMMethod m = methodTable[i];
-
- for (int j = 1; j < m.spec.length;) {
- j = resolveSpec(loader, m.spec, j);
- }
-
- parseAnnotationTable(loader, m.addendum);
- }
- }
-
- if (c.fieldTable != null) {
- for (int i = 0; i < c.fieldTable.length; ++i) {
- VMField f = c.fieldTable[i];
-
- resolveSpec(loader, f.spec, 0);
-
- parseAnnotationTable(loader, f.addendum);
- }
- }
-
- c.vmFlags |= LinkFlag;
- }
- } finally {
- releaseClassLock();
- }
- }
-
- public static void link(VMClass c) {
- link(c, c.loader);
- }
-
- public static Class forName(String name, boolean initialize,
- ClassLoader loader)
- throws ClassNotFoundException
- {
- if (loader == null) {
- loader = Class.class.getClassLoader();
- }
- Class c = loader.loadClass(name.replace('/', '.'));
- VMClass vmc = SystemClassLoader.vmClass(c);
- link(vmc, loader);
- if (initialize) {
- initialize(vmc);
- }
- return c;
- }
-
- public static Class forCanonicalName(String name) {
- return forCanonicalName(null, name);
- }
-
- public static Class forCanonicalName(ClassLoader loader, String name) {
- try {
- if (name.startsWith("[")) {
- return forName(name, true, loader);
- } else if (name.startsWith("L")) {
- return forName(name.substring(1, name.length() - 1), true, loader);
- } else {
- if (name.length() == 1) {
- return SystemClassLoader.getClass
- (primitiveClass(name.charAt(0)));
- } else {
- throw new ClassNotFoundException(name);
- }
- }
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
-
- private static int next(char c, String s, int start) {
- for (int i = start; i < s.length(); ++i) {
- if (s.charAt(i) == c) return i;
- }
- throw new RuntimeException();
- }
-
- public static Class[] getParameterTypes(VMMethod vmMethod) {
- int count = vmMethod.parameterCount;
-
- Class[] types = new Class[count];
- int index = 0;
-
- String spec = new String
- (vmMethod.spec, 1, vmMethod.spec.length - 2);
-
- try {
- for (int i = 0; i < spec.length(); ++i) {
- char c = spec.charAt(i);
- if (c == ')') {
- break;
- } else if (c == 'L') {
- int start = i + 1;
- i = next(';', spec, start);
- String name = spec.substring(start, i).replace('/', '.');
- types[index++] = Class.forName(name, true, vmMethod.class_.loader);
- } else if (c == '[') {
- int start = i;
- while (spec.charAt(i) == '[') ++i;
-
- if (spec.charAt(i) == 'L') {
- i = next(';', spec, i + 1);
- String name = spec.substring(start, i).replace('/', '.');
- types[index++] = Class.forName
- (name, true, vmMethod.class_.loader);
- } else {
- String name = spec.substring(start, i + 1);
- types[index++] = forCanonicalName(vmMethod.class_.loader, name);
- }
- } else {
- String name = spec.substring(i, i + 1);
- types[index++] = forCanonicalName(vmMethod.class_.loader, name);
- }
- }
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
-
- return types;
- }
-
- public static int findField(VMClass vmClass, String name) {
- if (vmClass.fieldTable != null) {
- link(vmClass);
-
- for (int i = 0; i < vmClass.fieldTable.length; ++i) {
- if (toString(vmClass.fieldTable[i].name).equals(name)) {
- return i;
- }
- }
- }
- return -1;
- }
-
- public static String toString(byte[] array) {
- return new String(array, 0, array.length - 1);
- }
-
- private static boolean match(VMClass a, VMClass b) {
- // TODO: in theory we should be able to just do an == comparison
- // here instead of recursively comparing array element types.
- // However, the VM currently can create multiple array classes for
- // the same element type. We should fix that so that there's only
- // ever one of each per classloader, eliminating the need for a
- // recursive comparison. See also the native implementation of
- // isAssignableFrom.
- if (a.arrayDimensions > 0) {
- return match(a.arrayElementClass, b.arrayElementClass);
- } else {
- return a == b;
- }
- }
-
- public static boolean match(Class[] a, Class[] b) {
- if (a.length == b.length) {
- for (int i = 0; i < a.length; ++i) {
- if (! match(toVMClass(a[i]), toVMClass(b[i]))) {
- return false;
- }
- }
- return true;
- } else {
- return false;
- }
- }
-
- public static VMMethod findMethod(ClassLoader loader,
- String class_,
- String name,
- String spec)
- throws ClassNotFoundException
- {
- VMClass c = SystemClassLoader.vmClass(loader.loadClass(class_));
- VMMethod[] methodTable = c.methodTable;
- if (methodTable != null) {
- link(c);
-
- for (int i = 0; i < methodTable.length; ++i) {
- VMMethod m = methodTable[i];
- if (toString(m.name).equals(name) && toString(m.spec).equals(spec)) {
- return m;
- }
- }
- }
- return null;
- }
-
- public static int findMethod(VMClass vmClass, String name,
- Class[] parameterTypes)
- {
- VMMethod[] methodTable = vmClass.methodTable;
- if (methodTable != null) {
- link(vmClass);
-
- if (parameterTypes == null) {
- parameterTypes = new Class[0];
- }
-
- for (int i = 0; i < methodTable.length; ++i) {
- VMMethod m = methodTable[i];
- if (toString(m.name).equals(name)
- && match(parameterTypes, getParameterTypes(m)))
- {
- return i;
- }
- }
- }
- return -1;
- }
-
- public static int countMethods(VMClass vmClass, boolean publicOnly) {
- int count = 0;
- VMMethod[] methodTable = vmClass.methodTable;
- if (methodTable != null) {
- for (int i = 0, j = declaredMethodCount(vmClass); i < j; ++i) {
- VMMethod m = methodTable[i];
- if (((! publicOnly) || ((m.flags & Modifier.PUBLIC)) != 0)
- && (! toString(m.name).startsWith("<")))
- {
- ++ count;
- }
- }
- }
- return count;
- }
-
- public static Method[] getMethods(VMClass vmClass, boolean publicOnly) {
- Method[] array = new Method[countMethods(vmClass, publicOnly)];
- VMMethod[] methodTable = vmClass.methodTable;
- if (methodTable != null) {
- link(vmClass);
-
- int ai = 0;
- for (int i = 0, j = declaredMethodCount(vmClass); i < j; ++i) {
- VMMethod m = methodTable[i];
- if (((! publicOnly) || ((m.flags & Modifier.PUBLIC) != 0))
- && ! toString(m.name).startsWith("<"))
- {
- array[ai++] = makeMethod(SystemClassLoader.getClass(vmClass), i);
- }
- }
- }
-
- return array;
- }
-
- public static int countFields(VMClass vmClass, boolean publicOnly) {
- int count = 0;
- if (vmClass.fieldTable != null) {
- for (int i = 0; i < vmClass.fieldTable.length; ++i) {
- if ((! publicOnly)
- || ((vmClass.fieldTable[i].flags & Modifier.PUBLIC))
- != 0)
- {
- ++ count;
- }
- }
- }
- return count;
- }
-
- public static Field[] getFields(VMClass vmClass, boolean publicOnly) {
- Field[] array = new Field[countFields(vmClass, publicOnly)];
- if (vmClass.fieldTable != null) {
- link(vmClass);
-
- int ai = 0;
- for (int i = 0; i < vmClass.fieldTable.length; ++i) {
- if (((vmClass.fieldTable[i].flags & Modifier.PUBLIC) != 0)
- || (! publicOnly))
- {
- array[ai++] = makeField(SystemClassLoader.getClass(vmClass), i);
- }
- }
- }
-
- return array;
- }
-
- public static Annotation getAnnotation(ClassLoader loader, Object[] a) {
- if (a[0] == null) {
- a[0] = Proxy.newProxyInstance
- (loader, new Class[] { (Class) a[1] },
- new AnnotationInvocationHandler(a));
- }
- return (Annotation) a[0];
- }
-
- public static Object getAnnotationDefaultValue(ClassLoader loader,
- MethodAddendum addendum) {
- if (addendum == null) {
- return null;
- }
- byte[] annotationDefault = (byte[]) addendum.annotationDefault;
- if (annotationDefault == null) {
- return null;
- }
- try {
- return parseAnnotationValue(loader, addendum.pool,
- new ByteArrayInputStream(annotationDefault));
- } catch (IOException e) {
- AssertionError error = new AssertionError();
- error.initCause(e);
- throw error;
- }
- }
-
- private static int index(VMMethod m) {
- VMMethod[] table = m.class_.methodTable;
- for (int i = 0; i < table.length; ++i) {
- if (m == table[i]) return i;
- }
- throw new AssertionError();
- }
-
- public static Method makeMethod(VMMethod m) {
- return makeMethod(SystemClassLoader.getClass(m.class_), index(m));
- }
-
- public static ProtectionDomain getProtectionDomain(VMClass c) {
- CodeSource source = null;
- if (c.source != null) {
- try {
- source = new CodeSource
- (new URL(new String(c.source, 0, c.source.length - 1)),
- (Certificate[]) null);
- } catch (MalformedURLException ignored) { }
- }
-
- Permissions p = new Permissions();
- p.add(new AllPermission());
-
- return new ProtectionDomain(source, p);
- }
-
- public static native Method makeMethod(Class c, int slot);
-
- public static native Field makeField(Class c, int slot);
-
- private static native void acquireClassLock();
-
- private static native void releaseClassLock();
-
- public static native String makeString(byte[] array, int offset, int length);
-}
diff --git a/sgx-jvm/avian/classpath/avian/Code.java b/sgx-jvm/avian/classpath/avian/Code.java
deleted file mode 100644
index 957099107d..0000000000
--- a/sgx-jvm/avian/classpath/avian/Code.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package avian;
-
-abstract class Code {
- // VM-visible fields in types.def
-}
diff --git a/sgx-jvm/avian/classpath/avian/ConstantPool.java b/sgx-jvm/avian/classpath/avian/ConstantPool.java
deleted file mode 100644
index 61547ee38a..0000000000
--- a/sgx-jvm/avian/classpath/avian/ConstantPool.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/* Copyright (c) 2008-2015, Avian Contributors
-
- Permission to use, copy, modify, and/or distribute this software
- for any purpose with or without fee is hereby granted, provided
- that the above copyright notice and this permission notice appear
- in all copies.
-
- There is NO WARRANTY for this software. See license.txt for
- details. */
-
-package avian;
-
-import static avian.Stream.write1;
-import static avian.Stream.write2;
-import static avian.Stream.write4;
-
-import java.util.List;
-import java.io.OutputStream;
-import java.io.IOException;
-
-public class ConstantPool {
- private static final int CONSTANT_Integer = 3;
- private static final int CONSTANT_Utf8 = 1;
- private static final int CONSTANT_String = 8;
- private static final int CONSTANT_Class = 7;
- private static final int CONSTANT_NameAndType = 12;
- private static final int CONSTANT_Fieldref = 9;
- private static final int CONSTANT_Methodref = 10;
- private static final int CONSTANT_InterfaceMethodref = 11;
-
- public static int add(List pool, PoolEntry e) {
- int i = 0;
- for (PoolEntry existing: pool) {
- if (existing.equals(e)) {
- return i;
- } else {
- ++i;
- }
- }
- pool.add(e);
- return pool.size() - 1;
- }
-
- public static int addInteger(List pool, int value) {
- return add(pool, new IntegerPoolEntry(value));
- }
-
- public static int addUtf8(List pool, String value) {
- return add(pool, new Utf8PoolEntry(value));
- }
-
- public static int addString(List pool, String value) {
- return add(pool, new StringPoolEntry(addUtf8(pool, value)));
- }
-
- public static int addClass(List pool, String name) {
- return add(pool, new ClassPoolEntry(addUtf8(pool, name)));
- }
-
- public static int addNameAndType(List pool,
- String name,
- String type)
- {
- return add(pool, new NameAndTypePoolEntry
- (addUtf8(pool, name),
- addUtf8(pool, type)));
- }
-
- public static int addFieldRef(List pool,
- String className,
- String name,
- String spec)
- {
- return add(pool, new FieldRefPoolEntry
- (addClass(pool, className),
- addNameAndType(pool, name, spec)));
- }
-
- public static int addMethodRef(List pool,
- String className,
- String name,
- String spec)
- {
- return add(pool, new MethodRefPoolEntry
- (addClass(pool, className),
- addNameAndType(pool, name, spec)));
- }
-
- public static int addInterfaceMethodRef(List pool,
- String interfaceName,
- String name,
- String spec)
- {
- return add(pool, new InterfaceMethodRefPoolEntry
- (addClass(pool, interfaceName),
- addNameAndType(pool, name, spec)));
- }
-
- public interface PoolEntry {
- public void writeTo(OutputStream out) throws IOException;
- }
-
- private static class IntegerPoolEntry implements PoolEntry {
- private final int value;
-
- public IntegerPoolEntry(int value) {
- this.value = value;
- }
-
- public void writeTo(OutputStream out) throws IOException {
- write1(out, CONSTANT_Integer);
- write4(out, value);
- }
-
- public boolean equals(Object o) {
- return o instanceof IntegerPoolEntry
- && ((IntegerPoolEntry) o).value == value;
- }
- }
-
- private static class Utf8PoolEntry implements PoolEntry {
- private final String data;
-
- public Utf8PoolEntry(String data) {
- this.data = data;
- }
-
- public void writeTo(OutputStream out) throws IOException {
- write1(out, CONSTANT_Utf8);
- byte[] bytes = data.getBytes("UTF-8");
- write2(out, bytes.length);
- out.write(bytes);
- }
-
- public boolean equals(Object o) {
- return o instanceof Utf8PoolEntry
- && ((Utf8PoolEntry) o).data.equals(data);
- }
- }
-
- private static class StringPoolEntry implements PoolEntry {
- private final int valueIndex;
-
- public StringPoolEntry(int valueIndex) {
- this.valueIndex = valueIndex;
- }
-
- public void writeTo(OutputStream out) throws IOException {
- write1(out, CONSTANT_String);
- write2(out, valueIndex + 1);
- }
-
- public boolean equals(Object o) {
- return o instanceof StringPoolEntry
- && ((StringPoolEntry) o).valueIndex == valueIndex;
- }
- }
-
- private static class ClassPoolEntry implements PoolEntry {
- private final int nameIndex;
-
- public ClassPoolEntry(int nameIndex) {
- this.nameIndex = nameIndex;
- }
-
- public void writeTo(OutputStream out) throws IOException {
- write1(out, CONSTANT_Class);
- write2(out, nameIndex + 1);
- }
-
- public boolean equals(Object o) {
- return o instanceof ClassPoolEntry
- && ((ClassPoolEntry) o).nameIndex == nameIndex;
- }
- }
-
- private static class NameAndTypePoolEntry implements PoolEntry {
- private final int nameIndex;
- private final int typeIndex;
-
- public NameAndTypePoolEntry(int nameIndex, int typeIndex) {
- this.nameIndex = nameIndex;
- this.typeIndex = typeIndex;
- }
-
- public void writeTo(OutputStream out) throws IOException {
- write1(out, CONSTANT_NameAndType);
- write2(out, nameIndex + 1);
- write2(out, typeIndex + 1);
- }
-
- public boolean equals(Object o) {
- if (o instanceof NameAndTypePoolEntry) {
- NameAndTypePoolEntry other = (NameAndTypePoolEntry) o;
- return other.nameIndex == nameIndex && other.typeIndex == typeIndex;
- } else {
- return false;
- }
- }
- }
-
- private static class FieldRefPoolEntry implements PoolEntry {
- private final int classIndex;
- private final int nameAndTypeIndex;
-
- public FieldRefPoolEntry(int classIndex, int nameAndTypeIndex) {
- this.classIndex = classIndex;
- this.nameAndTypeIndex = nameAndTypeIndex;
- }
-
- public void writeTo(OutputStream out) throws IOException {
- write1(out, CONSTANT_Fieldref);
- write2(out, classIndex + 1);
- write2(out, nameAndTypeIndex + 1);
- }
-
- public boolean equals(Object o) {
- if (o instanceof FieldRefPoolEntry) {
- FieldRefPoolEntry other = (FieldRefPoolEntry) o;
- return other.classIndex == classIndex
- && other.nameAndTypeIndex == nameAndTypeIndex;
- } else {
- return false;
- }
- }
- }
-
- private static class MethodRefPoolEntry implements PoolEntry {
- private final int classIndex;
- private final int nameAndTypeIndex;
-
- public MethodRefPoolEntry(int classIndex, int nameAndTypeIndex) {
- this.classIndex = classIndex;
- this.nameAndTypeIndex = nameAndTypeIndex;
- }
-
- public void writeTo(OutputStream out) throws IOException {
- write1(out, CONSTANT_Methodref);
- write2(out, classIndex + 1);
- write2(out, nameAndTypeIndex + 1);
- }
-
- public boolean equals(Object o) {
- if (o instanceof MethodRefPoolEntry) {
- MethodRefPoolEntry other = (MethodRefPoolEntry) o;
- return other.classIndex == classIndex
- && other.nameAndTypeIndex == nameAndTypeIndex;
- } else {
- return false;
- }
- }
- }
-
- private static class InterfaceMethodRefPoolEntry implements PoolEntry {
- private final int classIndex;
- private final int nameAndTypeIndex;
-
- public InterfaceMethodRefPoolEntry(int classIndex, int nameAndTypeIndex) {
- this.classIndex = classIndex;
- this.nameAndTypeIndex = nameAndTypeIndex;
- }
-
- public void writeTo(OutputStream out) throws IOException {
- write1(out, CONSTANT_InterfaceMethodref);
- write2(out, classIndex + 1);
- write2(out, nameAndTypeIndex + 1);
- }
-
- public boolean equals(Object o) {
- if (o instanceof InterfaceMethodRefPoolEntry) {
- InterfaceMethodRefPoolEntry other = (InterfaceMethodRefPoolEntry) o;
- return other.classIndex == classIndex
- && other.nameAndTypeIndex == nameAndTypeIndex;
- } else {
- return false;
- }
- }
- }
-}
diff --git a/sgx-jvm/avian/classpath/avian/Continuations.java b/sgx-jvm/avian/classpath/avian/Continuations.java
deleted file mode 100644
index 2c930970b0..0000000000
--- a/sgx-jvm/avian/classpath/avian/Continuations.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/* Copyright (c) 2008-2015, Avian Contributors
-
- Permission to use, copy, modify, and/or distribute this software
- for any purpose with or without fee is hereby granted, provided
- that the above copyright notice and this permission notice appear
- in all copies.
-
- There is NO WARRANTY for this software. See license.txt for
- details. */
-
-package avian;
-
-import java.util.concurrent.Callable;
-
-/**
- * This class provides methods to capture continuations and manage
- * control flow when calling continuations.
- *
- *
A continuation is a snapshot of a thread's call stack which can
- * be captured via callWithCurrentContinuation and later
- * restored any number of times. The program may restore this
- * snapshot by either feeding it a result (to be returned by
- * callWithCurrentContinuation) or feeding it an
- * exception (to be thrown by
- * callWithCurrentContinuation). Continuations may be
- * used to implement features such as coroutines, generators, and
- * cooperative multitasking.
- *
- *
This class provides two static methods,
- * callWithCurrentContinuation and
- * dynamicWind, with similar semantics to the Scheme
- * functions call-with-current-continuation and
- * dynamic-wind, respectively. In addition, we define
- * how continuations work with respect to native code, exceptions,
- * try/finally blocks, synchronized blocks, and multithreading.
- *
- *
Continuations and Continuation Contexts
- *
- *
A continuation can be thought of as a singly-linked list of
- * stack frames representing the call trace, where the head of the
- * list is the frame of the method most recently called (i.e. the top
- * of the stack). However, this trace only extends as far as the most
- * recent chain of Java frames - it ends just prior to the most recent
- * native frame in the stack. The reason for this is that the VM
- * cannot, in general, safely capture and restore native frames.
- * Therefore, each call from native code to Java (including the
- * original invocation of main(String[]) or
- * Thread.run()) represents a new continuation context in
- * which continuations may be captured, and these will only contain
- * frames from within that context.
- *
- *
Calling a continuation (i.e. feeding it a result or exception)
- * causes the current continuation to be replaced with the called
- * continuation. When the last method in this new continuation
- * returns, it returns to the native frame which created the current
- * context, which may or may not be the same as the context in which
- * that continuation was created.
- *
- *
We define the return type of a continuation context as the
- * return type of the first method called in that context. A
- * continuation may be called from a different context than the one in
- * which it was created, provided the return type of the latter is
- * compatible with the current context.
- *
- *
Given a thread executing in context "A" which wants to call a
- * continuation created in context "B", the following rules apply:
- *
- *
- *
- *
If the return type of "A" is void, the return
- * type of "B" may be anything, including void
- *
- *
If the return type of "A" is a primitive type, the return
- * type of "B" must match exactly
- *
- *
If the return type of "A" is an object type, that type must
- * be assignable from the return type of "B" (i.e. the latter must
- * either be the same as the former or a superclass or
- * superinterface of it)
- *
- *
- *
- *
A thread may call a continuation created by a different thread
- * provided the return types are compatible. Multiple threads may
- * safely call the same continuation simultaneously without
- * synchronization. Any attempt to call a continuation from a context
- * with an incompatible return type will throw an {@link
- * avian.IncompatibleContinuationException}.
- *
- *
Winding, Unwinding, and Rewinding
- *
- *
Traditionally, Java provides one way to wind the execution stack
- * (method calls) and two ways to unwind it (normal returns and
- * exception unwinding). With continuations, we add a new way to
- * rewind the stack and a new way to unwind it.
- *
- *
The call stack of a continuation may share frames with other
- * continuations - in which case they share a common history. When
- * calling a continuation "B" from the current continuation "A", the
- * VM must unwind past any frames which are in "A" but not in "B" and
- * rewind past any frames in "B" but not in "A". During this
- * unwinding and rewinding, control may pass through synchronized and
- * try/finally blocks while going down the old stack and up the new
- * stack.
- *
- *
However, unlike the traditional processes of winding and
- * unwinding, the VM will ignore these blocks - monitors will not be
- * released or acquired and finally blocks will not execute. This is
- * by design. The purpose of such a block is to acquire a resource,
- * such as a file handle or monitor, once before executing a task and
- * release it after the task is finished, regardless of how often the
- * task might temporarily yield control to other continuations.
- *
- *
Alternatively, one might wish to acquire and release a resource
- * each time control (re)winds to or unwinds from a continuation,
- * respectively. In this case, one may use dynamicWind
- * to register functions which will run every time that frame is
- * passed, regardless of how the stack is wound or unwound.
- */
-public class Continuations {
- private Continuations() { }
-
- private static final ThreadLocal latestReset = new ThreadLocal();
-
- /**
- * Captures the current continuation, passing a reference to the
- * specified receiver.
- *
- *
This method will either return the result returned by
- * receiver.call(Callback), propagate the exception
- * thrown by that method, return the result passed to the
- * handleResult(T) method of the continuation, or throw the
- * exception passed to the handleException(Throwable) method of the
- * continuation.
- */
- public static native T callWithCurrentContinuation
- (Function,T> receiver) throws Exception;
-
- /**
- * Calls the specified "before" and "after" tasks each time a
- * continuation containing the call is wound or unwound,
- * respectively.
- *
- *
This method first calls before.run(), then
- * thunk.call(), and finally after.run(),
- * returning the result of the second call. If
- * before.run() does not return normally, the second
- * and third calls will not happen. If thunk.call()
- * throws an exception, after.run(), will be called
- * before the exception is propagated.
- *
- *
If thunk.call() calls a continuation (directly or
- * via a subroutine) which does not include the current call to
- * dynamicWind, after.run() will be called
- * before control passes to that continuation. If this call throws
- * an exception, the exception will propagate to the current caller
- * of dynamicWind.
- *
- *