classy

Crates.ioclassy
lib.rsclassy
version0.3.0
sourcesrc
created_at2023-05-18 13:40:55.018809
updated_at2023-07-21 22:00:20.813632
descriptionClassy: A Rust Library for Parsing Java Class Files
homepagehttps://github.com/andygrove/classy
repositoryhttps://github.com/andygrove/classy
max_upload_size
id867957
size147,761
Andy Grove (andygrove)

documentation

README

Classy: A Rust Library for Parsing Java Class Files

Library

Classy is a Rust library for reading Java class files, based on The Java Virtual Machine Specification, Java SE 17 Edition.

https://docs.oracle.com/javase/specs/jvms/se17/html/jvms-4.html

Example Usage:

let f = File::open("MyClass.class")?;
let class: ClassFile = read_class(f)?;
println!("Class JVM version: {}.{}", class.major_version, class.minor_version);
println!("Class has {} fields and {} methods", class.field_info.len(), class.method_info.len());

The ClassFile struct contains complete information about a class file:

pub struct ClassFile {
    minor_version: u16,
    major_version: u16,
    constant_pool: Vec<Constant>,
    access_flags: u16,
    this_class: u16,
    super_class: u16,
    interfaces: Vec<u16>,
    field_info: Vec<FieldInfo>,
    method_info: Vec<MethodInfo>,
    attributes: Vec<Attribute>,
}

Command-Line

A command-line tool is included, which provides examples of using the library.

Features:

  • Search for a class in a directory full of Jar files using a regular expression.
  • Partially decompile all classes in a Jar file (similar to javap functionality). Note that this is not a full decompiler. It only shows field and method signatures, not implementation code.

Roadmap

I built this for personal use to help me with a specific task. I am not sure if I will develop it further.

Commit count: 13

cargo fmt