MCPcopy Index your code
hub / github.com/Palmr/classfile-parser

github.com/Palmr/classfile-parser @0.3.8

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.3.8 ↗ · + Follow
130 symbols 202 edges 32 files 4 documented · 3%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Java Classfile Parser

LICENSE Rust Crates.io Version

A parser for Java Classfiles, written in Rust using nom.

Installation

Classfile Parser is available from crates.io and can be included in your Cargo enabled project like this:

[dependencies]
classfile-parser = "~0.3"

Usage

extern crate classfile_parser;

use classfile_parser::class_parser;

fn main() {
    let classfile_bytes = include_bytes!("../path/to/JavaClass.class");

    match class_parser(classfile_bytes) {
        Ok((_, class_file)) => {
            println!(
                "version {},{} \
                 const_pool({}), \
                 this=const[{}], \
                 super=const[{}], \
                 interfaces({}), \
                 fields({}), \
                 methods({}), \
                 attributes({}), \
                 access({:?})",
                class_file.major_version,
                class_file.minor_version,
                class_file.const_pool_size,
                class_file.this_class,
                class_file.super_class,
                class_file.interfaces_count,
                class_file.fields_count,
                class_file.methods_count,
                class_file.attributes_count,
                class_file.access_flags
            );
        }
        Err(_) => panic!("Failed to parse"),
    };
}

Implementation Status

  • [x] Header
  • [x] Magic const
  • [x] Version info
  • [x] Constant pool
  • [x] Constant pool size
  • [x] Constant types
    • [x] Utf8
    • [x] Integer
    • [x] Float
    • [x] Long
    • [x] Double
    • [x] Class
    • [x] String
    • [x] Fieldref
    • [x] Methodref
    • [x] InterfaceMethodref
    • [x] NameAndType
    • [x] MethodHandle
    • [x] MethodType
    • [x] InvokeDynamic
  • [x] Access flags
  • [x] This class
  • [x] Super class
  • [x] Interfaces
  • [x] Fields
  • [x] Methods
  • [x] Attributes
  • [x] Basic attribute info block parsing
  • [ ] Known typed attributes parsing
    • [x] Critical for JVM
    • [x] ConstantValue
    • [x] Code
    • [x] StackMapTable
    • [x] Exceptions
    • [x] BootstrapMethods
    • [ ] Critical for Java SE
    • [ ] InnerClasses
    • [ ] EnclosingMethod
    • [ ] Synthetic
    • [ ] Signature
    • [ ] RuntimeVisibleAnnotations
    • [ ] RuntimeInvisibleAnnotations
    • [ ] RuntimeVisibleParameterAnnotations
    • [ ] RuntimeInvisibleParameterAnnotations
    • [ ] RuntimeVisibleTypeAnnotations
    • [ ] RuntimeInvisibleTypeAnnotations
    • [ ] AnnotationDefault
    • [X] MethodParameters
    • [ ] Useful but not critical
    • [x] SourceFile
    • [ ] SourceDebugExtension
    • [ ] LineNumberTable
    • [ ] LocalVariableTable
    • [ ] LocalVariableTypeTable
    • [ ] Deprecated

Extension points exported contracts — how you extend this code

BasicInterface (Interface)
(no doc) [2 implementers]
java-assets/src/uk/co/palmr/classfileparser/BasicInterface.java
TraitTester (Interface)
(no doc) [1 implementers]
src/types.rs
TraitTester (Interface)
(no doc) [1 implementers]
src/field_info/types.rs
TraitTester (Interface)
(no doc) [1 implementers]
src/method_info/types.rs

Core symbols most depended-on inside this repo

class_parser
called by 9
src/parser.rs
code_attribute_parser
called by 3
src/attribute_info/parser.rs
align
called by 2
src/code_attribute/parser.rs
verification_type_parser
called by 2
src/attribute_info/parser.rs
intMath
called by 1
java-assets/src/uk/co/palmr/classfileparser/SimpleMath.java
floatMath
called by 1
java-assets/src/uk/co/palmr/classfileparser/SimpleMath.java
getOutputMessage
called by 1
java-assets/src/uk/co/palmr/classfileparser/InterfaceImplementor.java
add
called by 1
java-assets/src/uk/co/palmr/classfileparser/BasicClass.java

Shape

Function 65
Class 37
Method 20
Enum 4
Interface 4

Languages

Rust77%
Java23%

Modules by API surface

src/attribute_info/parser.rs21 symbols
src/constant_info/parser.rs18 symbols
src/constant_info/types.rs15 symbols
src/attribute_info/types.rs13 symbols
java-assets/src/uk/co/palmr/classfileparser/BasicClass.java8 symbols
tests/code_attribute.rs7 symbols
src/code_attribute/parser.rs7 symbols
java-assets/src/uk/co/palmr/classfileparser/SimpleMath.java4 symbols
tests/classfile.rs3 symbols
java-assets/src/uk/co/palmr/classfileparser/InterfaceImplementor.java3 symbols
java-assets/src/uk/co/palmr/classfileparser/BootstrapMethods.java3 symbols
tests/attr_bootstrap_methods.rs2 symbols

For agents

$ claude mcp add classfile-parser \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact