-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_deserializer.rs
2270 lines (2227 loc) · 123 KB
/
test_deserializer.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
use phoron_core::{deserializer::Deserializer, rw::reader::Reader};
use std::{error::Error, io::Cursor};
pub type DeserializerResult = Result<(), Box<dyn Error + Send + Sync + 'static>>;
// 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."<init>":()V
// #2 = Class #4 // java/lang/Object
// #3 = NameAndType #5:#6 // "<init>":()V
// #4 = Utf8 java/lang/Object
// #5 = Utf8 <init>
// #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."<init>":()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."<init>":()V
// #2 = Class #4 // java/lang/Object
// #3 = NameAndType #5:#6 // "<init>":()V
// #4 = Utf8 java/lang/Object
// #5 = Utf8 <init>
// #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."<init>":(ILjava/lang/String;DZLjava/lang/Integer;)V
// #39 = NameAndType #5:#40 // "<init>":(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."<init>":()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 "<init>":(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."<init>":()V
// #2 = Class #4 // java/lang/Object
// #3 = NameAndType #5:#6 // "<init>":()V
// #4 = Utf8 java/lang/Object
// #5 = Utf8 <init>
// #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."<init>":(Ljava/io/InputStream;)V
// #16 = NameAndType #5:#17 // "<init>":(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."<init>":(Ljava/lang/String;)V
// #49 = NameAndType #5:#31 // "<init>":(Ljava/lang/String;)V
// #50 = Methodref #44.#51 // Parser."<init>":(LLexer;)V
// #51 = NameAndType #5:#52 // "<init>":(LLexer;)V
// #52 = Utf8 (LLexer;)V
// #53 = Class #54 // Evaluator
// #54 = Utf8 Evaluator
// #55 = Methodref #53.#3 // Evaluator."<init>":()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."<init>":()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."<init>":(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."<init>":(Ljava/lang/String;)V
// 45: invokespecial #50 // Method Parser."<init>":(LLexer;)V
// 48: astore_3
// 49: new #53 // class Evaluator
// 52: dup
// 53: invokespecial #55 // Method Evaluator."<init>":()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 <init>
// #5 = Class #3 // java/lang/Object
// #6 = NameAndType #4:#8 // "<init>":()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."<init>":()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."<init>":()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 <init>
// #4 = NameAndType #3:#9 // "<init>":()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."<init>":()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."<init>":()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 <init>
// #5 = Class #3 // java/lang/Object
// #6 = NameAndType #4:#8 // "<init>":()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."<init>":()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."<init>":()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."<init>":()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."<init>":()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 // "<init>":()V
// #21 = Class #35 // java/io/PrintStream
// #22 = Utf8 (I)V
// #23 = Utf8 println
// #24 = Utf8 SourceFile
// #25 = Utf8 <init>
// #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."<init>":()V
// #31 = Methodref #5.#20 // LookupswitchDemo."<init>":()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;