Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/FourteenBrush/Classreader
A Java class-file reader
https://github.com/FourteenBrush/Classreader
class-file java-classfiles javaclass odin odin-lang
Last synced: 18 days ago
JSON representation
A Java class-file reader
- Host: GitHub
- URL: https://github.com/FourteenBrush/Classreader
- Owner: FourteenBrush
- License: mit
- Created: 2023-09-23T13:32:01.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-21T12:51:28.000Z (4 months ago)
- Last Synced: 2024-08-21T22:10:34.623Z (4 months ago)
- Topics: class-file, java-classfiles, javaclass, odin, odin-lang
- Language: Odin
- Homepage:
- Size: 1.63 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-odin - Java classfile parser
- awesome-odin - Java classfile parser
README
# Classreader
A Java class-file reader*Under progress..*
## Usage
```
classreader SomeJavaFile.class
```## API
```go
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.
#2 = Class java/lang/Object
#3 = NameAndType :()V
#4 = Utf8 java/lang/Object
#5 = Utf8
#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
- Make sure you got the [Task build system](https://taskfile.dev/installation/) and the [Odin compiler](https://odin-lang.org/docs/install/) installed.
- Build with `task` or run `task -l` to show all available options