Chapter 2. Getting started with Dryad

Table of Contents

2.1. Linking with the Dryad Library
2.1.1. Compilation in Automake Package
2.1.2. Standalone Compilation at Command-line
2.1.3. Explanation
2.2. Dryad on Mac OS X
2.2.1. Installing Dryad using Nix
2.2.2. Dryad on Mac OS X 10.3

Work in Progress

This chapter is work in progress. Not all parts have been finished yet. The latest revision of this manual may contain more material. Refer to the online version.

Dryad is a collection of tools for developing transformation systems for Java source and bytecode.

2.1. Linking with the Dryad Library

For some applications, you might want to link with the Dryad library. This library has a few dependencies, such as libjvm, that make linking a bit more involved than it should be. Fortunately, you don't have to have to know all these details.

2.1.1. Compilation in Automake Package

In an autoxt-based Automake package, you can use the variable DRYAD_LIBS in the Makefile.am. This variable contains all the required linker flags, including platform specific ones.

2.1.2. Standalone Compilation at Command-line

At the command-line, the preferred way of compilation is:

$ strc -i const-prop.str $(strcflags dryad java-front)

The strcflags include the Stratego includes (-I) of these packages and special linker options required to use the Dryad library. This way of compilation works on all supported platforms, since it reuses the information the configure script of Dryad has figured out about the platform you are running on.

If you haven't seen strcflags before: it is an alias for the invocation of pkg-config. You can define it using the following command. Of course, you also use the longer pkg-config variant in the invocation of strc.

$ alias strcflags="pkg-config --variable=strcflags "

Make sure that Dryad is in the PKG_CONFIG_PATH. You can check if it is by invoking the following command. This will print a bunch of strc options. If it prints nothing, then dryad is not on the path and you can extend it by defining the PKG_CONFIG_PATH.

$ echo $(strcflags dryad)

$ export PKG_CONFIG_PATH=$dryadprefix/lib/pkgconfig:$PKG_CONFIG_PATH

2.1.3. Explanation

If you don't use the suggested ways of linking, then you probably get the following message:

$ ./const-prop -i Foo.java 
./const-prop: error while loading shared libraries: libjvm.so: cannot
open shared object file: No such file or directory

This can be solved in several ways, for example by setting the LD_LIBRARY_PATH, or by adding the runtime path of the libjvm library to the executable. This is what is done be the previously suggested solutions.

2.2. Dryad on Mac OS X

Dryad supports Mac OS X if the JDK 5.0 is installed. You need to configure 5.0 as the default JVM in the preferences, or you can set an environment variable for this:

$ export JAVA_JVM_VERSION="1.5"

If you get an UnsupportedClassVersionError, then there is something wrong with this configuration.

For Dryad, there is no need to manipulate the Current and CurrentJDK symbolic links in /System/Library/Frameworks/JavaVM.framework/Versions, which is often suggested on the Internet. In fact, this will not affect the default JVM at all for Dryad, which starts the JVM as a library using JNI, not from the command-line.

2.2.1. Installing Dryad using Nix

Users of Dryad in Nix have to install the JDK 5.0 as well: it is not included in the dependencies of Dryad in Nix. They also have to configure this JDK as the default.

2.2.2. Dryad on Mac OS X 10.3

The JDK 5.0 is not officially supported on Mac OS X 10.3, but the Java features Dryad uses work with an installation of JDK 5.0 on Mac OS X 10.3. For this, you can copy the installation of the JDK on a Mac OS X 10.4 machine to Mac OS X 10.3. Copy the directory /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0 to Mac OS X 10.3 and create a symbolic link /System/Library/Frameworks/JavaVM.framework/Versions/1.5 to this directory. We advice you not to make this the global default JVM: it is safer to set the JAVA_JVM_VERSION to 1.5 for Dryad sessions only, since the 1.5.0 installation will not work for most other Java applications.