serenity icon indicating copy to clipboard operation
serenity copied to clipboard

LibJava+javap: Add a ClassFile parser & initial work on a javap implementation

Open jamierocks opened this issue 1 year ago • 0 comments

Opening early to allow for feedback while this is developed. I'm almost certain some of this won't be 'idiomatic-Serenity' code, and welcome feedback on things I might not know exist - or better ways to approach things :)

javap example output
public class test
  minor version: 0
  major version: 61
  flags: (0x21) ACC_PUBLIC, ACC_SUPER
  this_class: #21    // test
  super_class: #2   // java/lang/Object
  interfaces: 0, fields: 0, methods: 2, attributes: 1
Constant pool:
 #1 = Methodref    #2.#3   // java/lang/Object.:()V
 #2 = Class    #4   // java/lang/Object
 #3 = NameAndType    #5.#6   // :()V
 #4 = Utf8    java/lang/Object
 #5 = Utf8    
 #6 = Utf8    ()V
 #7 = Fieldref    #8.#9   // java/lang/System.out:Ljava/io/PrintStream;
 #8 = Class    #10   // java/lang/System
 #9 = NameAndType    #11.#12   // out:Ljava/io/PrintStream;
 #10 = Utf8    java/lang/System
 #11 = Utf8    out
 #12 = Utf8    Ljava/io/PrintStream;
 #13 = String    #14   // hello, world!
 #14 = Utf8    hello, world!
 #15 = Methodref    #16.#17   // java/io/PrintStream.println:(Ljava/lang/String;)V
 #16 = Class    #18   // java/io/PrintStream
 #17 = NameAndType    #19.#20   // println:(Ljava/lang/String;)V
 #18 = Utf8    java/io/PrintStream
 #19 = Utf8    println
 #20 = Utf8    (Ljava/lang/String;)V
 #21 = Class    #22   // test
 #22 = Utf8    test
 #23 = Utf8    Code
 #24 = Utf8    LineNumberTable
 #25 = Utf8    main
 #26 = Utf8    ([Ljava/lang/String;)V
 #27 = Utf8    SourceFile
 #28 = Utf8    test.java
{
  public test();
    descriptor: ()V
    flags: (0x1) ACC_PUBLIC
  public static main();
    descriptor: ([Ljava/lang/String;)V
    flags: (0x9) ACC_PUBLIC, ACC_STATIC
}
SourceFile: "FIXME"

jamierocks avatar May 18 '24 22:05 jamierocks