10 releases

0.0.10 Nov 6, 2024
0.0.9 Oct 27, 2024
0.0.6 Sep 16, 2024
0.0.4 May 10, 2024

#1047 in Development tools

Download history 285/week @ 2024-09-13 42/week @ 2024-09-20 129/week @ 2024-09-27 36/week @ 2024-10-04 8/week @ 2024-10-11 117/week @ 2024-10-18 140/week @ 2024-10-25 123/week @ 2024-11-01 34/week @ 2024-11-08 9/week @ 2024-11-15 5/week @ 2024-11-22 2/week @ 2024-11-29

93 downloads per month
Used in 2 crates

Apache-2.0

290KB
6K SLoC

java-asm

Crates.io Version

Java bytecode reader & writer, maybe a rust implementation for ASM

There are some similar projects in GitHub, but they didn't actually implement all JVM Bytecode format, and also not implements all ASM nodes/features in rust. So I want to build this library to fully read and write Java bytecode information.

This project supports much newer LTS Java version(Java 21 currently) than other rust implementations. Only supports asm-tree api currently, not supports visitor api because Tree API is much easier to use than visitor api.

Current Stage

After version 0.0.6, you can try to use ClassNode::from_jvms to read a class file into a ClassNode, and it is pretty useful to now, check tests in this project to see some examples.

  • Implement Read Java class file with JVMS format
  • Implement Write Java class file with JVMS format
  • WIP, ClassNode reader
    • Constant pool
    • Attributes
    • Class / Field / Method metadata
    • Method instructions
    • Method frames (read as an attribute is available, need a better format)
    • Method local variables / stacks / try-catches (read as an attribute is available, need a better format)
  • Not Start, Nodes writer (low priority currently)
    • Append constant pool if needed
    • Write back attributes into Class / Field / Method / Code
    • Method frames
  • Not Start, Implement ASM features (eg. auto calculate frame/stack etc.)
  • Smali liked output.
  • Dex interop. (https://source.android.com/docs/core/runtime/dex-format)
    • Basic structure for dex file metadata
    • Instructions
    • Annotations
    • Debug info
    • Other formats
    • Separation for metadata with real data (e.g. instructions)
  • Isolate AsmResult as multiple different errors, and provide a better error message.
  • GUI interactions
    • GUI backend:
      • unzip (whatever jar or dex) & parallel read
      • retrieve metadata and combine multiple metadata for better indexing
      • using metadata to get the real data if needed (e.g. method instructions)
      • search content, quick search for metadata and slow search for instructions.
    • GUI frontend:
      • basic window with egui.
      • load files from the backend
      • show metadata in a tree view
      • show instructions in a list view
      • quick jump to specific metadata

Goals

  1. Fully read and write Java class file with JVMS format.
  2. Partially implement ASM features in rust, but provides some better operations in rust.
  3. Support much newer Java version (higher priority for LTS, Java 21 currently).
  4. For parser core, not depends on any of other rust libraries at runtime, build everything from std only. (but some proc marco's dependencies are used for generate some template codes. e.g. quote and syn)
  5. Simple GUI to show decompiled jar like files. e.g. dex, apk, jar, class files.

Some similar projects:

Dependencies

~1.5MB
~37K SLoC