Code Monkey home page Code Monkey logo

classreader's Introduction

Classreader

A Java class-file reader

Under progress..

Usage

classreader SomeJavaFile.class

API

import "core:os"
import "../dependencies/classreader"

main :: proc() {
    data, ok := os.read_entire_file("Demo.class")
    assert(ok)
    defer delete(data)

    reader := classreader.reader_new(data)
    // Note that the returned class' lifetime is bound to
    // the bytes it got from the reader
    class, err := classreader.read_classfile(&reader)
    assert(err == .None)

    classreader.classfile_dump(class)
}

Sample output:

Version: minor=0, major=65 (Java SE 21)
Access flags: 0x0021 (ACC_PUBLIC, ACC_SUPER)
Constant pool:
   #1 = MethodRef          java/lang/Object.<init>
   #2 = Class              java/lang/Object
   #3 = NameAndType        <init>:()V
   #4 = Utf8               java/lang/Object
   #5 = Utf8               <init>
   #6 = Utf8               ()V
   #7 = FieldRef           Test.i
   #8 = Class              Test
   #9 = NameAndType        i:I
  #10 = Utf8               Test
  #11 = Utf8               i
  #12 = Utf8               I
  #13 = FieldRef           Test.s
  #14 = NameAndType        s:Ljava/lang/String;
  #15 = Utf8               s
  #16 = Utf8               Ljava/lang/String;
  #17 = Utf8               ConstantValue
  #18 = Integer            2
  #19 = Utf8               (Ljava/lang/String;)V
  #20 = Utf8               Code
  #21 = Utf8               LineNumberTable
  #22 = Utf8               (I)V
  #23 = Utf8               getI
  #24 = Utf8               ()I
  #25 = Utf8               getS
  #26 = Utf8               ()Ljava/lang/String;
  #27 = Utf8               SourceFile
  #28 = Utf8               Test.java
Attributes:
  SourceFile

Building the project

classreader's People

Contributors

fourteenbrush avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

lillianrubyrose

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.