Skip to content
Java Class file parser and analyzer written in Clojure
Clojure
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/class_analyzer implement wide opcodes Dec 1, 2019
test/class_analyzer
.gitignore
LICENSE
README.md
project.clj

README.md

bytecode-explorer

A disassembler library for Java Class files.

The purpose of the project is to provide an idiomatic Clojure framework for disassembling Java Class files based on the Java Virtual Machine Specification.

It is also a fun topic to learn about the quirks and oddities of a commonly used VM ecosystem.

The program is validated by running it on a selection of class files on the developer's ~/.m2 folder. For testing purposes, an output layer is provided that renders in the same format as javap does and we validate that every byte of the outputs match. Therefore, it can be also used as a drop-in replacement of the standard Java disassembler.

Written in Clojure Hello Visitors

Usage

You can embed it as a library in your project, or run it as a standalone program: lein run [ARGS] [CLASSES]

Arguments:

  • -c: prints bytecode of methods (like in javap)
  • -l: prints line numbers and local variable tables (like in javap)
  • --x-edn: prints output as a nice EDN data structure instead of text.

For example, to run it on a class file from the Clojure source code.

lein run -- -c  clojure/asm/TypePath.class

You can check that the output is the same as with javap:

javap -c clojure.asm.TypePath

Testing

You will need Leiningen to run the tests.

  • Run unit tests with $ lein test command.
  • Run javap comparison tests with: $ lein test :javap

License

Copyright (c) Janos Erdos. All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 2.0 (https://www.eclipse.org/legal/epl-2.0/) which can be found in the file LICENSE.txt at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.

You can’t perform that action at this time.