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, ARM, and ARM64),
  • Windows (i386 and x86_64),
  • OS X (i386 and x86_64),
  • iOS (i386, x86_64, ARM, and ARM64), 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.2.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.2.0 (553K)

Recent changes:

  • Add support for ARM64 on Linux and iOS
  • Lots of bugfixes throughout the code
  • Improve compatibility with OpenJDK 8 class library
  • Improve compatibility with Android class library
  • Improve Gradle build support

Avian-Pack Project (Avian plus Android class library)

This is a project for building Avian with the Android class library, providing more complete support for functionality such as regular expressions, SSL, localization, etc.. It does not include any Android platform support such as UI and system components.

All the components are patched to work on Windows and OS X (while the vanilla Android classpath is Linux-only) and tested (a bit). There are some minor known issues that hopefully will be fixed in the next releases.

Avian-pack project page on GitHub

Major features:

  • All-in-one. Many simple Java projects and libraries should already work with this package (if they don’t, you are welcome to submit an issue.)
  • The Android class library is has neither a proprietary, nor a copyleft-style license, thus may be freely used and embedded in both proprietary and open-source projects, and may also be modified freely (the authors would be happy for any pull requests submitted). Most non-Avian additional components are released under Apache license (the same as Android itself); others are mostly BSD.
  • The library has been pached to support Microsoft Windows, which was a major challenge, especially sockets and other I/O.

Download Avian-pack v0.1 (pre-release) with Avian 1.2.0 provided

Avian-pack is an independent project maintained by its creators: @bigfatbrowncat and @JustAMan. Please report issues and questions to that project.

Documentation

Project Ideas

  • 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)

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 (1078K)
Linux/i386 download (1030K)
Linux/ARM64 download (1448K)
Linux/ARM download (884K)
OS X/x86_64 download (1066K)
OS X/i386 download (1053K)
Windows/x86_64 download (1113K)
Windows/i386 download (1073K)

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-arm64            swt-4.3-gtk-linux-arm64.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.2.0.tar.bz2
tar xjf avian-1.2.0.tar.bz2
curl -Of http://oss.readytalk.com/avian-web/avian-swt-examples-1.2.0.tar.bz2
tar xjf avian-swt-examples-1.2.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-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.