Discuss on Groups View on GitHub

A lightweight alternative to Java

About Avian

Avian is a lightweight virtual machine and class lbrary designed to provide a useful subset of Java’s features, suitable for building self-contained applications.

Efficient

The VM is implemented from scratch and designed to be both fast and small.

  • Just-In-Time (JIT) compilation for fast method execution
  • Generational, copying garbage collection ensures short pause times and good spatial locality
  • Thread-local heaps provide O(1) memory allocation with no synchronization overhead
  • Null pointer dereferences are handled via OS signals to avoid unecessary branches

The class library is designed to be as loosely coupled as possible, allowing tools like ProGuard to aggressively isolate the minimum code needed for an application. This translates to smaller downloads and faster startup.

Portable

Platform-specific code is hidden behind a generic interface, so adding support for new OSes is easy. Avian currently supports:

  • Linux (i386, x86_64, and ARM),
  • Windows (i386 and x86_64),
  • OS X (i386 and x86_64),
  • iOS (i386 and ARM), and
  • FreeBSD (i386 and x86_64).

The only third party dependency beyond OS-provided libraries is zlib, which is itself very portable. Although the VM is written in C++, it does not depend on the C++ standard library, and is therefore robust in the face of ABI changes.

Embeddable

Not only can applications embed the VM, but the VM itself supports class and resource loading from embedded jar files. This means you can produce a single executable containing your entire application, thus simplifying the installation process.

Download

Current Release

The latest release is version 1.1.0. As of this release, everything should work as advertised on the supported platforms. Please post to the discussion group if you have any problems.

Download Avian 1.1.0 (1496K)

Recent changes:

  • Lots of bugfixes throughout the code
  • Improved type safety for internal VM code
  • Update build files for recent platform SDKs
  • Add compatibility with recent OpenJDK releases
  • Add experimental CMake and Gradle build support

Documentation

Roadmap

Ideas for the future

  • Add java.lang.invoke support
  • Experiment with trace-based JIT compilation
  • Improve ahead-of-time compilation using LLVM
  • Add support for escape analysis to determine where objects may be safely allocated on the stack instead of the heap
  • Rework memory allocation in garbage collector to improve performance in low memory situations (see here for details)
  • Support additional architectures such as 64-bit ARM

Examples

Avian is well suited to building small, self-contained applications. To demonstrate this, we’ve taken a demo application from the Eclipse SCM repository and built it using Avian, ProGuard, and LZMA.

Platform Example
Linux/x86_64 download (1049K)
Linux/i386 download (973K)
Linux/ARM download (882K)
OS X/x86_64 download (1066K)
OS X/i386 download (1053K)
Windows/x86_64 download (1111K)
Windows/i386 download (1072K)

Building

If you’d like to build this example yourself, try the following:

# Set the platform and swt_zip environment variables according to the
# following table:
#
# platform               swt_zip
# --------               -------
# linux-x86_64           swt-4.3-gtk-linux-x86_64.zip
# linux-i386             swt-4.3-gtk-linux-x86.zip
# linux-arm              swt-4.3-gtk-linux-arm.zip
# macosx-x86_64          swt-4.3-cocoa-macosx-x86_64.zip
# macosx-i386            swt-4.3-cocoa-macosx.zip
# windows-x86_64         swt-4.3-win32-win32-x86_64.zip
# windows-i386           swt-4.3-win32-win32-x86.zip

mkdir work
cd work
curl -Of http://oss.readytalk.com/avian-web/proguard4.11.tar.gz
tar xzf proguard4.11.tar.gz
curl -Of http://oss.readytalk.com/avian-web/lzma920.tar.bz2
(mkdir -p lzma-920 && cd lzma-920 && tar xjf ../lzma920.tar.bz2)
curl -Of http://oss.readytalk.com/avian-web/${swt_zip}
mkdir -p swt/${platform}
unzip -d swt/${platform} ${swt_zip}
curl -Of http://oss.readytalk.com/avian-web/avian-1.1.0.tar.bz2
tar xjf avian-1.1.0.tar.bz2
curl -Of http://oss.readytalk.com/avian-web/avian-swt-examples-1.1.0.tar.bz2
tar xjf avian-swt-examples-1.1.0.tar.bz2
# needed only for 32-bit Windows builds:
git clone https://github.com/ReadyTalk/win32.git
# needed only for 64-bit Windows builds:
git clone https://github.com/ReadyTalk/win64.git
cd avian-swt-examples
make lzma=$(pwd)/../lzma-920 full-platform=${platform} example

License

Permissive BSD/ISC - style license:

Copyright (c) 2008-2014, 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.