Skip to main content

Crate java_class_rs

Crate java_class_rs 

Source
Expand description

Java class file format parser.

Parses .class files according to the JVM Specification (JVMS Chapter 4). Supports all 17 constant pool entry types, access flags, fields, methods, and 20+ specialized attributes including Code, StackMapTable, BootstrapMethods, annotations, and more.

§Example

use java_class_rs::parse_classfile;

fn main() {
    let data = std::fs::read("MyClass.class").unwrap();
    let (_, class_file) = parse_classfile(&data).unwrap();
    println!("Class: {:?}", class_file.this_class_name());
}

Modules§

cp_tag
Constant pool entry tags.
ref_kind
Method handle reference kinds.

Structs§

Annotation
AttributeInfo
Generic attribute info. Specialized attributes are parsed separately.
BootstrapMethodEntry
BootstrapMethodsAttribute
ClassAccessFlags
ClassFile
Parsed Java class file.
ClassInfo
CodeAttribute
ConstantValueAttribute
DoubleInfo
DynamicInfo
ExceptionTableEntry
ExceptionsAttribute
FieldAccessFlags
FieldInfo
FieldrefInfo
FloatInfo
InnerClass
InnerClassesAttribute
IntegerInfo
InterfaceMethodrefInfo
InvokeDynamicInfo
LineNumberEntry
LineNumberTableAttribute
LocalVarTargetEntry
LocalVariableEntry
LocalVariableTableAttribute
LocalVariableTypeEntry
LocalVariableTypeTableAttribute
LongInfo
MethodAccessFlags
MethodHandleInfo
MethodInfo
MethodTypeInfo
MethodrefInfo
ModuleInfo
NameAndTypeInfo
NestHostAttribute
NestMembersAttribute
PackageInfo
ParameterAnnotation
PermittedSubclassesAttribute
RecordAttribute
RecordComponentInfo
RuntimeAnnotationsAttribute
RuntimeParameterAnnotationsAttribute
RuntimeTypeAnnotationsAttribute
SourceFileAttribute
StackMapTableAttribute
StringInfo
TypeAnnotation
A type annotation (JVMS 4.7.20).
TypePathEntry
A step in the type_path of a type annotation.
Utf8Info

Enums§

ConstantPoolEntry
A constant pool entry. Index 0 is unused; entries are 1-indexed. Long and Double entries occupy two slots.
ElementValue
ParsedAttribute
Parsed attribute with its specialized form if recognized.
StackMapFrame
TypeAnnotationTarget
Target type for a type annotation (JVMS 4.7.20).
VerificationTypeInfo

Functions§

get_entry
Helper to get a constant pool entry by its logical index (1-based, accounting for Long/Double double-slot).
get_utf8
Helper to resolve a UTF8 string from the constant pool by index (1-based). Returns None if the index is out of bounds or not a UTF8 entry.
parse_classfile
Parse a Java class file from raw bytes.
parse_specialized_attribute
Try to parse a raw attribute into a specialized attribute type based on the attribute name.