Git Product home page Git Product logo

classfile-parser's Introduction

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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.