#java-class #jvm #ecosystem #descriptor #source #signatures #maven

bin+lib jaust

Java ecosystem tools in rust a learning project

3 releases

0.1.2 Sep 15, 2024
0.1.1 Sep 7, 2024
0.1.0 Sep 5, 2024

#344 in Programming languages

Download history 256/week @ 2024-09-01 49/week @ 2024-09-08 245/week @ 2024-09-15 33/week @ 2024-09-22 13/week @ 2024-09-29

135 downloads per month

MIT license

85KB
2K SLoC

Jaust (Java in Rust)

This is a project to learn more about java and the jvm by wrtting rust library to interact with different parts of the java ecosystem.

Initially, I will be focusing on the following areas:

  • class file parsing
    • parse the method descriptors signatures
  • jar file parsing
  • Java source code parsing
  • Maven project parsing

Features

jaustp commad (javap like command)

jaustp <class file> # prints public methods and fields of class
jaustp -p <class file> # prints all methods and fields of class
jaustp -c <class file> # prints the bytecode of the methods

jaustp --raw <class file> # prints a much more verbose output describing the class file (mustly for my own debugging)

Class File Parsing

The JVM takes .class files as input. These files are generated by the java compiler from java source code. The class file contains the bytecode that the JVM will execute. Along with metadata about the class, fields, methods. Knowing how to parse these files tells us exactly what information is available to the JVM when it runs the code. The java byte code in the class file also contains all the information about method calls. So by parsing all the class files in a project, we can build a call graph of the project.

The documentation for the format is well written in the oracle docs: https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html

TODO next

  • fill out more bytecode instructins in the bytecode enum
  • parse more specific attributes
    • MethodParamaters
    • Record
    • BootstrapMethods
    • InnerClasses

Dependencies

~1.3–1.9MB
~35K SLoC