Created: 2011-09-06 16:35
Updated: 2017-11-21 17:20


Sporkle: Pure-Clojure Java classfile assembler and disassembler

Written as a compare-and-contrast programming exercise, loosely based on Pork (http://github.com/CodeFarmer/pork).

ABANDONED CODE - starting again in the 'sporkle' project.

Has three main parts:

  1. Classfile read/write - parsing JVM class file streams into structs that correspond to the format laid out in the JVM spec, and writing those structs back into byte streams.

  2. Class struct creation with a sorta-DSL - creating classfile structs (above) by describing in a friendly form the fields and attributes of the class, as well as a pseudo-bytecode JCM assembler for describing methods.

  3. Friendly view of classfile structs - the reverse process of 2. above, creating a human-readable view onto the classfile struct that should eventually be the same DSL, so we can run the view through a reader and get Java classes.

Current State

This works at the moment:

    (public (java-class "Nothing"))
  1 ;; this

Ugly eh? This is the plan:

  (java-class "Nothing"
      (field java.lang.Object "x")
      (method :void "doNothing" [] [:return]))
      (method java.lang.Object "getX" []
        [:aload_0      ; this
         :getfield "x" ; infer containing class unless specified, guess type if unambiguous

The shortish term goal is feature parity with Pork, so support for exception tables, smart arguments for JVM bytecode instructions, line number tables, labels (for jumping) and so on will be next once the syntax is nice.


Copyright (C) 2017 Joel Gluth

Distributed under the Eclipse Public License, the same as Clojure.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more