atgreen / openldk

Java in Common Lisp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenLDK

Warning

This does not work and may never work. Please don't tell anyone about this. I just prefer to tinker in public.

OpenLDK is a JIT compiler and runtime for Java written in Common Lisp. It works by incrementally translating Java bytecode into Lisp, and then compiling that into native machine code for execution. Java classes are mapped to CLOS classes, opening the door for easy integration between Java and Common Lisp code.

OpenLDK makes use of OpenJDK's core runtime libraries. This is made possible by the GNU Classpath Exception to the GPL, under which OpenJDK code is distributed.

Requirements

System dependencies are managed with ocicl. Just run ocicl install in the top level source directory to download and install openldk's dependencies.

openldk has only been tested with sbcl. It's possible that other Common Lisp implementations could be made to work with it, but I am only developing with sbcl for now.

openldk has only been tested in Linux.

openldk uses the LDK_CLASSPATH environment variable rather than CLASSPATH. Be sure to point it at your Java 8 runtime jar file. On my Fedora Linux system that looks like:

$ export LDK_CLASSPATH=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.392.b08-4.fc39.x86_64/jre/lib/rt.jar

Hacking

Testing

Run make check to run through the dejagnu-based testsuite.

This project makes use of github actions in which we use Red Light Green Light to evaluate test results. The rlgl policy for openldk is found at https://github.com/atgreen/openldk-rlgl-policy.

Debugging

The openldk runtime will generate useful debug info if you set your LDK_DEBUG environment variable. LDK_DEBUG should be set to a string of characters that are interpreted as below:

  • c - dump all Lisp code prior to evaluation
  • s - show stack push/pop events
  • t - trace method entries
  • u - unmuffle the Lisp compiler

More specifically, running LDK_DEBUG=cstu openldk Hello will enable all debug output while running Hello.

Status

It still doesn't work. You are looking at a work in progress that may never be completed. I don't want to see this on hackernews or reddit prematurely.

Here's an incomplete list of what's not implemented:

  • support for class files beyond Java 8
  • bytecode verification
  • monitorenter/monitorexit for object synchronization
  • SSA and SSA-based optimizations are aspirational. The compiler currently generates code for a naive stack machine.

Author and License

OpenLDK was written by Anthony Green, and is distributed under the terms of the GNU General Public License, Version 2, modified by the "CLASSPATH" exception to the GPL. See LICENSE for details.

About

Java in Common Lisp

License:GNU General Public License v2.0


Languages

Language:Java 99.4%Language:Common Lisp 0.6%Language:Shell 0.0%Language:Makefile 0.0%