Skip to content

Add support for Haiku on x86_64 - #25

Open
duncanmcqueen wants to merge 1 commit into
ingelabs:masterfrom
duncanmcqueen:haiku-port
Open

duncanmcqueen wants to merge 1 commit into
ingelabs:masterfrom
duncanmcqueen:haiku-port

Conversation

@duncanmcqueen

@duncanmcqueen duncanmcqueen commented Oct 16, 2026 •

Copy link
Copy Markdown

Summary

This pull request adds Haiku on x86_64 as a host. JamVM then builds and runs on Haiku with GNU Classpath (ingelabs master with the Haiku patches in ingelabs/classpath#61 and the pull requests that it needs).

I use JamVM as the VM for BeKaffe, an AWT/Swing toolkit for GNU Classpath on Haiku. Until now BeKaffe used Kaffe, which is archived.

Changes

  • configure.ac: the host case x86_64-*-haiku*, and the Makefiles for src/os/haiku. Haiku has dlopen() in libroot, thus libdl is not necessary.
  • src/os/haiku/os.c: the stack base, the number of CPUs and the physical memory come from the Haiku kernel kit (get_thread_info() and get_system_info()). Haiku uses LIBRARY_PATH to find native libraries.
  • src/os/haiku/x86_64/: the same files as src/os/bsd/x86_64/. Haiku uses the System V AMD64 calling convention.
  • src/class.c: on Haiku, the scandir() filter function takes a const argument (as on Linux and macOS).

The change does not touch the code for the other hosts.

How to build

On Linux, run ./autogen.sh (the files that it adds must be real files, not symbolic links, when you copy the tree to Haiku). On Haiku:

../jamvm/configure --prefix=$HOME/jamvm-install \
    --with-classpath-install-dir=$HOME/classpath-install
make && make install

javac comes from the Haiku OpenJDK 8 package.

Results

Haiku R1/beta6 x86_64 (hrev60228), GCC 13.3.0, QEMU/KVM with 6 CPUs. The default configuration (inlining, direct, threaded, with run-time relocation checks) builds without errors and without new warnings.

  • jamvm -version and a hello program: Hello from JamVM 2.1.0 on Haiku amd64, CPUs=6.
  • A stress test: 16 threads allocate memory while the collector runs, plus wait()/notify(), interrupt(), timed wait(), finalizers, NullPointerException, array bounds and StackOverflowError. 10 of 10 runs passed.
  • AWT and Swing programs, applets, mouse and keyboard input, and javax.sound.sampled output work with the Haiku toolkit.
  • A command line test from BeKaffe (CliTest: collections, formatting, BigDecimal, regular expressions, file I/O, threads, processes, network and system properties) passes.

Speed, against Kaffe 1.1.10-pre (interpreter) with the same Classpath build on the same machine:

Test Kaffe JamVM
CPU benchmark (fib(30), an array loop, strings and HashMap) 6347 ms 362 ms
Stress test above (200 rounds) 235 s 6.5 s
Drawing benchmark (same pixels on both VMs) 57 s 2.8 s

I also ran the Kaffe regression suite (149 tests) on JamVM: 129 tests pass. Most of the other tests compare exception messages and stack trace formats with Kaffe's text, or test Kaffe internals. Two results can be useful to you:

  • ProhibitedClass showed that a user class loader can define java.lang.Object. Do not let user class loaders define classes in java.* #24 fixes this.
  • SecurityMan does not stop. It also does not stop on OpenJDK 8, so it is not a JamVM problem: the test's security manager asks for a class that does not exist, and each class path lookup calls the security manager again.

AI assistance

An AI model (Claude Code, by Anthropic) wrote this change, the tests and this text. The repository owner directed the work and checked the results. Please review it as you review other contributions.

🤖 Generated with Claude Code

Add Haiku (x86_64-*-haiku*) as a host:

- configure.ac: the host case, and the Makefiles for src/os/haiku.
  Haiku has dlopen() in libroot, so libdl is not needed.
- src/os/haiku/os.c: get the stack base, the number of CPUs and the
  physical memory from the Haiku kernel kit (get_thread_info() and
  get_system_info()). Haiku uses LIBRARY_PATH for native libraries.
- src/os/haiku/x86_64: the same files as src/os/bsd/x86_64. Haiku uses
  the System V AMD64 calling convention.
- src/class.c: the scandir() filter on Haiku takes a const argument.

Tested on Haiku R1/beta6 x86_64 with GNU Classpath (ingelabs master)
and the Haiku AWT peer: the default interpreter (inlining, direct,
threaded), threads, the garbage collector, AWT and Swing programs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
duncanmcqueen added a commit to duncanmcqueen/bekaffe that referenced this pull request Oct 16, 2026
JamVM (ingelabs/jamvm) now builds and runs on Haiku x86_64 with the
same GNU Classpath build and the same Haiku peer as Kaffe. AWT, Swing,
applets and sound work, and it is 17 to 36 times faster than Kaffe.

- patches/jamvm/: the Haiku port, and a fix that stops user class
  loaders from defining java.* classes. Both are offered upstream as
  ingelabs/jamvm#25 and #24.
- src/build-jamvm.sh and src/run-jamvm.sh: build JamVM on Haiku against
  the Classpath install, and run classes with it.
- src/build.sh: get jni.h from the Classpath install, not from Kaffe.
- README, front page news and development notes: how to build JamVM,
  and the test results (Kaffe regression suite, stress test, speed).

Kaffe stays the default VM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant