use phoron_core::{deserializer::Deserializer, rw::reader::Reader}; use std::{error::Error, io::Cursor}; pub type DeserializerResult = Result<(), Box>; // Bytecode for the following class file: //Classfile /Users/z0ltan/dev/playground/HelloWorld.class // Last modified 27-Jan-2023; size 422 bytes // SHA-256 checksum 8b07d9dd65152998eda6951af14be9052f0dd66d8c60bbf1be42530fefe2e056 // Compiled from "HelloWorld.java" //public class HelloWorld // minor version: 0 // major version: 65 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #21 // HelloWorld // 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 // HelloWorld // #22 = Utf8 HelloWorld // #23 = Utf8 Code // #24 = Utf8 LineNumberTable // #25 = Utf8 main // #26 = Utf8 ([Ljava/lang/String;)V // #27 = Utf8 SourceFile // #28 = Utf8 HelloWorld.java //{ // public HelloWorld(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #1 // Method java/lang/Object."":()V // 4: return // LineNumberTable: // line 1: 0 // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=2, locals=1, args_size=1 // 0: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream; // 3: ldc #13 // String Hello, world // 5: invokevirtual #15 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 8: return // LineNumberTable: // line 2: 0 //} //SourceFile: "HelloWorld.java" #[test] fn test_deserialize_hello_world() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x00, 0x00, 0x41, 0x00, 0x1d, 0x0a, 0x00, 0x02, 0x00, 0x03, 0x07, 0x00, 0x04, 0x0c, 0x00, 0x05, 0x00, 0x06, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x09, 0x00, 0x08, 0x00, 0x09, 0x07, 0x00, 0x0a, 0x0c, 0x00, 0x0b, 0x00, 0x0c, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x01, 0x00, 0x03, 0x6f, 0x75, 0x74, 0x01, 0x00, 0x15, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x08, 0x00, 0x0e, 0x01, 0x00, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x0a, 0x00, 0x10, 0x00, 0x11, 0x07, 0x00, 0x12, 0x0c, 0x00, 0x13, 0x00, 0x14, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x01, 0x00, 0x07, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x6c, 0x6e, 0x01, 0x00, 0x15, 0x28, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x07, 0x00, 0x16, 0x01, 0x00, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, 0x0f, 0x4c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x0f, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x6a, 0x61, 0x76, 0x61, 0x00, 0x21, 0x00, 0x15, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, 0x00, 0x06, 0x00, 0x01, 0x00, 0x17, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x01, 0xb1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x19, 0x00, 0x1a, 0x00, 0x01, 0x00, 0x17, 0x00, 0x00, 0x00, 0x21, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0xb2, 0x00, 0x07, 0x12, 0x0d, 0xb6, 0x00, 0x0f, 0xb1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x1c, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/playground/Fields.class // Last modified 27-Jan-2023; size 1023 bytes // SHA-256 checksum 65434f38c6bb13a5bf08b4226f80394cfaba5cc5dcbb7cacd3145cb3336f49f2 // Compiled from "Fields.java" //public class Fields // minor version: 0 // major version: 65 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #8 // Fields // super_class: #2 // java/lang/Object // interfaces: 0, fields: 5, 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 // Fields.one:I // #8 = Class #10 // Fields // #9 = NameAndType #11:#12 // one:I // #10 = Utf8 Fields // #11 = Utf8 one // #12 = Utf8 I // #13 = Fieldref #8.#14 // Fields.two:Ljava/lang/String; // #14 = NameAndType #15:#16 // two:Ljava/lang/String; // #15 = Utf8 two // #16 = Utf8 Ljava/lang/String; // #17 = Fieldref #8.#18 // Fields.three:D // #18 = NameAndType #19:#20 // three:D // #19 = Utf8 three // #20 = Utf8 D // #21 = Fieldref #8.#22 // Fields.four:Z // #22 = NameAndType #23:#24 // four:Z // #23 = Utf8 four // #24 = Utf8 Z // #25 = Fieldref #8.#26 // Fields.five:Ljava/lang/Integer; // #26 = NameAndType #27:#28 // five:Ljava/lang/Integer; // #27 = Utf8 five // #28 = Utf8 Ljava/lang/Integer; // #29 = String #15 // two // #30 = Double 3.0d // #32 = Methodref #33.#34 // java/lang/Integer.valueOf:(I)Ljava/lang/Integer; // #33 = Class #35 // java/lang/Integer // #34 = NameAndType #36:#37 // valueOf:(I)Ljava/lang/Integer; // #35 = Utf8 java/lang/Integer // #36 = Utf8 valueOf // #37 = Utf8 (I)Ljava/lang/Integer; // #38 = Methodref #8.#39 // Fields."":(ILjava/lang/String;DZLjava/lang/Integer;)V // #39 = NameAndType #5:#40 // "":(ILjava/lang/String;DZLjava/lang/Integer;)V // #40 = Utf8 (ILjava/lang/String;DZLjava/lang/Integer;)V // #41 = Fieldref #42.#43 // java/lang/System.out:Ljava/io/PrintStream; // #42 = Class #44 // java/lang/System // #43 = NameAndType #45:#46 // out:Ljava/io/PrintStream; // #44 = Utf8 java/lang/System // #45 = Utf8 out // #46 = Utf8 Ljava/io/PrintStream; // #47 = String #48 // %d, %s, %f, %b, %d\n // #48 = Utf8 %d, %s, %f, %b, %d\n // #49 = Methodref #50.#51 // java/lang/Double.valueOf:(D)Ljava/lang/Double; // #50 = Class #52 // java/lang/Double // #51 = NameAndType #36:#53 // valueOf:(D)Ljava/lang/Double; // #52 = Utf8 java/lang/Double // #53 = Utf8 (D)Ljava/lang/Double; // #54 = Methodref #55.#56 // java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean; // #55 = Class #57 // java/lang/Boolean // #56 = NameAndType #36:#58 // valueOf:(Z)Ljava/lang/Boolean; // #57 = Utf8 java/lang/Boolean // #58 = Utf8 (Z)Ljava/lang/Boolean; // #59 = Methodref #60.#61 // java/io/PrintStream.printf:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream; // #60 = Class #62 // java/io/PrintStream // #61 = NameAndType #63:#64 // printf:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream; // #62 = Utf8 java/io/PrintStream // #63 = Utf8 printf // #64 = Utf8 (Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream; // #65 = Utf8 Code // #66 = Utf8 LineNumberTable // #67 = Utf8 main // #68 = Utf8 ([Ljava/lang/String;)V // #69 = Utf8 SourceFile // #70 = Utf8 Fields.java //{ // public double three; // descriptor: D // flags: (0x0001) ACC_PUBLIC // // protected boolean four; // descriptor: Z // flags: (0x0004) ACC_PROTECTED // // java.lang.Integer five; // descriptor: Ljava/lang/Integer; // flags: (0x0000) // // Fields(int, java.lang.String, double, boolean, java.lang.Integer); // descriptor: (ILjava/lang/String;DZLjava/lang/Integer;)V // flags: (0x0000) // Code: // stack=3, locals=7, args_size=6 // 0: aload_0 // 1: invokespecial #1 // Method java/lang/Object."":()V // 4: aload_0 // 5: iload_1 // 6: putfield #7 // Field one:I // 9: aload_0 // 10: aload_2 // 11: putfield #13 // Field two:Ljava/lang/String; // 14: aload_0 // 15: dload_3 // 16: putfield #17 // Field three:D // 19: aload_0 // 20: iload 5 // 22: putfield #21 // Field four:Z // 25: aload_0 // 26: aload 6 // 28: putfield #25 // Field five:Ljava/lang/Integer; // 31: return // LineNumberTable: // line 8: 0 // line 9: 4 // line 10: 9 // line 11: 14 // line 12: 19 // line 13: 25 // line 14: 31 // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=8, locals=2, args_size=1 // 0: new #8 // class Fields // 3: dup // 4: iconst_1 // 5: ldc #29 // String two // 7: ldc2_w #30 // double 3.0d // 10: iconst_1 // 11: iconst_5 // 12: invokestatic #32 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; // 15: invokespecial #38 // Method "":(ILjava/lang/String;DZLjava/lang/Integer;)V // 18: astore_1 // 19: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream; // 22: ldc #47 // String %d, %s, %f, %b, %d\n // 24: iconst_5 // 25: anewarray #2 // class java/lang/Object // 28: dup // 29: iconst_0 // 30: aload_1 // 31: getfield #7 // Field one:I // 34: invokestatic #32 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; // 37: aastore // 38: dup // 39: iconst_1 // 40: aload_1 // 41: getfield #13 // Field two:Ljava/lang/String; // 44: aastore // 45: dup // 46: iconst_2 // 47: aload_1 // 48: getfield #17 // Field three:D // 51: invokestatic #49 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double; // 54: aastore // 55: dup // 56: iconst_3 // 57: aload_1 // 58: getfield #21 // Field four:Z // 61: invokestatic #54 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean; // 64: aastore // 65: dup // 66: iconst_4 // 67: aload_1 // 68: getfield #25 // Field five:Ljava/lang/Integer; // 71: aastore // 72: invokevirtual #59 // Method java/io/PrintStream.printf:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream; // 75: pop // 76: return // LineNumberTable: // line 17: 0 // line 18: 19 // line 19: 51 // line 18: 72 // line 20: 76 //} //SourceFile: "Fields.java" #[test] fn test_deserialize_fields() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x00, 0x00, 0x41, 0x00, 0x47, 0x0a, 0x00, 0x02, 0x00, 0x03, 0x07, 0x00, 0x04, 0x0c, 0x00, 0x05, 0x00, 0x06, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x09, 0x00, 0x08, 0x00, 0x09, 0x07, 0x00, 0x0a, 0x0c, 0x00, 0x0b, 0x00, 0x0c, 0x01, 0x00, 0x06, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x01, 0x00, 0x03, 0x6f, 0x6e, 0x65, 0x01, 0x00, 0x01, 0x49, 0x09, 0x00, 0x08, 0x00, 0x0e, 0x0c, 0x00, 0x0f, 0x00, 0x10, 0x01, 0x00, 0x03, 0x74, 0x77, 0x6f, 0x01, 0x00, 0x12, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x09, 0x00, 0x08, 0x00, 0x12, 0x0c, 0x00, 0x13, 0x00, 0x14, 0x01, 0x00, 0x05, 0x74, 0x68, 0x72, 0x65, 0x65, 0x01, 0x00, 0x01, 0x44, 0x09, 0x00, 0x08, 0x00, 0x16, 0x0c, 0x00, 0x17, 0x00, 0x18, 0x01, 0x00, 0x04, 0x66, 0x6f, 0x75, 0x72, 0x01, 0x00, 0x01, 0x5a, 0x09, 0x00, 0x08, 0x00, 0x1a, 0x0c, 0x00, 0x1b, 0x00, 0x1c, 0x01, 0x00, 0x04, 0x66, 0x69, 0x76, 0x65, 0x01, 0x00, 0x13, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3b, 0x08, 0x00, 0x0f, 0x06, 0x40, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x21, 0x00, 0x22, 0x07, 0x00, 0x23, 0x0c, 0x00, 0x24, 0x00, 0x25, 0x01, 0x00, 0x11, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x01, 0x00, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x4f, 0x66, 0x01, 0x00, 0x16, 0x28, 0x49, 0x29, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3b, 0x0a, 0x00, 0x08, 0x00, 0x27, 0x0c, 0x00, 0x05, 0x00, 0x28, 0x01, 0x00, 0x2b, 0x28, 0x49, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x44, 0x5a, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x3b, 0x29, 0x56, 0x09, 0x00, 0x2a, 0x00, 0x2b, 0x07, 0x00, 0x2c, 0x0c, 0x00, 0x2d, 0x00, 0x2e, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x01, 0x00, 0x03, 0x6f, 0x75, 0x74, 0x01, 0x00, 0x15, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x08, 0x00, 0x30, 0x01, 0x00, 0x13, 0x25, 0x64, 0x2c, 0x20, 0x25, 0x73, 0x2c, 0x20, 0x25, 0x66, 0x2c, 0x20, 0x25, 0x62, 0x2c, 0x20, 0x25, 0x64, 0x0a, 0x0a, 0x00, 0x32, 0x00, 0x33, 0x07, 0x00, 0x34, 0x0c, 0x00, 0x24, 0x00, 0x35, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x01, 0x00, 0x15, 0x28, 0x44, 0x29, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x3b, 0x0a, 0x00, 0x37, 0x00, 0x38, 0x07, 0x00, 0x39, 0x0c, 0x00, 0x24, 0x00, 0x3a, 0x01, 0x00, 0x11, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x01, 0x00, 0x16, 0x28, 0x5a, 0x29, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x3b, 0x0a, 0x00, 0x3c, 0x00, 0x3d, 0x07, 0x00, 0x3e, 0x0c, 0x00, 0x3f, 0x00, 0x40, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x01, 0x00, 0x06, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x01, 0x00, 0x3c, 0x28, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x3b, 0x29, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, 0x0f, 0x4c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x0b, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x2e, 0x6a, 0x61, 0x76, 0x61, 0x00, 0x21, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0f, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x13, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x17, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x28, 0x00, 0x01, 0x00, 0x41, 0x00, 0x00, 0x00, 0x50, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x2a, 0xb7, 0x00, 0x01, 0x2a, 0x1b, 0xb5, 0x00, 0x07, 0x2a, 0x2c, 0xb5, 0x00, 0x0d, 0x2a, 0x29, 0xb5, 0x00, 0x11, 0x2a, 0x15, 0x05, 0xb5, 0x00, 0x15, 0x2a, 0x19, 0x06, 0xb5, 0x00, 0x19, 0xb1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x09, 0x00, 0x09, 0x00, 0x0a, 0x00, 0x0e, 0x00, 0x0b, 0x00, 0x13, 0x00, 0x0c, 0x00, 0x19, 0x00, 0x0d, 0x00, 0x1f, 0x00, 0x0e, 0x00, 0x09, 0x00, 0x43, 0x00, 0x44, 0x00, 0x01, 0x00, 0x41, 0x00, 0x00, 0x00, 0x75, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x4d, 0xbb, 0x00, 0x08, 0x59, 0x04, 0x12, 0x1d, 0x14, 0x00, 0x1e, 0x04, 0x08, 0xb8, 0x00, 0x20, 0xb7, 0x00, 0x26, 0x4c, 0xb2, 0x00, 0x29, 0x12, 0x2f, 0x08, 0xbd, 0x00, 0x02, 0x59, 0x03, 0x2b, 0xb4, 0x00, 0x07, 0xb8, 0x00, 0x20, 0x53, 0x59, 0x04, 0x2b, 0xb4, 0x00, 0x0d, 0x53, 0x59, 0x05, 0x2b, 0xb4, 0x00, 0x11, 0xb8, 0x00, 0x31, 0x53, 0x59, 0x06, 0x2b, 0xb4, 0x00, 0x15, 0xb8, 0x00, 0x36, 0x53, 0x59, 0x07, 0x2b, 0xb4, 0x00, 0x19, 0x53, 0xb6, 0x00, 0x3b, 0x57, 0xb1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x42, 0x00, 0x00, 0x00, 0x16, 0x00, 0x05, 0x00, 0x00, 0x00, 0x11, 0x00, 0x13, 0x00, 0x12, 0x00, 0x33, 0x00, 0x13, 0x00, 0x48, 0x00, 0x12, 0x00, 0x4c, 0x00, 0x14, 0x00, 0x01, 0x00, 0x45, 0x00, 0x00, 0x00, 0x02, 0x00, 0x46, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Uses/z0ltan/dev/playground/ArithEvaluator.class // Last modified 31-Jan-2023; size 1148 bytes // SHA-256 checksum 709b0cbc3ec9c48129e97fd18ba5f4ed5c24ada073243ddc425b449d43bb2b9a // Compiled from "ArithEvaluator.java" //public class ArithEvaluator // minor version: 0 // major version: 65 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #22 // ArithEvaluator // super_class: #2 // java/lang/Object // interfaces: 0, fields: 1, 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 = Class #8 // java/util/Scanner // #8 = Utf8 java/util/Scanner // #9 = Fieldref #10.#11 // java/lang/System.in:Ljava/io/InputStream; // #10 = Class #12 // java/lang/System // #11 = NameAndType #13:#14 // in:Ljava/io/InputStream; // #12 = Utf8 java/lang/System // #13 = Utf8 in // #14 = Utf8 Ljava/io/InputStream; // #15 = Methodref #7.#16 // java/util/Scanner."":(Ljava/io/InputStream;)V // #16 = NameAndType #5:#17 // "":(Ljava/io/InputStream;)V // #17 = Utf8 (Ljava/io/InputStream;)V // #18 = Fieldref #10.#19 // java/lang/System.out:Ljava/io/PrintStream; // #19 = NameAndType #20:#21 // out:Ljava/io/PrintStream; // #20 = Utf8 out // #21 = Utf8 Ljava/io/PrintStream; // #22 = Class #23 // ArithEvaluator // #23 = Utf8 ArithEvaluator // #24 = String #25 // >> // #25 = Utf8 >> // #26 = Methodref #27.#28 // java/io/PrintStream.print:(Ljava/lang/String;)V // #27 = Class #29 // java/io/PrintStream // #28 = NameAndType #30:#31 // print:(Ljava/lang/String;)V // #29 = Utf8 java/io/PrintStream // #30 = Utf8 print // #31 = Utf8 (Ljava/lang/String;)V // #32 = Methodref #27.#33 // java/io/PrintStream.flush:()V // #33 = NameAndType #34:#6 // flush:()V // #34 = Utf8 flush // #35 = Methodref #7.#36 // java/util/Scanner.nextLine:()Ljava/lang/String; // #36 = NameAndType #37:#38 // nextLine:()Ljava/lang/String; // #37 = Utf8 nextLine // #38 = Utf8 ()Ljava/lang/String; // #39 = Methodref #40.#41 // java/lang/String.trim:()Ljava/lang/String; // #40 = Class #42 // java/lang/String // #41 = NameAndType #43:#38 // trim:()Ljava/lang/String; // #42 = Utf8 java/lang/String // #43 = Utf8 trim // #44 = Class #45 // Parser // #45 = Utf8 Parser // #46 = Class #47 // Lexer // #47 = Utf8 Lexer // #48 = Methodref #46.#49 // Lexer."":(Ljava/lang/String;)V // #49 = NameAndType #5:#31 // "":(Ljava/lang/String;)V // #50 = Methodref #44.#51 // Parser."":(LLexer;)V // #51 = NameAndType #5:#52 // "":(LLexer;)V // #52 = Utf8 (LLexer;)V // #53 = Class #54 // Evaluator // #54 = Utf8 Evaluator // #55 = Methodref #53.#3 // Evaluator."":()V // #56 = Methodref #44.#57 // Parser.parse:()LAst; // #57 = NameAndType #58:#59 // parse:()LAst; // #58 = Utf8 parse // #59 = Utf8 ()LAst; // #60 = Methodref #53.#61 // Evaluator.eval:(LAst;)D // #61 = NameAndType #62:#63 // eval:(LAst;)D // #62 = Utf8 eval // #63 = Utf8 (LAst;)D // #64 = Methodref #27.#65 // java/io/PrintStream.println:(D)V // #65 = NameAndType #66:#67 // println:(D)V // #66 = Utf8 println // #67 = Utf8 (D)V // #68 = Class #69 // java/lang/Throwable // #69 = Utf8 java/lang/Throwable // #70 = Methodref #7.#71 // java/util/Scanner.close:()V // #71 = NameAndType #72:#6 // close:()V // #72 = Utf8 close // #73 = Methodref #68.#74 // java/lang/Throwable.addSuppressed:(Ljava/lang/Throwable;)V // #74 = NameAndType #75:#76 // addSuppressed:(Ljava/lang/Throwable;)V // #75 = Utf8 addSuppressed // #76 = Utf8 (Ljava/lang/Throwable;)V // #77 = Utf8 PROMPT // #78 = Utf8 Ljava/lang/String; // #79 = Utf8 ConstantValue // #80 = Utf8 Code // #81 = Utf8 LineNumberTable // #82 = Utf8 main // #83 = Utf8 ([Ljava/lang/String;)V // #84 = Utf8 StackMapTable // #85 = Class #86 // "[Ljava/lang/String;" // #86 = Utf8 [Ljava/lang/String; // #87 = Utf8 SourceFile // #88 = Utf8 ArithEvaluator.java //{ // public ArithEvaluator(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #1 // Method java/lang/Object."":()V // 4: return // LineNumberTable: // line 3: 0 // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=5, locals=5, args_size=1 // 0: new #7 // class java/util/Scanner // 3: dup // 4: getstatic #9 // Field java/lang/System.in:Ljava/io/InputStream; // 7: invokespecial #15 // Method java/util/Scanner."":(Ljava/io/InputStream;)V // 10: astore_1 // 11: getstatic #18 // Field java/lang/System.out:Ljava/io/PrintStream; // 14: ldc #24 // String >> // 16: invokevirtual #26 // Method java/io/PrintStream.print:(Ljava/lang/String;)V // 19: getstatic #18 // Field java/lang/System.out:Ljava/io/PrintStream; // 22: invokevirtual #32 // Method java/io/PrintStream.flush:()V // 25: aload_1 // 26: invokevirtual #35 // Method java/util/Scanner.nextLine:()Ljava/lang/String; // 29: invokevirtual #39 // Method java/lang/String.trim:()Ljava/lang/String; // 32: astore_2 // 33: new #44 // class Parser // 36: dup // 37: new #46 // class Lexer // 40: dup // 41: aload_2 // 42: invokespecial #48 // Method Lexer."":(Ljava/lang/String;)V // 45: invokespecial #50 // Method Parser."":(LLexer;)V // 48: astore_3 // 49: new #53 // class Evaluator // 52: dup // 53: invokespecial #55 // Method Evaluator."":()V // 56: astore 4 // 58: getstatic #18 // Field java/lang/System.out:Ljava/io/PrintStream; // 61: aload 4 // 63: aload_3 // 64: invokevirtual #56 // Method Parser.parse:()LAst; // 67: invokevirtual #60 // Method Evaluator.eval:(LAst;)D // 70: invokevirtual #64 // Method java/io/PrintStream.println:(D)V // 73: goto 11 // 76: astore_2 // 77: aload_1 // 78: invokevirtual #70 // Method java/util/Scanner.close:()V // 81: goto 90 // 84: astore_3 // 85: aload_2 // 86: aload_3 // 87: invokevirtual #73 // Method java/lang/Throwable.addSuppressed:(Ljava/lang/Throwable;)V // 90: aload_2 // 91: athrow // Exception table: // from to target type // 11 76 76 Class java/lang/Throwable // 77 81 84 Class java/lang/Throwable // LineNumberTable: // line 7: 0 // line 9: 11 // line 10: 19 // line 12: 25 // line 13: 33 // line 14: 49 // line 15: 58 // line 16: 73 // line 7: 76 // StackMapTable: number_of_entries = 4 // frame_type = 252 /* append */ // offset_delta = 11 // locals = [ class java/util/Scanner ] // frame_type = 247 /* same_locals_1_stack_item_frame_extended */ // offset_delta = 64 // stack = [ class java/lang/Throwable ] // frame_type = 255 /* full_frame */ // offset_delta = 7 // locals = [ class "[Ljava/lang/String;", class java/util/Scanner, class java/lang/Throwable ] // stack = [ class java/lang/Throwable ] // frame_type = 5 /* same */ //} //SourceFile: "ArithEvaluator.java" #[test] fn test_deserialize_arith_evaluator() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x00, 0x00, 0x41, 0x00, 0x59, 0x0a, 0x00, 0x02, 0x00, 0x03, 0x07, 0x00, 0x04, 0x0c, 0x00, 0x05, 0x00, 0x06, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x07, 0x00, 0x08, 0x01, 0x00, 0x11, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x75, 0x74, 0x69, 0x6c, 0x2f, 0x53, 0x63, 0x61, 0x6e, 0x6e, 0x65, 0x72, 0x09, 0x00, 0x0a, 0x00, 0x0b, 0x07, 0x00, 0x0c, 0x0c, 0x00, 0x0d, 0x00, 0x0e, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x01, 0x00, 0x02, 0x69, 0x6e, 0x01, 0x00, 0x15, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x0a, 0x00, 0x07, 0x00, 0x10, 0x0c, 0x00, 0x05, 0x00, 0x11, 0x01, 0x00, 0x18, 0x28, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x29, 0x56, 0x09, 0x00, 0x0a, 0x00, 0x13, 0x0c, 0x00, 0x14, 0x00, 0x15, 0x01, 0x00, 0x03, 0x6f, 0x75, 0x74, 0x01, 0x00, 0x15, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x07, 0x00, 0x17, 0x01, 0x00, 0x0e, 0x41, 0x72, 0x69, 0x74, 0x68, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x6f, 0x72, 0x08, 0x00, 0x19, 0x01, 0x00, 0x03, 0x3e, 0x3e, 0x20, 0x0a, 0x00, 0x1b, 0x00, 0x1c, 0x07, 0x00, 0x1d, 0x0c, 0x00, 0x1e, 0x00, 0x1f, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x01, 0x00, 0x05, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x01, 0x00, 0x15, 0x28, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x0a, 0x00, 0x1b, 0x00, 0x21, 0x0c, 0x00, 0x22, 0x00, 0x06, 0x01, 0x00, 0x05, 0x66, 0x6c, 0x75, 0x73, 0x68, 0x0a, 0x00, 0x07, 0x00, 0x24, 0x0c, 0x00, 0x25, 0x00, 0x26, 0x01, 0x00, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x4c, 0x69, 0x6e, 0x65, 0x01, 0x00, 0x14, 0x28, 0x29, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x0a, 0x00, 0x28, 0x00, 0x29, 0x07, 0x00, 0x2a, 0x0c, 0x00, 0x2b, 0x00, 0x26, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x01, 0x00, 0x04, 0x74, 0x72, 0x69, 0x6d, 0x07, 0x00, 0x2d, 0x01, 0x00, 0x06, 0x50, 0x61, 0x72, 0x73, 0x65, 0x72, 0x07, 0x00, 0x2f, 0x01, 0x00, 0x05, 0x4c, 0x65, 0x78, 0x65, 0x72, 0x0a, 0x00, 0x2e, 0x00, 0x31, 0x0c, 0x00, 0x05, 0x00, 0x1f, 0x0a, 0x00, 0x2c, 0x00, 0x33, 0x0c, 0x00, 0x05, 0x00, 0x34, 0x01, 0x00, 0x0a, 0x28, 0x4c, 0x4c, 0x65, 0x78, 0x65, 0x72, 0x3b, 0x29, 0x56, 0x07, 0x00, 0x36, 0x01, 0x00, 0x09, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x6f, 0x72, 0x0a, 0x00, 0x35, 0x00, 0x03, 0x0a, 0x00, 0x2c, 0x00, 0x39, 0x0c, 0x00, 0x3a, 0x00, 0x3b, 0x01, 0x00, 0x05, 0x70, 0x61, 0x72, 0x73, 0x65, 0x01, 0x00, 0x07, 0x28, 0x29, 0x4c, 0x41, 0x73, 0x74, 0x3b, 0x0a, 0x00, 0x35, 0x00, 0x3d, 0x0c, 0x00, 0x3e, 0x00, 0x3f, 0x01, 0x00, 0x04, 0x65, 0x76, 0x61, 0x6c, 0x01, 0x00, 0x08, 0x28, 0x4c, 0x41, 0x73, 0x74, 0x3b, 0x29, 0x44, 0x0a, 0x00, 0x1b, 0x00, 0x41, 0x0c, 0x00, 0x42, 0x00, 0x43, 0x01, 0x00, 0x07, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x6c, 0x6e, 0x01, 0x00, 0x04, 0x28, 0x44, 0x29, 0x56, 0x07, 0x00, 0x45, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x54, 0x68, 0x72, 0x6f, 0x77, 0x61, 0x62, 0x6c, 0x65, 0x0a, 0x00, 0x07, 0x00, 0x47, 0x0c, 0x00, 0x48, 0x00, 0x06, 0x01, 0x00, 0x05, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x0a, 0x00, 0x44, 0x00, 0x4a, 0x0c, 0x00, 0x4b, 0x00, 0x4c, 0x01, 0x00, 0x0d, 0x61, 0x64, 0x64, 0x53, 0x75, 0x70, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x01, 0x00, 0x18, 0x28, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x54, 0x68, 0x72, 0x6f, 0x77, 0x61, 0x62, 0x6c, 0x65, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x06, 0x50, 0x52, 0x4f, 0x4d, 0x50, 0x54, 0x01, 0x00, 0x12, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x01, 0x00, 0x0d, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, 0x0f, 0x4c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x0d, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x4d, 0x61, 0x70, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x07, 0x00, 0x56, 0x01, 0x00, 0x13, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x13, 0x41, 0x72, 0x69, 0x74, 0x68, 0x45, 0x76, 0x61, 0x6c, 0x75, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x6a, 0x61, 0x76, 0x61, 0x00, 0x21, 0x00, 0x16, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1a, 0x00, 0x4d, 0x00, 0x4e, 0x00, 0x01, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x18, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, 0x00, 0x06, 0x00, 0x01, 0x00, 0x50, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x01, 0xb1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x51, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x09, 0x00, 0x52, 0x00, 0x53, 0x00, 0x01, 0x00, 0x50, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x00, 0x5c, 0xbb, 0x00, 0x07, 0x59, 0xb2, 0x00, 0x09, 0xb7, 0x00, 0x0f, 0x4c, 0xb2, 0x00, 0x12, 0x12, 0x18, 0xb6, 0x00, 0x1a, 0xb2, 0x00, 0x12, 0xb6, 0x00, 0x20, 0x2b, 0xb6, 0x00, 0x23, 0xb6, 0x00, 0x27, 0x4d, 0xbb, 0x00, 0x2c, 0x59, 0xbb, 0x00, 0x2e, 0x59, 0x2c, 0xb7, 0x00, 0x30, 0xb7, 0x00, 0x32, 0x4e, 0xbb, 0x00, 0x35, 0x59, 0xb7, 0x00, 0x37, 0x3a, 0x04, 0xb2, 0x00, 0x12, 0x19, 0x04, 0x2d, 0xb6, 0x00, 0x38, 0xb6, 0x00, 0x3c, 0xb6, 0x00, 0x40, 0xa7, 0xff, 0xc2, 0x4d, 0x2b, 0xb6, 0x00, 0x46, 0xa7, 0x00, 0x09, 0x4e, 0x2c, 0x2d, 0xb6, 0x00, 0x49, 0x2c, 0xbf, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x4c, 0x00, 0x4c, 0x00, 0x44, 0x00, 0x4d, 0x00, 0x51, 0x00, 0x54, 0x00, 0x44, 0x00, 0x02, 0x00, 0x51, 0x00, 0x00, 0x00, 0x26, 0x00, 0x09, 0x00, 0x00, 0x00, 0x07, 0x00, 0x0b, 0x00, 0x09, 0x00, 0x13, 0x00, 0x0a, 0x00, 0x19, 0x00, 0x0c, 0x00, 0x21, 0x00, 0x0d, 0x00, 0x31, 0x00, 0x0e, 0x00, 0x3a, 0x00, 0x0f, 0x00, 0x49, 0x00, 0x10, 0x00, 0x4c, 0x00, 0x07, 0x00, 0x54, 0x00, 0x00, 0x00, 0x22, 0x00, 0x04, 0xfc, 0x00, 0x0b, 0x07, 0x00, 0x07, 0xf7, 0x00, 0x40, 0x07, 0x00, 0x44, 0xff, 0x00, 0x07, 0x00, 0x03, 0x07, 0x00, 0x55, 0x07, 0x00, 0x07, 0x07, 0x00, 0x44, 0x00, 0x01, 0x07, 0x00, 0x44, 0x05, 0x00, 0x01, 0x00, 0x57, 0x00, 0x00, 0x00, 0x02, 0x00, 0x58, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/playground/HelloWorld.class // Last modified 01-Mar-2023; size 380 bytes // SHA-256 checksum ef195638e3713a3dde3628d6e9f23bc0a3b29b03a2ba8c4d1b676958a9c657b5 // Compiled from "HelloWorld.java" //public class HelloWorld // minor version: 3 // major version: 45 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #12 // HelloWorld // super_class: #5 // java/lang/Object // interfaces: 0, fields: 0, methods: 2, attributes: 1 //Constant pool: // #1 = NameAndType #24:#27 // out:Ljava/io/PrintStream; // #2 = Utf8 ([Ljava/lang/String;)V // #3 = Utf8 java/lang/Object // #4 = Utf8 // #5 = Class #3 // java/lang/Object // #6 = NameAndType #4:#8 // "":()V // #7 = Class #18 // java/io/PrintStream // #8 = Utf8 ()V // #9 = Class #22 // java/lang/System // #10 = Utf8 Code // #11 = Utf8 main // #12 = Class #17 // HelloWorld // #13 = Fieldref #9.#1 // java/lang/System.out:Ljava/io/PrintStream; // #14 = Utf8 SourceFile // #15 = Utf8 Hello, world // #16 = NameAndType #19:#25 // println:(Ljava/lang/String;)V // #17 = Utf8 HelloWorld // #18 = Utf8 java/io/PrintStream // #19 = Utf8 println // #20 = Methodref #5.#6 // java/lang/Object."":()V // #21 = String #15 // Hello, world // #22 = Utf8 java/lang/System // #23 = Methodref #7.#16 // java/io/PrintStream.println:(Ljava/lang/String;)V // #24 = Utf8 out // #25 = Utf8 (Ljava/lang/String;)V // #26 = Utf8 HelloWorld.java // #27 = Utf8 Ljava/io/PrintStream; //{ // public HelloWorld(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #20 // Method java/lang/Object."":()V // 4: return // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=2, locals=1, args_size=1 // 0: getstatic #13 // Field java/lang/System.out:Ljava/io/PrintStream; // 3: ldc #21 // String Hello, world // 5: invokevirtual #23 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 8: return //} //SourceFile: "HelloWorld.java" #[test] fn test_deserialize_hello_world_no_line_number_table() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x1c, 0x0c, 0x00, 0x18, 0x00, 0x1b, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x07, 0x00, 0x03, 0x0c, 0x00, 0x04, 0x00, 0x08, 0x07, 0x00, 0x12, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x07, 0x00, 0x16, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x07, 0x00, 0x11, 0x09, 0x00, 0x09, 0x00, 0x01, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x0c, 0x00, 0x13, 0x00, 0x19, 0x01, 0x00, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x01, 0x00, 0x07, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x6c, 0x6e, 0x0a, 0x00, 0x05, 0x00, 0x06, 0x08, 0x00, 0x0f, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x0a, 0x00, 0x07, 0x00, 0x10, 0x01, 0x00, 0x03, 0x6f, 0x75, 0x74, 0x01, 0x00, 0x15, 0x28, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x0f, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x6a, 0x61, 0x76, 0x61, 0x01, 0x00, 0x15, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x00, 0x21, 0x00, 0x0c, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x14, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x0b, 0x00, 0x02, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x15, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0xb2, 0x00, 0x0d, 0x12, 0x15, 0xb6, 0x00, 0x17, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x1a, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/playground/FieldsDemo.class // Last modified 02-Mar-2023; size 345 bytes // SHA-256 checksum 46d3f52393888f1761e0ce540dde51e3f3daba5e66cddaf4627ab8e0ef36cddc // Compiled from "FieldsDemo.pho" //public class FieldsDemo // minor version: 3 // major version: 45 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #12 // FieldsDemo // super_class: #5 // java/lang/Object // interfaces: 0, fields: 4, methods: 2, attributes: 1 //Constant pool: // #1 = Utf8 ([Ljava/lang/String;)V // #2 = Utf8 java/lang/Object // #3 = Utf8 // #4 = NameAndType #3:#9 // "":()V // #5 = Class #2 // java/lang/Object // #6 = Utf8 Foo // #7 = String #6 // Foo // #8 = Utf8 FieldsDemo.pho // #9 = Utf8 ()V // #10 = Utf8 Code // #11 = Utf8 main // #12 = Class #19 // FieldsDemo // #13 = Utf8 ConstantValue // #14 = Utf8 z // #15 = Utf8 y // #16 = Utf8 SourceFile // #17 = Utf8 I // #18 = Utf8 x // #19 = Utf8 FieldsDemo // #20 = Utf8 D // #21 = Methodref #5.#4 // java/lang/Object."":()V // #22 = Float 3.14159f // #23 = Utf8 PI // #24 = Utf8 Ljava/lang/String; //{ // public static final double PI; // descriptor: D // flags: (0x0019) ACC_PUBLIC, ACC_STATIC, ACC_FINAL // ConstantValue: float 3.14159f // // public FieldsDemo(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #21 // Method java/lang/Object."":()V // 4: return // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=1, locals=1, args_size=1 //} //SourceFile: "FieldsDemo.pho" #[test] fn test_deserialize_fields_demo() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x1a, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x0c, 0x00, 0x03, 0x00, 0x09, 0x07, 0x00, 0x02, 0x01, 0x00, 0x03, 0x46, 0x6f, 0x6f, 0x08, 0x00, 0x06, 0x01, 0x00, 0x0e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x44, 0x65, 0x6d, 0x6f, 0x2e, 0x70, 0x68, 0x6f, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x07, 0x00, 0x14, 0x01, 0x00, 0x0d, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x01, 0x00, 0x01, 0x7a, 0x01, 0x00, 0x01, 0x79, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x01, 0x49, 0x01, 0x00, 0x01, 0x78, 0x01, 0x00, 0x01, 0x46, 0x01, 0x00, 0x0a, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x44, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x01, 0x44, 0x0a, 0x00, 0x05, 0x00, 0x04, 0x04, 0x40, 0x49, 0x0f, 0xd0, 0x01, 0x00, 0x02, 0x50, 0x49, 0x01, 0x00, 0x12, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x00, 0x21, 0x00, 0x0c, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x12, 0x00, 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0f, 0x00, 0x15, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x19, 0x00, 0x01, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x07, 0x00, 0x19, 0x00, 0x18, 0x00, 0x13, 0x00, 0x01, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x00, 0x02, 0x00, 0x01, 0x00, 0x03, 0x00, 0x09, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x16, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x0b, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/playground/Catcher.class // Last modified 04-Mar-2023; size 424 bytes // SHA-256 checksum 530a9244b84b26a34b58decb6d48f63bd75a28e8f78e75320903a8855b15962a // Compiled from "Catcher.pho" //public class Catcher // minor version: 3 // major version: 45 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #27 // Catcher // super_class: #5 // java/lang/Object // interfaces: 0, fields: 0, methods: 2, attributes: 1 //Constant pool: // #1 = NameAndType #28:#30 // out:Ljava/io/PrintStream; // #2 = Utf8 ([Ljava/lang/String;)V // #3 = Utf8 java/lang/Object // #4 = Utf8 // #5 = Class #3 // java/lang/Object // #6 = NameAndType #4:#8 // "":()V // #7 = Class #21 // java/io/PrintStream // #8 = Utf8 ()V // #9 = Class #24 // java/lang/System // #10 = Utf8 Code // #11 = Methodref #14.#6 // java/lang/Exception."":()V // #12 = Utf8 Catcher // #13 = Utf8 main // #14 = Class #26 // java/lang/Exception // #15 = Fieldref #9.#1 // java/lang/System.out:Ljava/io/PrintStream; // #16 = String #17 // Exception Caught // #17 = Utf8 Exception Caught // #18 = Utf8 SourceFile // #19 = Utf8 Catcher.pho // #20 = NameAndType #22:#29 // println:(Ljava/lang/String;)V // #21 = Utf8 java/io/PrintStream // #22 = Utf8 println // #23 = Methodref #5.#6 // java/lang/Object."":()V // #24 = Utf8 java/lang/System // #25 = Methodref #7.#20 // java/io/PrintStream.println:(Ljava/lang/String;)V // #26 = Utf8 java/lang/Exception // #27 = Class #12 // Catcher // #28 = Utf8 out // #29 = Utf8 (Ljava/lang/String;)V // #30 = Utf8 Ljava/io/PrintStream; //{ // public Catcher(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #23 // Method java/lang/Object."":()V // 4: return // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=3, locals=3, args_size=1 // 0: new #14 // class java/lang/Exception // 3: dup // 4: invokespecial #11 // Method java/lang/Exception."":()V // 7: athrow // 8: pop // 9: getstatic #15 // Field java/lang/System.out:Ljava/io/PrintStream; // 12: ldc #16 // String Exception Caught // 14: invokevirtual #25 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 17: return // Exception table: // from to target type // 0 8 8 Class java/lang/Exception //} //SourceFile: "Catcher.pho" #[test] fn test_deserialize_catcher() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x1f, 0x0c, 0x00, 0x1c, 0x00, 0x1e, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x07, 0x00, 0x03, 0x0c, 0x00, 0x04, 0x00, 0x08, 0x07, 0x00, 0x15, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x07, 0x00, 0x18, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x0a, 0x00, 0x0e, 0x00, 0x06, 0x01, 0x00, 0x07, 0x43, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x07, 0x00, 0x1a, 0x09, 0x00, 0x09, 0x00, 0x01, 0x08, 0x00, 0x11, 0x01, 0x00, 0x10, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x43, 0x61, 0x75, 0x67, 0x68, 0x74, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x0b, 0x43, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x70, 0x68, 0x6f, 0x0c, 0x00, 0x16, 0x00, 0x1d, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x01, 0x00, 0x07, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x6c, 0x6e, 0x0a, 0x00, 0x05, 0x00, 0x06, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x0a, 0x00, 0x07, 0x00, 0x14, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x07, 0x00, 0x0c, 0x01, 0x00, 0x03, 0x6f, 0x75, 0x74, 0x01, 0x00, 0x15, 0x28, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x15, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x00, 0x21, 0x00, 0x1b, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x17, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x0d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x26, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x12, 0xbb, 0x00, 0x0e, 0x59, 0xb7, 0x00, 0x0b, 0xbf, 0x57, 0xb2, 0x00, 0x0f, 0x12, 0x10, 0xb6, 0x00, 0x19, 0xb1, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x02, 0x00, 0x13, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/playground/LookupswitchDemo.class // Last modified 07-Mar-2023; size 533 bytes // SHA-256 checksum f31ae9c21e28ccbd6126dfd09b46ee6ba0f21426bf83390913a4911b49d241d8 // Compiled from "LookupSwitchDemo.pho" //public class LookupswitchDemo // minor version: 3 // major version: 45 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #5 // LookupswitchDemo // super_class: #10 // java/lang/Object // interfaces: 0, fields: 0, methods: 3, attributes: 1 //Constant pool: // #1 = Integer 200 // #2 = Utf8 LookupswitchDemo // #3 = Utf8 ()V // #4 = Utf8 main // #5 = Class #2 // LookupswitchDemo // #6 = NameAndType #23:#22 // println:(I)V // #7 = Integer 10 // #8 = Integer 100 // #9 = Utf8 java/lang/Object // #10 = Class #9 // java/lang/Object // #11 = Integer 1 // #12 = Integer 0 // #13 = Integer 12345 // #14 = Utf8 java/lang/System // #15 = Class #14 // java/lang/System // #16 = NameAndType #19:#32 // demo:(I)I // #17 = Methodref #5.#16 // LookupswitchDemo.demo:(I)I // #18 = Utf8 ([Ljava/lang/String;)V // #19 = Utf8 demo // #20 = NameAndType #25:#3 // "":()V // #21 = Class #35 // java/io/PrintStream // #22 = Utf8 (I)V // #23 = Utf8 println // #24 = Utf8 SourceFile // #25 = Utf8 // #26 = Methodref #21.#6 // java/io/PrintStream.println:(I)V // #27 = NameAndType #28:#36 // out:Ljava/io/PrintStream; // #28 = Utf8 out // #29 = Utf8 LookupSwitchDemo.pho // #30 = Methodref #10.#20 // java/lang/Object."":()V // #31 = Methodref #5.#20 // LookupswitchDemo."":()V // #32 = Utf8 (I)I // #33 = Fieldref #15.#27 // java/lang/System.out:Ljava/io/PrintStream; // #34 = Utf8 Code // #35 = Utf8 java/io/PrintStream // #36 = Utf8 Ljava/io/PrintStream; //{ // public LookupswitchDemo(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #30 // Method java/lang/Object."":()V // 4: return // // private int demo(int); // descriptor: (I)I // flags: (0x0002) ACC_PRIVATE // Code: // stack=3, locals=3, args_size=2 // 0: iload_1 // 1: lookupswitch { // 2 // 1: 28 // 10: 31 // default: 34 // } // 28: ldc #7 // int 10 // 30: ireturn // 31: ldc #8 // int 100 // 33: ireturn // 34: ldc #12 // int 0 // 36: ireturn // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=3, locals=3, args_size=1 // 0: new #5 // class LookupswitchDemo // 3: dup // 4: invokespecial #31 // Method "":()V // 7: astore_1 // 8: aload_1 // 9: ldc #11 // int 1 // 11: invokevirtual #17 // Method demo:(I)I // 14: jsr 54 // 17: aload_1 // 18: ldc #7 // int 10 // 20: invokevirtual #17 // Method demo:(I)I // 23: jsr 54 // 26: aload_1 // 27: ldc #8 // int 100 // 29: invokevirtual #17 // Method demo:(I)I // 32: jsr 54 // 35: aload_1 // 36: ldc #1 // int 200 // 38: invokevirtual #17 // Method demo:(I)I // 41: jsr 54 // 44: aload_1 // 45: ldc #13 // int 12345 // 47: invokevirtual #17 // Method demo:(I)I // 50: jsr 54 // 53: return // 54: astore_2 // 55: getstatic #33 // Field java/lang/System.out:Ljava/io/PrintStream; // 58: swap // 59: invokevirtual #26 // Method java/io/PrintStream.println:(I)V // 62: ret 2 //} //SourceFile: "LookupSwitchDemo.pho" #[test] fn test_deserialize_lookupswitchdemo() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x25, 0x03, 0x00, 0x00, 0x00, 0xc8, 0x01, 0x00, 0x10, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x44, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x07, 0x00, 0x02, 0x0c, 0x00, 0x17, 0x00, 0x16, 0x03, 0x00, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x00, 0x00, 0x64, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x07, 0x00, 0x09, 0x03, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x30, 0x39, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x07, 0x00, 0x0e, 0x0c, 0x00, 0x13, 0x00, 0x20, 0x0a, 0x00, 0x05, 0x00, 0x10, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x04, 0x64, 0x65, 0x6d, 0x6f, 0x0c, 0x00, 0x19, 0x00, 0x03, 0x07, 0x00, 0x23, 0x01, 0x00, 0x04, 0x28, 0x49, 0x29, 0x56, 0x01, 0x00, 0x07, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x6c, 0x6e, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x0a, 0x00, 0x15, 0x00, 0x06, 0x0c, 0x00, 0x1c, 0x00, 0x24, 0x01, 0x00, 0x03, 0x6f, 0x75, 0x74, 0x01, 0x00, 0x14, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x77, 0x69, 0x74, 0x63, 0x68, 0x44, 0x65, 0x6d, 0x6f, 0x2e, 0x70, 0x68, 0x6f, 0x0a, 0x00, 0x0a, 0x00, 0x14, 0x0a, 0x00, 0x05, 0x00, 0x14, 0x01, 0x00, 0x04, 0x28, 0x49, 0x29, 0x49, 0x09, 0x00, 0x0f, 0x00, 0x1b, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x01, 0x00, 0x15, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x00, 0x21, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x19, 0x00, 0x03, 0x00, 0x01, 0x00, 0x22, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x1e, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x13, 0x00, 0x20, 0x00, 0x01, 0x00, 0x22, 0x00, 0x00, 0x00, 0x31, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x25, 0x1b, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x1e, 0x12, 0x07, 0xac, 0x12, 0x08, 0xac, 0x12, 0x0c, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x04, 0x00, 0x12, 0x00, 0x01, 0x00, 0x22, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x40, 0xbb, 0x00, 0x05, 0x59, 0xb7, 0x00, 0x1f, 0x4c, 0x2b, 0x12, 0x0b, 0xb6, 0x00, 0x11, 0xa8, 0x00, 0x28, 0x2b, 0x12, 0x07, 0xb6, 0x00, 0x11, 0xa8, 0x00, 0x1f, 0x2b, 0x12, 0x08, 0xb6, 0x00, 0x11, 0xa8, 0x00, 0x16, 0x2b, 0x12, 0x01, 0xb6, 0x00, 0x11, 0xa8, 0x00, 0x0d, 0x2b, 0x12, 0x0d, 0xb6, 0x00, 0x11, 0xa8, 0x00, 0x04, 0xb1, 0x4d, 0xb2, 0x00, 0x21, 0x5f, 0xb6, 0x00, 0x1a, 0xa9, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x1d, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/oyi-lang/phoron_asm/doc/grammar/TableswitchDemo.class // Last modified 07-Mar-2023; size 558 bytes // SHA-256 checksum fe89e7d28f29984e66a5a2b34c945f70077e82a7cd4c83eff63e70d14486210c // Compiled from "TableswitchDemo.pho" //public class TableswitchDemo // minor version: 3 // major version: 45 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #8 // TableswitchDemo // super_class: #11 // java/lang/Object // interfaces: 0, fields: 0, methods: 3, attributes: 1 //Constant pool: // #1 = Integer 200 // #2 = Integer 19 // #3 = Utf8 ()V // #4 = Utf8 main // #5 = Integer 199 // #6 = NameAndType #28:#26 // println:(I)V // #7 = Integer 100 // #8 = Class #16 // TableswitchDemo // #9 = Utf8 java/lang/Object // #10 = Methodref #8.#19 // TableswitchDemo.demo:(I)I // #11 = Class #9 // java/lang/Object // #12 = Integer 2 // #13 = Integer 1 // #14 = Integer 0 // #15 = Integer 12345 // #16 = Utf8 TableswitchDemo // #17 = Utf8 java/lang/System // #18 = Class #17 // java/lang/System // #19 = NameAndType #23:#34 // demo:(I)I // #20 = Utf8 TableswitchDemo.pho // #21 = Methodref #8.#24 // TableswitchDemo."":()V // #22 = Utf8 ([Ljava/lang/String;)V // #23 = Utf8 demo // #24 = NameAndType #29:#3 // "":()V // #25 = Class #37 // java/io/PrintStream // #26 = Utf8 (I)V // #27 = Utf8 SourceFile // #28 = Utf8 println // #29 = Utf8 // #30 = Methodref #25.#6 // java/io/PrintStream.println:(I)V // #31 = NameAndType #32:#39 // out:Ljava/io/PrintStream; // #32 = Utf8 out // #33 = Methodref #11.#24 // java/lang/Object."":()V // #34 = Utf8 (I)I // #35 = Fieldref #18.#31 // java/lang/System.out:Ljava/io/PrintStream; // #36 = Utf8 Code // #37 = Utf8 java/io/PrintStream // #38 = Integer 1009 // #39 = Utf8 Ljava/io/PrintStream; //{ // public TableswitchDemo(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #33 // Method java/lang/Object."":()V // 4: return // // private int demo(int); // descriptor: (I)I // flags: (0x0002) ACC_PRIVATE // Code: // stack=3, locals=3, args_size=2 // 0: iload_1 // 1: tableswitch { // 0 to 2 // 0: 28 // 1: 31 // 2: 34 // default: 37 // } // 28: ldc #2 // int 19 // 30: ireturn // 31: ldc #5 // int 199 // 33: ireturn // 34: ldc #38 // int 1009 // 36: ireturn // 37: ldc #14 // int 0 // 39: ireturn // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=3, locals=3, args_size=1 // 0: new #8 // class TableswitchDemo // 3: dup // 4: invokespecial #21 // Method "":()V // 7: astore_1 // 8: aload_1 // 9: ldc #14 // int 0 // 11: invokevirtual #10 // Method demo:(I)I // 14: jsr 63 // 17: aload_1 // 18: ldc #13 // int 1 // 20: invokevirtual #10 // Method demo:(I)I // 23: jsr 63 // 26: aload_1 // 27: ldc #12 // int 2 // 29: invokevirtual #10 // Method demo:(I)I // 32: jsr 63 // 35: aload_1 // 36: ldc #7 // int 100 // 38: invokevirtual #10 // Method demo:(I)I // 41: jsr 63 // 44: aload_1 // 45: ldc #1 // int 200 // 47: invokevirtual #10 // Method demo:(I)I // 50: jsr 63 // 53: aload_1 // 54: ldc #15 // int 12345 // 56: invokevirtual #10 // Method demo:(I)I // 59: jsr 63 // 62: return // 63: astore_2 // 64: getstatic #35 // Field java/lang/System.out:Ljava/io/PrintStream; // 67: swap // 68: invokevirtual #30 // Method java/io/PrintStream.println:(I)V // 71: ret 2 //} //SourceFile: "TableswitchDemo.pho" #[test] fn test_deserialize_tablewswitchdemo() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x28, 0x03, 0x00, 0x00, 0x00, 0xc8, 0x03, 0x00, 0x00, 0x00, 0x13, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x03, 0x00, 0x00, 0x00, 0xc7, 0x0c, 0x00, 0x1c, 0x00, 0x1a, 0x03, 0x00, 0x00, 0x00, 0x64, 0x07, 0x00, 0x10, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x0a, 0x00, 0x08, 0x00, 0x13, 0x07, 0x00, 0x09, 0x03, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x30, 0x39, 0x01, 0x00, 0x0f, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x44, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x07, 0x00, 0x11, 0x0c, 0x00, 0x17, 0x00, 0x22, 0x01, 0x00, 0x13, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x44, 0x65, 0x6d, 0x6f, 0x2e, 0x70, 0x68, 0x6f, 0x0a, 0x00, 0x08, 0x00, 0x18, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x04, 0x64, 0x65, 0x6d, 0x6f, 0x0c, 0x00, 0x1d, 0x00, 0x03, 0x07, 0x00, 0x25, 0x01, 0x00, 0x04, 0x28, 0x49, 0x29, 0x56, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x07, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x6c, 0x6e, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x0a, 0x00, 0x19, 0x00, 0x06, 0x0c, 0x00, 0x20, 0x00, 0x27, 0x01, 0x00, 0x03, 0x6f, 0x75, 0x74, 0x0a, 0x00, 0x0b, 0x00, 0x18, 0x01, 0x00, 0x04, 0x28, 0x49, 0x29, 0x49, 0x09, 0x00, 0x12, 0x00, 0x1f, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x03, 0x00, 0x00, 0x03, 0xf1, 0x01, 0x00, 0x15, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x00, 0x21, 0x00, 0x08, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x1d, 0x00, 0x03, 0x00, 0x01, 0x00, 0x24, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x21, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x00, 0x22, 0x00, 0x01, 0x00, 0x24, 0x00, 0x00, 0x00, 0x34, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x28, 0x1b, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x21, 0x12, 0x02, 0xac, 0x12, 0x05, 0xac, 0x12, 0x26, 0xac, 0x12, 0x0e, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x04, 0x00, 0x16, 0x00, 0x01, 0x00, 0x24, 0x00, 0x00, 0x00, 0x55, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x49, 0xbb, 0x00, 0x08, 0x59, 0xb7, 0x00, 0x15, 0x4c, 0x2b, 0x12, 0x0e, 0xb6, 0x00, 0x0a, 0xa8, 0x00, 0x31, 0x2b, 0x12, 0x0d, 0xb6, 0x00, 0x0a, 0xa8, 0x00, 0x28, 0x2b, 0x12, 0x0c, 0xb6, 0x00, 0x0a, 0xa8, 0x00, 0x1f, 0x2b, 0x12, 0x07, 0xb6, 0x00, 0x0a, 0xa8, 0x00, 0x16, 0x2b, 0x12, 0x01, 0xb6, 0x00, 0x0a, 0xa8, 0x00, 0x0d, 0x2b, 0x12, 0x0f, 0xb6, 0x00, 0x0a, 0xa8, 0x00, 0x04, 0xb1, 0x4d, 0xb2, 0x00, 0x23, 0x5f, 0xb6, 0x00, 0x1e, 0xa9, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x14, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/playground/AllInOne.class // Last modified 07-Mar-2023; size 1773 bytes // SHA-256 checksum 954c2d6f8f7b2af66c964e914106bba3940120b59a0bdf8758959203f082ba37 // Compiled from "AllInOne.j" //public class AllInOne extends java.lang.Thread // minor version: 3 // major version: 45 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #50 // AllInOne // super_class: #54 // java/lang/Thread // interfaces: 0, fields: 4, methods: 12, attributes: 1 //Constant pool: // #1 = Methodref #50.#41 // AllInOne.subroutinesDemo:()V // #2 = Utf8 , world // #3 = Utf8 Ljava/lang/String; // #4 = String #76 // Hello, world // #5 = Methodref #67.#7 // java/io/PrintStream.println:(Ljava/lang/String;)V // #6 = Utf8 SourceFile // #7 = NameAndType #15:#30 // println:(Ljava/lang/String;)V // #8 = Utf8 // #9 = Utf8 java/lang/System // #10 = String #83 // No such file // #11 = Class #59 // java/lang/RuntimeException // #12 = Class #18 // java/lang/Exception // #13 = Utf8 Count // #14 = Integer 12345 // #15 = Utf8 println // #16 = NameAndType #81:#70 // finallyDemo:()V // #17 = Utf8 main // #18 = Utf8 java/lang/Exception // #19 = String #64 // Hello // #20 = Methodref #50.#77 // AllInOne.instanceofDemo:()V // #21 = Class #49 // java/lang/Object // #22 = Utf8 valueOf // #23 = Utf8 AllInOne // #24 = NameAndType #102:#70 // exceptionsDemo:()V // #25 = Utf8 (Ljava/lang/Object;)V // #26 = Fieldref #101.#46 // java/lang/System.out:Ljava/io/PrintStream; // #27 = Methodref #54.#91 // java/lang/Thread."":()V // #28 = Utf8 synchronizedMethoDemo // #29 = NameAndType #57:#70 // checkCastDemo:()V // #30 = Utf8 (Ljava/lang/String;)V // #31 = Utf8 java/io/FileInputStream // #32 = Utf8 PREFIX // #33 = String #74 // IO Exception occurred // #34 = Utf8 Exceptions // #35 = Utf8 Exception caught // #36 = String #96 // Done // #37 = Utf8 AllInOne.j // #38 = Utf8 tableswitchDemo // #39 = Methodref #93.#47 // java/io/FileInputStream."":(Ljava/lang/String;)V // #40 = Class #60 // java/io/IOException // #41 = NameAndType #75:#70 // subroutinesDemo:()V // #42 = String #35 // Exception caught // #43 = Utf8 z // #44 = Utf8 y // #45 = Utf8 x // #46 = NameAndType #97:#90 // out:Ljava/io/PrintStream; // #47 = NameAndType #8:#30 // "":(Ljava/lang/String;)V // #48 = Methodref #12.#91 // java/lang/Exception."":()V // #49 = Utf8 java/lang/Object // #50 = Class #23 // AllInOne // #51 = Float 1.2345f // #52 = Class #65 // java/io/FileNotFoundException // #53 = Methodref #50.#58 // AllInOne.tableswitchDemo:()I // #54 = Class #63 // java/lang/Thread // #55 = Utf8 Code // #56 = Utf8 myfile // #57 = Utf8 checkCastDemo // #58 = NameAndType #38:#79 // tableswitchDemo:()I // #59 = Utf8 java/lang/RuntimeException // #60 = Utf8 java/io/IOException // #61 = Methodref #50.#95 // AllInOne.lookupswitchDemo:()I // #62 = Utf8 FooBar // #63 = Utf8 java/lang/Thread // #64 = Utf8 Hello // #65 = Utf8 java/io/FileNotFoundException // #66 = Utf8 I // #67 = Class #80 // java/io/PrintStream // #68 = Utf8 lookupswitchDemo // #69 = Utf8 instanceofDemo // #70 = Utf8 ()V // #71 = Utf8 D // #72 = NameAndType #22:#103 // valueOf:(I)Ljava/lang/String; // #73 = Utf8 ([Ljava/lang/String;)V // #74 = Utf8 IO Exception occurred // #75 = Utf8 subroutinesDemo // #76 = Utf8 Hello, world // #77 = NameAndType #69:#70 // instanceofDemo:()V // #78 = String #62 // FooBar // #79 = Utf8 ()I // #80 = Utf8 java/io/PrintStream // #81 = Utf8 finallyDemo // #82 = Methodref #50.#29 // AllInOne.checkCastDemo:()V // #83 = Utf8 No such file // #84 = String #56 // myfile // #85 = Methodref #86.#72 // java/lang/String.valueOf:(I)Ljava/lang/String; // #86 = Class #94 // java/lang/String // #87 = Utf8 monitoDemo // #88 = Utf8 LocalVariableTable // #89 = Methodref #50.#91 // AllInOne."":()V // #90 = Utf8 Ljava/io/PrintStream; // #91 = NameAndType #8:#70 // "":()V // #92 = Utf8 varDemo // #93 = Class #31 // java/io/FileInputStream // #94 = Utf8 java/lang/String // #95 = NameAndType #68:#79 // lookupswitchDemo:()I // #96 = Utf8 Done // #97 = Utf8 out // #98 = String #2 // , world // #99 = Methodref #50.#24 // AllInOne.exceptionsDemo:()V // #100 = Methodref #50.#16 // AllInOne.finallyDemo:()V // #101 = Class #9 // java/lang/System // #102 = Utf8 exceptionsDemo // #103 = Utf8 (I)Ljava/lang/String; // #104 = Utf8 ConstantValue //{ // private int x; // descriptor: I // flags: (0x0002) ACC_PRIVATE // // private double y; // descriptor: D // flags: (0x0002) ACC_PRIVATE // ConstantValue: float 1.2345f // // public int z; // descriptor: I // flags: (0x0001) ACC_PUBLIC // ConstantValue: int 12345 // // public static final java.lang.String PREFIX; // descriptor: Ljava/lang/String; // flags: (0x0019) ACC_PUBLIC, ACC_STATIC, ACC_FINAL // ConstantValue: String FooBar // // public AllInOne(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #27 // Method java/lang/Thread."":()V // 4: return // // private static void exceptionsDemo(); // descriptor: ()V // flags: (0x000a) ACC_PRIVATE, ACC_STATIC // Code: // stack=3, locals=1, args_size=0 // 0: new #12 // class java/lang/Exception // 3: dup // 4: invokespecial #48 // Method java/lang/Exception."":()V // 7: athrow // 8: pop // 9: getstatic #26 // Field java/lang/System.out:Ljava/io/PrintStream; // 12: ldc #42 // String Exception caught // 14: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 17: return // Exception table: // from to target type // 0 8 8 Class java/lang/Exception // // private static void finallyDemo(); // descriptor: ()V // flags: (0x000a) ACC_PRIVATE, ACC_STATIC // Code: // stack=3, locals=4, args_size=0 // 0: new #93 // class java/io/FileInputStream // 3: dup // 4: ldc #84 // String myfile // 6: invokespecial #39 // Method java/io/FileInputStream."":(Ljava/lang/String;)V // 9: astore_1 // 10: goto 37 // 13: pop // 14: getstatic #26 // Field java/lang/System.out:Ljava/io/PrintStream; // 17: ldc #10 // String No such file // 19: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 22: goto 37 // 25: pop // 26: getstatic #26 // Field java/lang/System.out:Ljava/io/PrintStream; // 29: ldc #33 // String IO Exception occurred // 31: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 34: goto 37 // 37: jsr 47 // 40: return // 41: astore_2 // 42: jsr 47 // 45: aload_2 // 46: athrow // 47: astore_3 // 48: getstatic #26 // Field java/lang/System.out:Ljava/io/PrintStream; // 51: ldc #36 // String Done // 53: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 56: ret 3 // Exception table: // from to target type // 0 10 13 Class java/io/FileNotFoundException // 0 37 25 Class java/io/IOException // 0 37 41 any // // synchronized void synchronizedMethoDemo(); // descriptor: ()V // flags: (0x0020) ACC_SYNCHRONIZED // Code: // stack=1, locals=1, args_size=1 // 0: return // // private void monitoDemo(java.lang.Object); // descriptor: (Ljava/lang/Object;)V // flags: (0x0002) ACC_PRIVATE // Code: // stack=2, locals=2, args_size=2 // 0: aload_1 // 1: monitorenter // 2: aload_1 // 3: monitorexit // 4: return // // private void checkCastDemo(); // descriptor: ()V // flags: (0x0002) ACC_PRIVATE // Code: // stack=2, locals=2, args_size=1 // 0: aload_0 // 1: checkcast #21 // class java/lang/Object // 4: return // // private void instanceofDemo(); // descriptor: ()V // flags: (0x0002) ACC_PRIVATE // Code: // stack=2, locals=2, args_size=1 // 0: aload_0 // 1: instanceof #54 // class java/lang/Thread // 4: getstatic #26 // Field java/lang/System.out:Ljava/io/PrintStream; // 7: swap // 8: invokestatic #85 // Method java/lang/String.valueOf:(I)Ljava/lang/String; // 11: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 14: return // // private static void subroutinesDemo(); // descriptor: ()V // flags: (0x000a) ACC_PRIVATE, ACC_STATIC // Code: // stack=2, locals=2, args_size=0 // 0: ldc #19 // String Hello // 2: jsr 11 // 5: ldc #98 // String , world // 7: jsr 11 // 10: return // 11: astore_1 // 12: getstatic #26 // Field java/lang/System.out:Ljava/io/PrintStream; // 15: swap // 16: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 19: ret 1 // // private static int lookupswitchDemo(); // descriptor: ()I // flags: (0x000a) ACC_PRIVATE, ACC_STATIC // Code: // stack=2, locals=2, args_size=0 // 0: bipush 10 // 2: istore_1 // 3: iload_1 // 4: lookupswitch { // 3 // 1: 40 // 10: 42 // 100: 44 // default: 46 // } // 40: iconst_1 // 41: ireturn // 42: iconst_2 // 43: ireturn // 44: iconst_3 // 45: ireturn // 46: iconst_0 // 47: ireturn // // private static int tableswitchDemo(); // descriptor: ()I // flags: (0x000a) ACC_PRIVATE, ACC_STATIC // Code: // stack=2, locals=3, args_size=0 // 0: iconst_3 // 1: istore_1 // 2: iload_1 // 3: tableswitch { // 1 to 3 // 1: 28 // 2: 30 // 3: 32 // default: 34 // } // 28: iconst_1 // 29: ireturn // 30: iconst_2 // 31: ireturn // 32: iconst_3 // 33: ireturn // 34: iconst_0 // 35: ireturn // // private static void varDemo(); // descriptor: ()V // flags: (0x000a) ACC_PRIVATE, ACC_STATIC // Code: // stack=1, locals=1, args_size=0 // 0: bipush 10 // 2: istore_0 // 3: return // LocalVariableTable: // Start Length Slot Name Signature // 0 3 0 Count I // // public static void main(java.lang.String[]) throws java.lang.RuntimeException; // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=2, locals=3, args_size=1 // 0: getstatic #26 // Field java/lang/System.out:Ljava/io/PrintStream; // 3: ldc #4 // String Hello, world // 5: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 8: invokestatic #99 // Method exceptionsDemo:()V // 11: invokestatic #100 // Method finallyDemo:()V // 14: new #50 // class AllInOne // 17: dup // 18: invokespecial #89 // Method "":()V // 21: astore_1 // 22: aload_1 // 23: invokevirtual #20 // Method instanceofDemo:()V // 26: aload_1 // 27: invokevirtual #82 // Method checkCastDemo:()V // 30: invokestatic #1 // Method subroutinesDemo:()V // 33: invokestatic #61 // Method lookupswitchDemo:()I // 36: jsr 46 // 39: invokestatic #53 // Method tableswitchDemo:()I // 42: jsr 46 // 45: return // 46: astore_2 // 47: getstatic #26 // Field java/lang/System.out:Ljava/io/PrintStream; // 50: swap // 51: invokestatic #85 // Method java/lang/String.valueOf:(I)Ljava/lang/String; // 54: invokevirtual #5 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 57: ret 2 // Exceptions: // throws java.lang.RuntimeException //} //SourceFile: "AllInOne.j" #[test] fn test_deserialize_allinone() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x69, 0x0a, 0x00, 0x32, 0x00, 0x29, 0x01, 0x00, 0x07, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x01, 0x00, 0x12, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x08, 0x00, 0x4c, 0x0a, 0x00, 0x43, 0x00, 0x07, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x0c, 0x00, 0x0f, 0x00, 0x1e, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x08, 0x00, 0x53, 0x07, 0x00, 0x3b, 0x07, 0x00, 0x12, 0x01, 0x00, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x03, 0x00, 0x00, 0x30, 0x39, 0x01, 0x00, 0x07, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x6c, 0x6e, 0x0c, 0x00, 0x51, 0x00, 0x46, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x08, 0x00, 0x40, 0x0a, 0x00, 0x32, 0x00, 0x4d, 0x07, 0x00, 0x31, 0x01, 0x00, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x4f, 0x66, 0x01, 0x00, 0x08, 0x41, 0x6c, 0x6c, 0x49, 0x6e, 0x4f, 0x6e, 0x65, 0x0c, 0x00, 0x66, 0x00, 0x46, 0x01, 0x00, 0x15, 0x28, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x3b, 0x29, 0x56, 0x09, 0x00, 0x65, 0x00, 0x2e, 0x0a, 0x00, 0x36, 0x00, 0x5b, 0x01, 0x00, 0x15, 0x73, 0x79, 0x6e, 0x63, 0x68, 0x72, 0x6f, 0x6e, 0x69, 0x7a, 0x65, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x44, 0x65, 0x6d, 0x6f, 0x0c, 0x00, 0x39, 0x00, 0x46, 0x01, 0x00, 0x15, 0x28, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x17, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x46, 0x69, 0x6c, 0x65, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x01, 0x00, 0x06, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x08, 0x00, 0x4a, 0x01, 0x00, 0x0a, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x01, 0x00, 0x10, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x63, 0x61, 0x75, 0x67, 0x68, 0x74, 0x08, 0x00, 0x60, 0x01, 0x00, 0x0a, 0x41, 0x6c, 0x6c, 0x49, 0x6e, 0x4f, 0x6e, 0x65, 0x2e, 0x6a, 0x01, 0x00, 0x0f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x44, 0x65, 0x6d, 0x6f, 0x0a, 0x00, 0x5d, 0x00, 0x2f, 0x07, 0x00, 0x3c, 0x0c, 0x00, 0x4b, 0x00, 0x46, 0x08, 0x00, 0x23, 0x01, 0x00, 0x01, 0x7a, 0x01, 0x00, 0x01, 0x79, 0x01, 0x00, 0x01, 0x78, 0x0c, 0x00, 0x61, 0x00, 0x5a, 0x0c, 0x00, 0x08, 0x00, 0x1e, 0x0a, 0x00, 0x0c, 0x00, 0x5b, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x07, 0x00, 0x17, 0x04, 0x3f, 0x9e, 0x04, 0x19, 0x07, 0x00, 0x41, 0x0a, 0x00, 0x32, 0x00, 0x3a, 0x07, 0x00, 0x3f, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, 0x06, 0x6d, 0x79, 0x66, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x0d, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x43, 0x61, 0x73, 0x74, 0x44, 0x65, 0x6d, 0x6f, 0x0c, 0x00, 0x26, 0x00, 0x4f, 0x01, 0x00, 0x1a, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x49, 0x4f, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x00, 0x32, 0x00, 0x5f, 0x01, 0x00, 0x06, 0x46, 0x6f, 0x6f, 0x42, 0x61, 0x72, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x01, 0x00, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x01, 0x00, 0x1d, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x6f, 0x74, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x01, 0x00, 0x01, 0x49, 0x07, 0x00, 0x50, 0x01, 0x00, 0x10, 0x6c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x44, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x6f, 0x66, 0x44, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01, 0x00, 0x01, 0x44, 0x0c, 0x00, 0x16, 0x00, 0x67, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x15, 0x49, 0x4f, 0x20, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x63, 0x63, 0x75, 0x72, 0x72, 0x65, 0x64, 0x01, 0x00, 0x0f, 0x73, 0x75, 0x62, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x65, 0x73, 0x44, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x0c, 0x00, 0x45, 0x00, 0x46, 0x08, 0x00, 0x3e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x49, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x01, 0x00, 0x0b, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x6c, 0x79, 0x44, 0x65, 0x6d, 0x6f, 0x0a, 0x00, 0x32, 0x00, 0x1d, 0x01, 0x00, 0x0c, 0x4e, 0x6f, 0x20, 0x73, 0x75, 0x63, 0x68, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x08, 0x00, 0x38, 0x0a, 0x00, 0x56, 0x00, 0x48, 0x07, 0x00, 0x5e, 0x01, 0x00, 0x0a, 0x6d, 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x44, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x12, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x0a, 0x00, 0x32, 0x00, 0x5b, 0x01, 0x00, 0x15, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x0c, 0x00, 0x08, 0x00, 0x46, 0x01, 0x00, 0x07, 0x76, 0x61, 0x72, 0x44, 0x65, 0x6d, 0x6f, 0x07, 0x00, 0x1f, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0c, 0x00, 0x44, 0x00, 0x4f, 0x01, 0x00, 0x04, 0x44, 0x6f, 0x6e, 0x65, 0x01, 0x00, 0x03, 0x6f, 0x75, 0x74, 0x08, 0x00, 0x02, 0x0a, 0x00, 0x32, 0x00, 0x18, 0x0a, 0x00, 0x32, 0x00, 0x10, 0x07, 0x00, 0x09, 0x01, 0x00, 0x0e, 0x65, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x44, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x15, 0x28, 0x49, 0x29, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x01, 0x00, 0x0d, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x00, 0x21, 0x00, 0x32, 0x00, 0x36, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x2d, 0x00, 0x42, 0x00, 0x00, 0x00, 0x02, 0x00, 0x2c, 0x00, 0x47, 0x00, 0x01, 0x00, 0x68, 0x00, 0x00, 0x00, 0x02, 0x00, 0x33, 0x00, 0x01, 0x00, 0x2b, 0x00, 0x42, 0x00, 0x01, 0x00, 0x68, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x19, 0x00, 0x20, 0x00, 0x03, 0x00, 0x01, 0x00, 0x68, 0x00, 0x00, 0x00, 0x02, 0x00, 0x4e, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x08, 0x00, 0x46, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x1b, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x66, 0x00, 0x46, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x26, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x12, 0xbb, 0x00, 0x0c, 0x59, 0xb7, 0x00, 0x30, 0xbf, 0x57, 0xb2, 0x00, 0x1a, 0x12, 0x2a, 0xb6, 0x00, 0x05, 0xb1, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x51, 0x00, 0x46, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3a, 0xbb, 0x00, 0x5d, 0x59, 0x12, 0x54, 0xb7, 0x00, 0x27, 0x4c, 0xa7, 0x00, 0x1b, 0x57, 0xb2, 0x00, 0x1a, 0x12, 0x0a, 0xb6, 0x00, 0x05, 0xa7, 0x00, 0x0f, 0x57, 0xb2, 0x00, 0x1a, 0x12, 0x21, 0xb6, 0x00, 0x05, 0xa7, 0x00, 0x03, 0xa8, 0x00, 0x0a, 0xb1, 0x4d, 0xa8, 0x00, 0x05, 0x2c, 0xbf, 0x4e, 0xb2, 0x00, 0x1a, 0x12, 0x24, 0xb6, 0x00, 0x05, 0xa9, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x34, 0x00, 0x00, 0x00, 0x25, 0x00, 0x19, 0x00, 0x28, 0x00, 0x00, 0x00, 0x25, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x1c, 0x00, 0x46, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x57, 0x00, 0x19, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x2b, 0xc2, 0x2b, 0xc3, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x39, 0x00, 0x46, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xc0, 0x00, 0x15, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x45, 0x00, 0x46, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x2a, 0xc1, 0x00, 0x36, 0xb2, 0x00, 0x1a, 0x5f, 0xb8, 0x00, 0x55, 0xb6, 0x00, 0x05, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x4b, 0x00, 0x46, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x21, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x12, 0x13, 0xa8, 0x00, 0x09, 0x12, 0x62, 0xa8, 0x00, 0x04, 0xb1, 0x4c, 0xb2, 0x00, 0x1a, 0x5f, 0xb6, 0x00, 0x05, 0xa9, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x44, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x30, 0x10, 0x0a, 0x3c, 0x1b, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x28, 0x04, 0xac, 0x05, 0xac, 0x06, 0xac, 0x03, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x26, 0x00, 0x4f, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x30, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x24, 0x06, 0x3c, 0x1b, 0xaa, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x1d, 0x04, 0xac, 0x05, 0xac, 0x06, 0xac, 0x03, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x5c, 0x00, 0x46, 0x00, 0x01, 0x00, 0x37, 0x00, 0x00, 0x00, 0x22, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x10, 0x0a, 0x3b, 0xb1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x58, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x42, 0x00, 0x00, 0x00, 0x09, 0x00, 0x11, 0x00, 0x49, 0x00, 0x02, 0x00, 0x37, 0x00, 0x00, 0x00, 0x47, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3b, 0xb2, 0x00, 0x1a, 0x12, 0x04, 0xb6, 0x00, 0x05, 0xb8, 0x00, 0x63, 0xb8, 0x00, 0x64, 0xbb, 0x00, 0x32, 0x59, 0xb7, 0x00, 0x59, 0x4c, 0x2b, 0xb6, 0x00, 0x14, 0x2b, 0xb6, 0x00, 0x52, 0xb8, 0x00, 0x01, 0xb8, 0x00, 0x3d, 0xa8, 0x00, 0x0a, 0xb8, 0x00, 0x35, 0xa8, 0x00, 0x04, 0xb1, 0x4d, 0xb2, 0x00, 0x1a, 0x5f, 0xb8, 0x00, 0x55, 0xb6, 0x00, 0x05, 0xa9, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x25, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/playground/VarDemo.class // Last modified 07-Mar-2023; size 404 bytes // SHA-256 checksum 5232a0ea245e1bfa64a8b084d8ff380c7c5bf28a14205c2a9755acdc573765be // Compiled from "VarDemo.pho" //public class VarDemo // minor version: 3 // major version: 45 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #20 // VarDemo // super_class: #5 // java/lang/Object // interfaces: 0, fields: 0, methods: 3, attributes: 1 //Constant pool: // #1 = Methodref #20.#7 // VarDemo."":()V // #2 = Utf8 ([Ljava/lang/String;)V // #3 = Utf8 java/lang/Object // #4 = Utf8 // #5 = Class #3 // java/lang/Object // #6 = Utf8 Bar // #7 = NameAndType #4:#9 // "":()V // #8 = Utf8 Foo // #9 = Utf8 ()V // #10 = NameAndType #16:#9 // demo:()V // #11 = Utf8 Code // #12 = Utf8 main // #13 = Utf8 VarDemo.pho // #14 = Utf8 SourceFile // #15 = Utf8 I // #16 = Utf8 demo // #17 = Utf8 D // #18 = Methodref #5.#7 // java/lang/Object."":()V // #19 = Utf8 Ljava/lang/String; // #20 = Class #22 // VarDemo // #21 = Methodref #20.#10 // VarDemo.demo:()V // #22 = Utf8 VarDemo // #23 = Utf8 LocalVariableTable // #24 = Utf8 Baz //{ // public VarDemo(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #18 // Method java/lang/Object."":()V // 4: return // // private void demo(); // descriptor: ()V // flags: (0x0002) ACC_PRIVATE // Code: // stack=3, locals=8, args_size=1 // 0: bipush 10 // 2: istore_1 // 3: bipush 20 // 5: istore_2 // 6: bipush 30 // 8: istore_3 // 9: bipush 40 // 11: istore 4 // 13: bipush 50 // 15: istore 5 // 17: bipush 60 // 19: istore 7 // 21: return // LocalVariableTable: // Start Length Slot Name Signature // 0 3 0 Foo I // 6 3 1 Bar D // 13 4 2 Baz Ljava/lang/String; // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=2, locals=2, args_size=1 // 0: new #20 // class VarDemo // 3: dup // 4: invokespecial #1 // Method "":()V // 7: astore_1 // 8: aload_1 // 9: invokevirtual #21 // Method demo:()V // 12: return //} //SourceFile: "VarDemo.pho" #[test] fn test_deserialize_vardemo() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x19, 0x0a, 0x00, 0x14, 0x00, 0x07, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x07, 0x00, 0x03, 0x01, 0x00, 0x03, 0x42, 0x61, 0x72, 0x0c, 0x00, 0x04, 0x00, 0x09, 0x01, 0x00, 0x03, 0x46, 0x6f, 0x6f, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x0c, 0x00, 0x10, 0x00, 0x09, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x01, 0x00, 0x0b, 0x56, 0x61, 0x72, 0x44, 0x65, 0x6d, 0x6f, 0x2e, 0x70, 0x68, 0x6f, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x01, 0x49, 0x01, 0x00, 0x04, 0x64, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x01, 0x44, 0x0a, 0x00, 0x05, 0x00, 0x07, 0x01, 0x00, 0x12, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x07, 0x00, 0x16, 0x0a, 0x00, 0x14, 0x00, 0x0a, 0x01, 0x00, 0x07, 0x56, 0x61, 0x72, 0x44, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x12, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x56, 0x61, 0x72, 0x69, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x01, 0x00, 0x03, 0x42, 0x61, 0x7a, 0x00, 0x21, 0x00, 0x14, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x09, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x12, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x09, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x48, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x16, 0x10, 0x0a, 0x3c, 0x10, 0x14, 0x3d, 0x10, 0x1e, 0x3e, 0x10, 0x28, 0x36, 0x04, 0x10, 0x32, 0x36, 0x05, 0x10, 0x3c, 0x36, 0x07, 0xb1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x17, 0x00, 0x00, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x08, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x03, 0x00, 0x06, 0x00, 0x11, 0x00, 0x01, 0x00, 0x0d, 0x00, 0x04, 0x00, 0x18, 0x00, 0x13, 0x00, 0x02, 0x00, 0x09, 0x00, 0x0c, 0x00, 0x02, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x19, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0d, 0xbb, 0x00, 0x14, 0x59, 0xb7, 0x00, 0x01, 0x4c, 0x2b, 0xb6, 0x00, 0x15, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0d, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/playground/ThrowsDemo.class // Last modified 07-Mar-2023; size 392 bytes // SHA-256 checksum 8bdbce588fd8368b70d6578640c7314167ee8d11aca2e7331df3372f1f558b39 // Compiled from "ThrowsDemo.pho" //public class ThrowsDemo // minor version: 3 // major version: 45 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #8 // ThrowsDemo // super_class: #5 // java/lang/Object // interfaces: 0, fields: 0, methods: 3, attributes: 1 //Constant pool: // #1 = Utf8 ([Ljava/lang/String;)V // #2 = Utf8 java/lang/Throwable // #3 = Utf8 java/lang/Object // #4 = Utf8 // #5 = Class #3 // java/lang/Object // #6 = NameAndType #4:#9 // "":()V // #7 = Utf8 Exceptions // #8 = Class #24 // ThrowsDemo // #9 = Utf8 ()V // #10 = NameAndType #18:#9 // demo:()V // #11 = Utf8 Code // #12 = Utf8 main // #13 = Utf8 java/io/IOException // #14 = Methodref #8.#6 // ThrowsDemo."":()V // #15 = Class #13 // java/io/IOException // #16 = Utf8 SourceFile // #17 = Class #20 // java/lang/RuntimeException // #18 = Utf8 demo // #19 = Methodref #8.#10 // ThrowsDemo.demo:()V // #20 = Utf8 java/lang/RuntimeException // #21 = Methodref #5.#6 // java/lang/Object."":()V // #22 = Utf8 ThrowsDemo.pho // #23 = Class #2 // java/lang/Throwable // #24 = Utf8 ThrowsDemo //{ // public ThrowsDemo(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #21 // Method java/lang/Object."":()V // 4: return // // private void demo() throws java.lang.RuntimeException, java.io.IOException, java.lang.Throwable; // descriptor: ()V // flags: (0x0002) ACC_PRIVATE // Code: // stack=1, locals=1, args_size=1 // 0: return // Exceptions: // throws java.lang.RuntimeException, java.io.IOException, java.lang.Throwable // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=2, locals=2, args_size=1 // 0: new #8 // class ThrowsDemo // 3: dup // 4: invokespecial #14 // Method "":()V // 7: astore_1 // 8: aload_1 // 9: invokevirtual #19 // Method demo:()V // 12: return //} //SourceFile: "ThrowsDemo.pho" #[test] fn test_deserialize_throwsdemo() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x19, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x54, 0x68, 0x72, 0x6f, 0x77, 0x61, 0x62, 0x6c, 0x65, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x07, 0x00, 0x03, 0x0c, 0x00, 0x04, 0x00, 0x09, 0x01, 0x00, 0x0a, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x07, 0x00, 0x18, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x0c, 0x00, 0x12, 0x00, 0x09, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x49, 0x4f, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x00, 0x08, 0x00, 0x06, 0x07, 0x00, 0x0d, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x07, 0x00, 0x14, 0x01, 0x00, 0x04, 0x64, 0x65, 0x6d, 0x6f, 0x0a, 0x00, 0x08, 0x00, 0x0a, 0x01, 0x00, 0x1a, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x00, 0x05, 0x00, 0x06, 0x01, 0x00, 0x0e, 0x54, 0x68, 0x72, 0x6f, 0x77, 0x73, 0x44, 0x65, 0x6d, 0x6f, 0x2e, 0x70, 0x68, 0x6f, 0x07, 0x00, 0x02, 0x01, 0x00, 0x0a, 0x54, 0x68, 0x72, 0x6f, 0x77, 0x73, 0x44, 0x65, 0x6d, 0x6f, 0x00, 0x21, 0x00, 0x08, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x09, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x15, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x12, 0x00, 0x09, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x03, 0x00, 0x11, 0x00, 0x0f, 0x00, 0x17, 0x00, 0x09, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x19, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0d, 0xbb, 0x00, 0x08, 0x59, 0xb7, 0x00, 0x0e, 0x4c, 0x2b, 0xb6, 0x00, 0x13, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x16, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/oyi-lang/phoron_asm/doc/grammar/LineNumberDemo.class // Last modified 08-Mar-2023; size 515 bytes // SHA-256 checksum 5191f45157470d38c1f72af4f2117a4045759921f77e5a30e0e70d76d13b74cd // Compiled from "LineNumberDemo.pho" //public class LineNumberDemo // minor version: 3 // major version: 45 // flags: (0x0021) ACC_PUBLIC, ACC_SUPER // this_class: #3 // LineNumberDemo // super_class: #6 // java/lang/Object // interfaces: 0, fields: 0, methods: 2, attributes: 1 //Constant pool: // #1 = NameAndType #28:#32 // out:Ljava/io/PrintStream; // #2 = Utf8 ([Ljava/lang/String;)V // #3 = Class #14 // LineNumberDemo // #4 = Utf8 java/lang/Object // #5 = Utf8 // #6 = Class #4 // java/lang/Object // #7 = NameAndType #5:#10 // "":()V // #8 = Class #20 // java/io/PrintStream // #9 = Class #21 // java/lang/String // #10 = Utf8 ()V // #11 = Class #26 // java/lang/System // #12 = Utf8 Code // #13 = Utf8 main // #14 = Utf8 LineNumberDemo // #15 = Fieldref #11.#1 // java/lang/System.out:Ljava/io/PrintStream; // #16 = Utf8 valueOf // #17 = Methodref #9.#30 // java/lang/String.valueOf:(I)Ljava/lang/String; // #18 = Utf8 SourceFile // #19 = NameAndType #22:#31 // println:(Ljava/lang/String;)V // #20 = Utf8 java/io/PrintStream // #21 = Utf8 java/lang/String // #22 = Utf8 println // #23 = Utf8 LineNumberDemo.pho // #24 = Methodref #6.#7 // java/lang/Object."":()V // #25 = Utf8 LineNumberTable // #26 = Utf8 java/lang/System // #27 = Methodref #8.#19 // java/io/PrintStream.println:(Ljava/lang/String;)V // #28 = Utf8 out // #29 = Utf8 (I)Ljava/lang/String; // #30 = NameAndType #16:#29 // valueOf:(I)Ljava/lang/String; // #31 = Utf8 (Ljava/lang/String;)V // #32 = Utf8 Ljava/io/PrintStream; //{ // public LineNumberDemo(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #24 // Method java/lang/Object."":()V // 4: return // LineNumberTable: // line 1: 0 // line 2: 1 // line 1: 4 // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=3, locals=4, args_size=1 // 0: getstatic #15 // Field java/lang/System.out:Ljava/io/PrintStream; // 3: astore_1 // 4: bipush 10 // 6: istore_2 // 7: bipush 10 // 9: iload_2 // 10: isub // 11: invokestatic #17 // Method java/lang/String.valueOf:(I)Ljava/lang/String; // 14: astore_3 // 15: aload_1 // 16: aload_3 // 17: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/String;)V // 20: iinc_w 2, -1 // 26: iload_2 // 27: ifne 7 // 30: return // LineNumberTable: // line 1: 0 // line 2: 3 // line 3: 4 //} //SourceFile: "LineNumberDemo.pho" #[test] fn test_deserialize_linenumberdemo() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x21, 0x0c, 0x00, 0x1c, 0x00, 0x20, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x07, 0x00, 0x0e, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x07, 0x00, 0x04, 0x0c, 0x00, 0x05, 0x00, 0x0a, 0x07, 0x00, 0x14, 0x07, 0x00, 0x15, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x07, 0x00, 0x1a, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x01, 0x00, 0x0e, 0x4c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x44, 0x65, 0x6d, 0x6f, 0x09, 0x00, 0x0b, 0x00, 0x01, 0x01, 0x00, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x4f, 0x66, 0x0a, 0x00, 0x09, 0x00, 0x1e, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x0c, 0x00, 0x16, 0x00, 0x1f, 0x01, 0x00, 0x13, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x01, 0x00, 0x07, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x6c, 0x6e, 0x01, 0x00, 0x12, 0x4c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x44, 0x65, 0x6d, 0x6f, 0x2e, 0x70, 0x68, 0x6f, 0x0a, 0x00, 0x06, 0x00, 0x07, 0x01, 0x00, 0x0f, 0x4c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x0a, 0x00, 0x08, 0x00, 0x13, 0x01, 0x00, 0x03, 0x6f, 0x75, 0x74, 0x01, 0x00, 0x15, 0x28, 0x49, 0x29, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x0c, 0x00, 0x10, 0x00, 0x1d, 0x01, 0x00, 0x15, 0x28, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x15, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x3b, 0x00, 0x21, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x25, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x18, 0xb1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x19, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x01, 0x00, 0x09, 0x00, 0x0d, 0x00, 0x02, 0x00, 0x01, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1f, 0xb2, 0x00, 0x0f, 0x4c, 0x10, 0x0a, 0x3d, 0x10, 0x0a, 0x1c, 0x64, 0xb8, 0x00, 0x11, 0x4e, 0x2b, 0x2d, 0xb6, 0x00, 0x1b, 0xc4, 0x84, 0x00, 0x02, 0xff, 0xff, 0x1c, 0x9a, 0xff, 0xec, 0xb1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x19, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x02, 0x00, 0x04, 0x00, 0x03, 0x00, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/oyi-lang/phoron_asm/doc/grammar/InterfaceDemo.class // Last modified 08-Mar-2023; size 245 bytes // SHA-256 checksum c5f5d69d45c7d93dd6f00409b1f19521c6b93023b0c1583ff22b7f6cf27a5237 // Compiled from "InterfaceDemo.pho" //public interface InterfaceDemo // minor version: 3 // major version: 45 // flags: (0x0221) ACC_PUBLIC, ACC_SUPER, ACC_INTERFACE // this_class: #14 // InterfaceDemo // super_class: #15 // java/lang/Object // interfaces: 0, fields: 0, methods: 3, attributes: 1 //Constant pool: // #1 = Utf8 java/lang/Object // #2 = Utf8 Exceptions // #3 = Utf8 InterfaceDemo.pho // #4 = Utf8 SourceFile // #5 = Utf8 (DJZ)Ljava/lang/String; // #6 = Utf8 baz // #7 = Utf8 InterfaceDemo // #8 = Utf8 bar // #9 = Utf8 java/lang/RuntimeException // #10 = Utf8 ()V // #11 = Utf8 foo // #12 = Class #9 // java/lang/RuntimeException // #13 = Utf8 (IIIF)V // #14 = Class #7 // InterfaceDemo // #15 = Class #1 // java/lang/Object //{ // public abstract void foo() throws java.lang.RuntimeException; // descriptor: ()V // flags: (0x0401) ACC_PUBLIC, ACC_ABSTRACT // Exceptions: // throws java.lang.RuntimeException // // public abstract void bar(int, int, int, float); // descriptor: (IIIF)V // flags: (0x0401) ACC_PUBLIC, ACC_ABSTRACT // // public abstract java.lang.String baz(double, long, boolean); // descriptor: (DJZ)Ljava/lang/String; // flags: (0x0401) ACC_PUBLIC, ACC_ABSTRACT //} //SourceFile: "InterfaceDemo.pho" #[test] fn test_deserialize_interface_demo() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x10, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x0a, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x01, 0x00, 0x11, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x44, 0x65, 0x6d, 0x6f, 0x2e, 0x70, 0x68, 0x6f, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x17, 0x28, 0x44, 0x4a, 0x5a, 0x29, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x01, 0x00, 0x03, 0x62, 0x61, 0x7a, 0x01, 0x00, 0x0d, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x44, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x03, 0x62, 0x61, 0x72, 0x01, 0x00, 0x1a, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01, 0x00, 0x03, 0x66, 0x6f, 0x6f, 0x07, 0x00, 0x09, 0x01, 0x00, 0x07, 0x28, 0x49, 0x49, 0x49, 0x46, 0x29, 0x56, 0x07, 0x00, 0x07, 0x07, 0x00, 0x01, 0x02, 0x21, 0x00, 0x0e, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x01, 0x00, 0x0b, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x0c, 0x04, 0x01, 0x00, 0x08, 0x00, 0x0d, 0x00, 0x00, 0x04, 0x01, 0x00, 0x06, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) } //Classfile /Users/z0ltan/dev/oyi-lang/phoron_asm/doc/grammar/ImplementsDemo.class // Last modified 08-Mar-2023; size 284 bytes // SHA-256 checksum dbe95ed6f6317377cbf0159a3c0c46cb12164888157a0179b7865f4d007cec20 // Compiled from "ImplementsDemo.pho" //class ImplementsDemo implements java.lang.Runnable,java.io.Serializable // minor version: 3 // major version: 45 // flags: (0x0020) ACC_SUPER // this_class: #12 // ImplementsDemo // super_class: #17 // java/lang/Object // interfaces: 2, fields: 0, methods: 2, attributes: 1 //Constant pool: // #1 = Methodref #17.#10 // java/lang/Object."":()V // #2 = Utf8 java/lang/Object // #3 = Utf8 ImplementsDemo // #4 = Utf8 SourceFile // #5 = Utf8 // #6 = Utf8 java/lang/Runnable // #7 = Utf8 java/io/Serializable // #8 = Utf8 main // #9 = Class #7 // java/io/Serializable // #10 = NameAndType #5:#14 // "":()V // #11 = Utf8 Code // #12 = Class #3 // ImplementsDemo // #13 = Utf8 ([Ljava/lang/String;)V // #14 = Utf8 ()V // #15 = Utf8 ImplementsDemo.pho // #16 = Class #6 // java/lang/Runnable // #17 = Class #2 // java/lang/Object //{ // public ImplementsDemo(); // descriptor: ()V // flags: (0x0001) ACC_PUBLIC // Code: // stack=1, locals=1, args_size=1 // 0: aload_0 // 1: invokespecial #1 // Method java/lang/Object."":()V // 4: return // // public static void main(java.lang.String[]); // descriptor: ([Ljava/lang/String;)V // flags: (0x0009) ACC_PUBLIC, ACC_STATIC // Code: // stack=1, locals=1, args_size=1 // 0: return //} //SourceFile: "ImplementsDemo.pho" #[test] fn test_deserialize_implements_demo() -> DeserializerResult { let bytes = [ 0xca, 0xfe, 0xba, 0xbe, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x12, 0x0a, 0x00, 0x11, 0x00, 0x0a, 0x01, 0x00, 0x10, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x01, 0x00, 0x0e, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x44, 0x65, 0x6d, 0x6f, 0x01, 0x00, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x01, 0x00, 0x06, 0x3c, 0x69, 0x6e, 0x69, 0x74, 0x3e, 0x01, 0x00, 0x12, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x52, 0x75, 0x6e, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x01, 0x00, 0x14, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x69, 0x6f, 0x2f, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x62, 0x6c, 0x65, 0x01, 0x00, 0x04, 0x6d, 0x61, 0x69, 0x6e, 0x07, 0x00, 0x07, 0x0c, 0x00, 0x05, 0x00, 0x0e, 0x01, 0x00, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x07, 0x00, 0x03, 0x01, 0x00, 0x16, 0x28, 0x5b, 0x4c, 0x6a, 0x61, 0x76, 0x61, 0x2f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x3b, 0x29, 0x56, 0x01, 0x00, 0x03, 0x28, 0x29, 0x56, 0x01, 0x00, 0x12, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x44, 0x65, 0x6d, 0x6f, 0x2e, 0x70, 0x68, 0x6f, 0x07, 0x00, 0x06, 0x07, 0x00, 0x02, 0x00, 0x20, 0x00, 0x0c, 0x00, 0x11, 0x00, 0x02, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x2a, 0xb7, 0x00, 0x01, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x08, 0x00, 0x0d, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0f, ]; let mut deserializer = Deserializer::new(Reader::new(Cursor::new(bytes))); let _classfile = deserializer.deserialize()?; Ok(()) }