File: print_jvm_class.e

package info (click to toggle)
smarteiffel 1.1-11
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 12,288 kB
  • ctags: 40,785
  • sloc: ansic: 35,791; lisp: 4,036; sh: 1,783; java: 895; ruby: 613; python: 209; makefile: 115; csh: 78; cpp: 50
file content (1824 lines) | stat: -rw-r--r-- 63,618 bytes parent folder | download | duplicates (2)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries
--
-- SmartEiffel is  free software;  you can redistribute it and/or  modify it
-- under  the terms of the  GNU General Public License, as published by  the
-- Free Software Foundation; either version 2, or (at your option) any later
-- version.
-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT 
-- ANY WARRANTY;  without  even the implied warranty  of MERCHANTABILITY  or
-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-- more details.  You should have received a copy of  the GNU General Public
-- License along with SmartEiffel;  see the file COPYING.  If not,  write to
-- the Free Software Foundation,  Inc., 59 Temple Place - Suite 330,  Boston, 
-- MA 02111-1307, USA.
--
-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.
--			   - University of Nancy 1 - FRANCE
-- Copyright(C) 2003:      INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne
--			   - University of Nancy 2 - FRANCE
--
--		 Dominique COLNET, Suzanne COLLIN, Olivier ZENDRA,
--			   Philippe RIBET, Cyril ADRIAN
--
-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
--
class PRINT_JVM_CLASS
   --
   -- The `print_jvm_class' command.
   --

inherit
   COMMAND_LINE_TOOLS
   CP_INFO_TAGS

creation make

feature

   command_name: STRING is "print_jvm_class"

   command_line_help_summary: STRING is
      "Usage: print_jvm_class [options] <Path>[.class]%N%
      %%N%
      %Option summary:%N%
      %%N%
      %Information:%N%
      %  -help               Display this help information%N%
      %  -version            Display SmartEiffel version information%N%
      %  -verbose            Display detailed information about what the%N%
      %                       program is doing%N"

feature {PRINT_JVM_CLASS_VISITOR}

   accept(visitor: PRINT_JVM_CLASS_VISITOR) is
      do
         visitor.visit_print_jvm_class(Current)
      end

feature {NONE}

   bytes: FIXED_ARRAY[INTEGER] is
         -- All bytes of the class file.
      once
         !!Result.with_capacity(4096)
      end

   constant_pool_count: INTEGER

   this_class_idx: INTEGER

   super_class_idx: INTEGER

   interfaces_count: INTEGER

   fields_count: INTEGER

   methods_count: INTEGER

   attributes_count: INTEGER

   make is
      local
	 arg, class_name: STRING; i: INTEGER
      do
         if argument_count = 0 then
            system_tools.bad_use_exit(Current)
	 end
         search_for_verbose_flag
	 from
	    i := 1
	 until
	    i > argument_count
	 loop
	    arg := argument(i)
	    if is_some_flag(arg) then
	       if (is_version_flag(arg)
		   or else
		   is_help_flag(arg)
		   or else
		   is_verbose_flag(arg))
		then
		  i := i + 1
	       else
		  unknown_flag_exit(arg)
	       end
	    elseif class_name /= Void then
	       system_tools.bad_use_exit(Current)
	    else
	       class_name := arg
	       i := i + 1
	    end
	 end
	 if class_name /= Void then
	    print_jvm_class(class_name)
	 end
      end

   print_jvm_class(arg: STRING) is
      local
         path: STRING
         file_of_bytes: BINARY_FILE_READ
         byte, i, index: INTEGER
         s: STRING
         interface_idx: INTEGER
         access_flags: BIT Integer_bits
      do
	 path := arg.twin
	 if not path.has_suffix(once ".class") then
	    path.append(once ".class")
	 end
	 !!file_of_bytes.connect_to(path)
	 if file_of_bytes.is_connected then
	    from
	       io.put_string(once "Contents of file %"")
	       io.put_string(file_of_bytes.path)
	       io.put_string(once "%".%N")
	       file_of_bytes.read_byte
	       if file_of_bytes.end_of_input then
		  bad_class_file(once "Invalid empty class file.",0)
	       end
	    until
	       file_of_bytes.end_of_input
	    loop
	       byte := file_of_bytes.last_byte
	       bytes.add_last(byte)
	       file_of_bytes.read_byte
	    end
	    file_of_bytes.disconnect
	    io.put_string(once "Total bytes: ")
	    io.put_integer(bytes.count)
	    io.put_new_line
	    io.put_string(once "Magic number: ")
	    s := hexa4_at(0)
	    if not (once "0xCAFEBABE").is_equal(s) then
	       bad_class_file(once "Invalid Magic number.",0)
	    else
	       io.put_string(s)
	       io.put_new_line
	    end
	    io.put_string(once "Minor version: ")
	    io.put_string(hexa2_at(4))
	    io.put_new_line
	    io.put_string(once "Major version: ")
	    io.put_string(hexa2_at(6))
	    io.put_new_line
	    io.put_string(once "Constant pool count: ")
	    constant_pool_count := u2_integer_at(8)
	    io.put_integer(constant_pool_count)
	    io.put_new_line
	    io.put_string(once "Loading constant pool items :%N")
	    from
	       constant_pool.reset(constant_pool_count - 1)
	       index := 10; -- of first item in constant pool.
	       i := 1
	    until
	       i >= constant_pool_count
	    loop
	       index := load_cp_info(i,index)
	       i := i + 1
	    end
	    io.put_string(once "Constant pool view :%N")
	    from
	       index := 10; -- of first item in constant pool.
	       i := 1
	    until
	       i >= constant_pool_count
	    loop
	       tmp_string.clear
	       integer_to_hexa_in(i,tmp_string)
	       tmp_string.extend(' ')
	       extend_string(tmp_string,' ',6)
	       i.append_in(tmp_string)
	       tmp_string.extend(' ')
	       extend_string(tmp_string,' ',12)
	       tmp_string.extend('(')
	       integer_to_hexa_in(index,tmp_string)
	       tmp_string.extend(')')
	       extend_string(tmp_string,' ',20)
	       tmp_string.append(once " : ")
	       io.put_string(tmp_string)
	       index := print_cp_info(i,index)
	       io.put_new_line
	       i := i + 1
	    end
	    io.put_string(once "Access flag: ")
	    io.put_string(hexa2_at(index))
	    io.put_character(' ')
	    access_flags := bytes.item(index + 1).to_bit
	    if (access_flags and 1B).to_boolean then
	       io.put_string(once "public ")
	    end
	    if (access_flags and 10000B).to_boolean then
	       io.put_string(once "final (no subclass)")
	    end
	    if (access_flags and 100000B).to_boolean then
	       io.put_string(once "invokespecial (for superclass) ")
	    end
	    access_flags := bytes.item(index).to_bit
	    if (access_flags and 10B).to_boolean then
	       io.put_string(once "interface ")
	    end
	    if (access_flags and 100B).to_boolean then
	       io.put_string(once "abstract ")
	    end
	    io.put_new_line
	    index := index + 2
	    io.put_new_line
	    io.put_string(once "This Class: ")
	    this_class_idx := u2_integer_at(index)
	    index := index + 2
	    if constant_pool.is_class(this_class_idx) then
	       tmp_string.copy(once " is ")
	       constant_pool.view_in(tmp_string,this_class_idx)
	       io.put_string(tmp_string)
	    else
	       io.put_string(once "??%N")
	       bad_class_file(once "Bad `this_class' value.",index - 2)
	    end
	    io.put_new_line
	    io.put_string(once "Super Class: ")
	    super_class_idx := u2_integer_at(index)
	    index := index + 2
	    if constant_pool.is_class(super_class_idx) then
	       tmp_string.copy(once "is ")
	       constant_pool.view_in(tmp_string,super_class_idx)
	       io.put_string(tmp_string)
	    else
	       io.put_string(once "??%N")
	       bad_class_file(once "Bad `super_class' value.",index - 2)
	    end
	    io.put_new_line
	    io.put_string(once "Interfaces count: ")
	    interfaces_count := u2_integer_at(index)
	    index := index + 2
	    io.put_integer(interfaces_count)
	    i := interfaces_count
	    if i > 0 then
	       io.put_string(once " {")
	       from
	       until
		  i = 0
	       loop
		  interface_idx := u2_integer_at(index)
		  index := index + 2
		  io.put_integer(interface_idx)
		  i := i - 1
		  if i > 0 then
		     io.put_character(',')
		  end
	       end
	       io.put_character('}')
	    end
	    io.put_new_line
	    io.put_string(once "----- Fields count: ")
	    fields_count := u2_integer_at(index)
	    index := index + 2
	    io.put_integer(fields_count)
	    io.put_new_line
	    from
	       i := 1
	    until
	       i > fields_count
	    loop
	       io.put_integer(i)
	       if i < 10 then
		  io.put_string(once "   ")
	       elseif i < 100 then
		  io.put_string(once "  ")
	       else
		  io.put_string(once " ")
	       end
	       io.put_string(once ": ")
	       index := print_field_info(index)
	       io.put_new_line
	       i := i + 1
	    end
	    io.put_string(once "----- Methods count: ")
	    methods_count := u2_integer_at(index)
	    index := index + 2
	    io.put_integer(methods_count)
	    io.put_new_line
	    from
	       i := 1
	    until
	       i > methods_count
	    loop
	       io.put_integer(i)
	       if i < 10 then
		  io.put_string(once "   ")
	       elseif i < 100 then
		  io.put_string(once "  ")
	       else
		  io.put_string(once " ")
	       end
	       io.put_string(once ": ")
	       index := print_method_info(index)
	       io.put_new_line
	       i := i + 1
	    end
	    io.put_string(once "Attributes count: ")
	    attributes_count := u2_integer_at(index)
	    index := index + 2
	    io.put_integer(attributes_count)
	    io.put_new_line
	    from
	       i := 1
	    until
	       i > attributes_count
	    loop
	       io.put_integer(i)
	       if i < 10 then
		  io.put_string(once "   ")
	       elseif i < 100 then
		  io.put_string(once "  ")
	       else
		  io.put_string(once " ")
	       end
	       io.put_string(once ": ")
	       index := print_attribute_info(index)
	       io.put_new_line
	       i := i + 1
	    end
	    check
	       index = bytes.upper + 1
	    end
	 else
	    io.put_string(once "File %"")
	    io.put_string(path)
	    io.put_string(once "%" not found.%N")
	 end
      end

feature {NONE} -- Low level access in `bytes' :

   character_at(index: INTEGER): CHARACTER is
      do
         Result := bytes.item(index).to_character
      end

   u2_at(index: INTEGER): STRING is
      do
         !!Result.make(2)
         Result.extend(character_at(index + 0))
         Result.extend(character_at(index + 1))
      end

   u4_at(index: INTEGER): STRING is
      do
         !!Result.make(4)
         Result.extend(character_at(index + 0))
         Result.extend(character_at(index + 1))
         Result.extend(character_at(index + 2))
         Result.extend(character_at(index + 3))
      end

   u8_at(index: INTEGER): STRING is
      do
         !!Result.make(8)
         Result.extend(character_at(index + 0))
         Result.extend(character_at(index + 1))
         Result.extend(character_at(index + 2))
         Result.extend(character_at(index + 3))
         Result.extend(character_at(index + 4))
         Result.extend(character_at(index + 5))
         Result.extend(character_at(index + 6))
         Result.extend(character_at(index + 7))
      end

   hexa1_at(index: INTEGER): STRING is
      do
         !!Result.copy(once "0x")
         bytes.item(index).to_character.to_hexadecimal_in(Result)
      end

   hexa2_at(index: INTEGER): STRING is
      do
         !!Result.copy(once "0x")
         bytes.item(index + 0).to_character.to_hexadecimal_in(Result)
         bytes.item(index + 1).to_character.to_hexadecimal_in(Result)
      end

   hexa4_at(index: INTEGER): STRING is
      do
         !!Result.copy(once "0x")
         bytes.item(index + 0).to_character.to_hexadecimal_in(Result)
         bytes.item(index + 1).to_character.to_hexadecimal_in(Result)
         bytes.item(index + 2).to_character.to_hexadecimal_in(Result)
         bytes.item(index + 3).to_character.to_hexadecimal_in(Result)
      end

   hexa8_at(index: INTEGER): STRING is
      do
         !!Result.copy(once "0x")
         bytes.item(index + 0).to_character.to_hexadecimal_in(Result)
         bytes.item(index + 1).to_character.to_hexadecimal_in(Result)
         bytes.item(index + 2).to_character.to_hexadecimal_in(Result)
         bytes.item(index + 3).to_character.to_hexadecimal_in(Result)
         bytes.item(index + 4).to_character.to_hexadecimal_in(Result)
         bytes.item(index + 5).to_character.to_hexadecimal_in(Result)
         bytes.item(index + 6).to_character.to_hexadecimal_in(Result)
         bytes.item(index + 7).to_character.to_hexadecimal_in(Result)
      end

   u2_integer_at(index: INTEGER): INTEGER is
      do
         Result := bytes.item(index)
         Result := Result |<<8 | bytes.item(index + 1)
      end

   u4_integer_at(index: INTEGER): INTEGER is
      do
         Result := bytes.item(index)
         Result := Result |<< 8 | (bytes.item(index + 1) & 0x000000ff)
         Result := Result |<< 8 | (bytes.item(index + 2) & 0x000000ff)
         Result := Result |<< 8 | (bytes.item(index + 3) & 0x000000ff)

         debug
            inst.extend('[')
            bytes.item(index).append_in(inst)
            inst.extend(',')
            bytes.item(index+1).append_in(inst)
            inst.extend(',')
            bytes.item(index+2).append_in(inst)
            inst.extend(',')
            bytes.item(index+3).append_in(inst)
            inst.extend(']')
         end
      end

feature {NONE} -- Basic stuff to view values:

   integer_to_hexa_in(int: INTEGER; str: STRING) is
      require
         int >= 0
      do
         str.append(once "0x")
         inspect
            int
         when 0 .. 255 then
            int.to_character.to_hexadecimal_in(str)
         when 256 .. 65535 then
            (int \\ 256).to_character.to_hexadecimal_in(str)
            ; (int // 256).to_character.to_hexadecimal_in(str)
         end
      end

   extend_string(s: STRING; c: CHARACTER; length: INTEGER) is
      do
         from
         until
            s.count >= length
         loop
            s.extend(c)
         end
      end

   bad_class_file(msg: STRING; at: INTEGER) is
         -- If `at' is greater than 0, the corresponding byte
         -- is shown during the class file dump.
      require
         bytes.valid_index(at)
      local
         fz_visible, fz_hexadec: STRING
         index: INTEGER
         byte: CHARACTER
         left_margin: INTEGER
      do
         io.put_string(msg)
         io.put_new_line
         io.put_string(once "Class file dump:%N")
         from
            !!fz_visible.make(16)
            !!fz_hexadec.make(32)
         until
            index > bytes.upper
         loop
            if fz_visible.is_empty then
               tmp_string.clear
               integer_to_hexa_in(index,tmp_string)
               tmp_string.extend(' ')
               extend_string(tmp_string,' ',9)
               index.append_in(tmp_string)
               tmp_string.extend(' ')
               extend_string(tmp_string,' ',15)
               io.put_string(tmp_string)
               left_margin := tmp_string.count
            end
            byte := character_at(index)
            byte.to_hexadecimal_in(fz_hexadec)
            inspect
               byte.code
            when 32 .. 126 then
               fz_visible.extend(byte)
            else
               fz_visible.extend('.')
            end
            if fz_visible.count = 16 then
               show_dump_line(fz_hexadec,fz_visible,left_margin,index,at)
            end
            index := index + 1
         end
         if fz_visible.count > 0 then
            from
               index := index - 1
            until
               fz_visible.count = 16
            loop
               fz_visible.extend(' ')
               fz_hexadec.append(once "  ")
               index := index + 1
            end
            show_dump_line(fz_hexadec,fz_visible,left_margin,index,at)
         end
         die_with_code(exit_failure_code)
      end

   show_dump_line(hexadec, visible: STRING; left_margin, index, at: INTEGER) is
         -- Where `index - 15' is the index of `visible.item(1)'.
      require
         bytes.valid_index(at)
         visible.count = 16
         hexadec.count = 32
      local
         min, max, i: INTEGER
      do
         io.put_string(hexadec)
         io.put_string(once " ")
         io.put_string(visible)
         io.put_new_line
         min := index - 15
         max := index
         if (at > 0) and (min <= at) and (at <= max) then
            from
               tmp_string.clear
               extend_string(tmp_string,'_',left_margin)
               i := min
            until
               i = at
            loop
               tmp_string.append(once "__")
               i := i + 1
            end
            io.put_string(tmp_string)
            io.put_string(once "^^%N*** Error at this byte%N")
            io.put_string(once "Remainder of the class file :%N")
         end
         visible.clear
         hexadec.clear
      ensure
         visible.is_empty
         hexadec.is_empty
      end

   load_cp_info(i: INTEGER; index: INTEGER): INTEGER is
         -- Gives the index of the following item.
      local
         tag, i2, length: INTEGER
         utf8: STRING
      do
         tmp_string.clear
         tmp_string.append(once "item #")
         i.append_in(tmp_string)
         extend_string(tmp_string,' ',8)
         tmp_string.append(once " : ")
         io.put_string(tmp_string)
         tag := bytes.item(index)
         inspect
            tag.to_character
         when Constant_class then
            io.put_string(once "CONSTANT_Class")
            constant_pool.set_class(i,u2_at(index + 1))
            Result := index + 3
         when Constant_fieldref then
            io.put_string(once "CONSTANT_Fieldref")
            constant_pool.set_fieldref(i,u4_at(index + 1))
            Result := index + 5
         when Constant_methodref then
            io.put_string(once "CONSTANT_Methodref")
            constant_pool.set_methodref(i,u4_at(index + 1))
            Result := index + 5
         when Constant_interfacemethodref then
            io.put_string(once "CONSTANT_InterfaceMethodref")
            constant_pool.set_interface_methodref(i,u4_at(index + 1))
            Result := index + 5
         when Constant_string then
            io.put_string(once "CONSTANT_String")
            constant_pool.set_string(i,u2_at(index + 1))
            Result := index + 3
         when Constant_integer then
            io.put_string(once "CONSTANT_Integer")
            constant_pool.set_integer(i,u4_at(index + 1))
            Result := index + 5
         when Constant_float then
            io.put_string(once "CONSTANT_Float")
            constant_pool.set_float(i,u4_at(index + 1))
            Result := index + 5
         when Constant_long then
            io.put_string(once "CONSTANT_Long")
            constant_pool.set_long(i,u8_at(index + 1))
            Result := index + 9
         when Constant_double then
            io.put_string(once "CONSTANT_Double")
            constant_pool.set_double(i,u8_at(index + 1))
            Result := index + 9
         when Constant_name_and_type then
            io.put_string(once "CONSTANT_NameandType")
            constant_pool.set_name_and_type(i,u4_at(index + 1))
            Result := index + 5
         when Constant_utf8 then
            io.put_string(once "CONSTANT_Utf8")
            length := u2_integer_at(index + 1)
            Result := index + 3
            !!utf8.make(length + 2)
            utf8.extend(character_at(index + 1))
            utf8.extend(character_at(index + 2))
            from
               i2 := length
            until
               i2 = 0
            loop
               utf8.extend(character_at(Result))
               Result := Result + 1
               i2 := i2 - 1
            end
            constant_pool.set_utf8(i,utf8)
         else
            io.put_string(once "Error while loading constant pool.%N")
            io.put_string(once "Problem with item #")
            io.put_integer(i)
            io.put_string(once "%NBad cp_info tag : ")
            io.put_integer(tag)
            io.put_string(once "%N")
            bad_class_file(once "Bad constant pool.",index)
         end
         io.put_new_line
      end

   u2_to_integer(u2: STRING): INTEGER is
      require
         u2.count = 2
      do
         Result := u2.item(1).code
         Result := Result * 256
         Result := Result + u2.item(2).code
      ensure
         Result >= 0
      end

   print_cp_info(i: INTEGER; index: INTEGER): INTEGER is
         -- Gives the index of the following item.
      local
         tag: INTEGER
         cp_info: CP_INFO
         info: STRING
         class_idx, name_idx, type_idx, string_idx: INTEGER
      do
         tag := bytes.item(index)
         cp_info := constant_pool.item(i)
         info := cp_info.info
         check
            tag.to_character = cp_info.tag
         end
         inspect
            tag.to_character
         when Constant_class then -- CONSTANT_Class :
            io.put_string(once "class at ")
            class_idx := u2_to_integer(info)
            if constant_pool.valid_index(class_idx) then
               io.put_integer(class_idx)
               io.put_string(once ": ")
               cp_info := constant_pool.item(class_idx)
               if cp_info.tag.code = 1 then
                  tmp_string.clear
                  constant_pool.view_in(tmp_string,i)
                  io.put_string(tmp_string)
               else
                  io.put_string(once "%NUtf8 index expected.%N")
                  bad_class_file(once "Bad constant pool.",index + 1)
               end
            else
               io.put_string(once "Class index out of range.%N")
               bad_class_file(once "Bad constant pool.",index + 1)
            end
            Result := index + 3
         when Constant_fieldref then -- CONSTANT_Fieldref :
            io.put_string(once "fieldref class: ")
            print_cp_info_fields_methods(index,info)
            Result := index + 5
         when Constant_methodref then -- CONSTANT_Methodref :
            io.put_string(once "methodref class: ")
            print_cp_info_fields_methods(index,info)
            Result := index + 5
         when Constant_interfacemethodref then -- CONSTANT_InterfaceMethodref :
            io.put_string(once "interface methodref class: ")
            print_cp_info_fields_methods(index,info)
            Result := index + 5
         when Constant_string then -- CONSTANT_String :
            io.put_string(once "string at ")
            string_idx := u2_to_integer(info)
            if constant_pool.valid_index(string_idx) then
               io.put_integer(string_idx)
               io.put_string(once " : %"")
               cp_info := constant_pool.item(string_idx)
               if cp_info.tag.code = 1 then
                  tmp_string.clear
                  constant_pool.view_in(tmp_string,i)
                  io.put_string(tmp_string)
                  io.put_string(once "%"")
               else
                  io.put_string(once "%NUtf8 index expected.%N")
                  bad_class_file(once "Bad constant pool.",index + 1)
               end
            else
               io.put_string(once "??%NString index out of range.%N")
               bad_class_file(once "Bad constant pool.",index + 1)
            end
            Result := index + 3
         when Constant_integer then -- CONSTANT_Integer :
            io.put_string(once "integer: ")
            io.put_string(hexa4_at(index + 1))
            Result := index + 5
         when Constant_float then -- CONSTANT_Float :
            io.put_string(once "float: ")
            io.put_string(hexa4_at(index + 1))
            Result := index + 5
         when Constant_long then -- CONSTANT_Long :
            io.put_string(once "long: ")
            io.put_string(hexa8_at(index + 1))
            Result := index + 9
         when Constant_double then -- CONSTANT_Double :
            io.put_string(once "double: ")
            io.put_string(hexa8_at(index + 1))
            Result := index + 9
         when Constant_name_and_type then -- CONSTANT_NameandType :
            io.put_string(once "name: ")
            name_idx := u2_to_integer(info.substring(1,2))
            if constant_pool.valid_index(name_idx) then
               cp_info := constant_pool.item(name_idx)
               if cp_info.tag.code = 1 then
                  tmp_string.clear
                  constant_pool.view_in(tmp_string,name_idx)
                  io.put_string(tmp_string)
                  io.put_string(once " type: ")
                  type_idx := u2_to_integer(info.substring(3,4))
                  if constant_pool.valid_index(type_idx) then
                     cp_info := constant_pool.item(type_idx)
                     if cp_info.tag.code = 1 then
                        tmp_string.clear
                        constant_pool.view_in(tmp_string,type_idx)
                        io.put_string(tmp_string)
                     else
                        io.put_string(once "??%NUtf8 index expected.%N")
                        bad_class_file(once "Bad constant pool.",index + 3)
                     end
                  else
                     io.put_string(once "%NType index out of range.%N")
                     bad_class_file(once "Bad constant pool.",index + 3)
                  end
               else
                  io.put_string(once "%NUtf8 index expected.%N")
                  bad_class_file(once "Bad constant pool.",index + 1)
               end
            else
               io.put_string(once "??%NClass index out of range.%N")
               bad_class_file(once "Bad constant pool.",index + 1)
            end
            Result := index + 5
         when Constant_utf8 then -- CONSTANT_Utf8 :
            io.put_string(once "utf8: %"")
            tmp_string.clear
            constant_pool.view_in(tmp_string,i)
            io.put_string(tmp_string)
            io.put_string(once "%"")
            Result := index + 1 + cp_info.info.count
         end
      end

   print_cp_info_fields_methods(index: INTEGER; info: STRING) is
      require

      local
         cp_info: CP_INFO
         class_idx, utf8_idx, name_and_type_idx: INTEGER
      do
         class_idx := u2_to_integer(info.substring(1,2))
         name_and_type_idx := u2_to_integer(info.substring(3,4))
         if constant_pool.valid_index(class_idx) then
            cp_info := constant_pool.item(class_idx)
            if cp_info.tag.code = 7 then
               utf8_idx := u2_to_integer(cp_info.info)
               if constant_pool.valid_index(utf8_idx) then
                  tmp_string.clear
                  constant_pool.view_in(tmp_string,class_idx)
                  io.put_string(tmp_string)
                  io.put_string(once " name_and_type: ")
                  if constant_pool.valid_index(name_and_type_idx) then
                     tmp_string.clear
                     constant_pool.view_in(tmp_string,name_and_type_idx)
                     io.put_string(tmp_string)
                  else
                     io.put_string(once "??%N*** Error: name_and_type_index expected.")
                     bad_class_file(once "Bad constant pool.",index + 3)
                  end
               else
                  io.put_string(once "??%N*** Error: Class index expected.")
               end
            else
               io.put_string(once "%NClass index expected.%N")
               bad_class_file(once "Bad constant pool.",index + 1)
            end
         else
            io.put_string(once "??%NClass index out of range.%N")
            bad_class_file(once "Bad constant pool.",index + 1)
         end
      end

   print_field_info(index: INTEGER): INTEGER is
      local
         access_flags_idx, name_idx: INTEGER
         descriptor_idx, field_attributes_count: INTEGER
         access_flags: BIT Integer_bits
      do
         access_flags_idx := index
         Result := index + 2
         io.put_string(once "access flags (")
         io.put_string(hexa2_at(access_flags_idx))
         io.put_string(once "): ")
         access_flags := bytes.item(access_flags_idx + 1).to_bit
         if (access_flags and 1B).to_boolean then
            io.put_string(once "public ")
         end
         if (access_flags and 10B).to_boolean then
            io.put_string(once "private ")
         end
         if (access_flags and 100B).to_boolean then
            io.put_string(once "protected ")
         end
         if (access_flags and 1000B).to_boolean then
            io.put_string(once "static ")
         end
         if (access_flags and 10000B).to_boolean then
            io.put_string(once "final ")
         end
         if (access_flags and 1000000B).to_boolean then
            io.put_string(once "volatile ")
         end
         if (access_flags and 10000000B).to_boolean then
            io.put_string(once "transient ")
         end
         io.put_new_line
         io.put_string(once "Field name: ")
         name_idx := u2_integer_at(Result)
         Result := Result + 2
         if constant_pool.valid_index(name_idx) then
            tmp_string.clear
            constant_pool.view_in(tmp_string,name_idx)
            io.put_string(tmp_string)
            descriptor_idx := u2_integer_at(Result)
            Result := Result + 2
            io.put_string(once " descriptor: ")
            if constant_pool.valid_index(descriptor_idx) then
               tmp_string.clear
               constant_pool.view_in(tmp_string,descriptor_idx)
               io.put_string(tmp_string)
               field_attributes_count := u2_integer_at(Result)
               Result := Result + 2
               io.put_new_line
               io.put_string(once "Attributes count: ")
               io.put_integer(field_attributes_count)
               io.put_new_line
               from
               until
                  field_attributes_count = 0
               loop
                  Result := print_attribute_info(Result)
                  field_attributes_count := field_attributes_count - 1
               end
            else
               io.put_string(once "??%NDescriptor index out of range.%N")
               bad_class_file(once "Bad constant pool.",Result - 2)
            end
         else
            io.put_string(once "??%NName index out of range.%N")
            bad_class_file(once "Bad constant pool.",Result - 2)
         end
      end

   print_attribute_info(index: INTEGER): INTEGER is
      local
         attribute_name_idx, attribute_length: INTEGER
         attribute_name: STRING
         tmp: INTEGER
      do
         attribute_name_idx := u2_integer_at(index)
         Result := index + 2
         io.put_string(once "Attribute Name: ")
         tmp_string.clear
         constant_pool.view_in(tmp_string,attribute_name_idx)
         io.put_string(tmp_string)
         attribute_name := tmp_string.twin
         attribute_length := u4_integer_at(Result)
         Result := Result + 4
         io.put_string(once " length: ")
         io.put_integer(attribute_length)
         io.put_character(' ')
         if (once "Code").is_equal(attribute_name) then
            tmp := print_code_attribute(Result,attribute_length)
            Result := Result + attribute_length
         else
            io.put_string(once " Ignored (skipped)%N")
            Result := Result + attribute_length
         end
      end


   print_method_info(index: INTEGER): INTEGER is
      local
         access_flags_idx, name_idx: INTEGER
         descriptor_idx, method_attributes_count: INTEGER
         access_flags: BIT Integer_bits
      do
         access_flags_idx := index
         Result := index + 2
         io.put_string(once "access flags (")
         io.put_string(hexa2_at(access_flags_idx))
         io.put_string(once "): ")
         access_flags := bytes.item(access_flags_idx + 1).to_bit
         if (access_flags and 1B).to_boolean then
            io.put_string(once "public ")
         end
         if (access_flags and 10B).to_boolean then
            io.put_string(once "private ")
         end
         if (access_flags and 100B).to_boolean then
            io.put_string(once "protected ")
         end
         if (access_flags and 1000B).to_boolean then
            io.put_string(once "static ")
         end
         if (access_flags and 10000B).to_boolean then
            io.put_string(once "final ")
         end
         if (access_flags and 100000B).to_boolean then
            io.put_string(once "synchronized ")
         end
         access_flags := bytes.item(access_flags_idx).to_bit
         if (access_flags and 1B).to_boolean then
            io.put_string(once "native ")
         end
         if (access_flags and 100B).to_boolean then
            io.put_string(once "abstract ")
         end
         io.put_new_line
         name_idx := u2_integer_at(Result)
         Result := Result + 2
         io.put_string(once "Method name: ")
         tmp_string.clear
         constant_pool.view_in(tmp_string,name_idx)
         io.put_string(tmp_string)
         io.put_string(once " descriptor: ")
         descriptor_idx := u2_integer_at(Result)
         Result := Result + 2
         tmp_string.clear
         constant_pool.view_in(tmp_string,descriptor_idx)
         io.put_string(tmp_string)
         io.put_new_line
         io.put_string(once "Attributes count: ")
         method_attributes_count := u2_integer_at(Result)
         Result := Result + 2
         io.put_integer(method_attributes_count)
         io.put_new_line
         from
         until
            method_attributes_count = 0
         loop
            Result := print_attribute_info(Result)
            method_attributes_count := method_attributes_count - 1
         end
      end

   print_code_attribute(index, length: INTEGER): INTEGER is
      local
         code_length: INTEGER
         exception_table_length: INTEGER
         max_stack, max_locals: INTEGER
         -- idx: INTEGER
         local_attributes_count: INTEGER
      do
         io.put_string(once "%Nmax_stack: ")
         max_stack := u2_integer_at(index)
         Result := index + 2
         io.put_integer(max_stack)
         io.put_string(once " max_locals: ")
         max_locals := u2_integer_at(Result)
         Result := Result + 2
         io.put_integer(max_locals)
         io.put_string(once " code_length: ")
         code_length := u4_integer_at(Result)
         Result := Result + 4
         io.put_integer(code_length)
         io.put_new_line
         print_byte_code(Result,code_length)
         Result := Result + code_length
         exception_table_length := u2_integer_at(Result)
         Result := Result + 2
         io.put_string(once "Exception(s): ")
         io.put_integer(exception_table_length)
         io.put_new_line
         print_exception_table(Result,exception_table_length)
         Result := Result + exception_table_length * 8
         io.put_string(once "Attributes count: ")
         local_attributes_count := u2_integer_at(Result)
         Result := Result + 2
         io.put_integer(local_attributes_count)
         io.put_new_line
         from
         until
            local_attributes_count = 0
         loop
            Result := print_attribute_info(Result)
            local_attributes_count := local_attributes_count - 1
         end
      end

   inst_view(byte_idx: INTEGER; cp_idx_type: CHARACTER) is
      local
         cp_idx: INTEGER
         cp_info: CP_INFO
      do
         cp_idx := u2_integer_at(byte_idx)
         if constant_pool.valid_index(cp_idx) then
            cp_info := constant_pool.item(cp_idx)
            if cp_info.tag = cp_idx_type then
               constant_pool.view_in(inst,cp_idx)
            else
               tmp_string.clear
               tmp_string.append(once "????%N")
               tmp_string.append(once "Invalid type entry in constant pool at: ")
               cp_idx.append_in(tmp_string)
               tmp_string.append(once " : ")
               constant_pool.view_in(tmp_string,cp_idx)
               tmp_string.append(once "%NExpected tag: ")
               cp_idx_type.code.append_in(tmp_string)
               tmp_string.append(once " (")
               cp_info_tag_name_in(cp_idx_type,tmp_string)
               tmp_string.append(once ")%NActual   tag: ")
               cp_info.tag.code.append_in(tmp_string)
               tmp_string.append(once " (")
               cp_info_tag_name_in(cp_info.tag,tmp_string)
               tmp_string.append(once ")%N")
               io.put_string(tmp_string)
               bad_class_file(once "Constant pool type index error.",byte_idx)
            end
         else
            io.put_string(once "????%N")
            bad_class_file(once "Valid index in constant pool expected.",byte_idx)
         end
      end

   u2sign_extended_view(str: STRING; idx: INTEGER) is
      local
         byte: INTEGER
      do
         byte := bytes.item(idx)
         str.append(hexa1_at(idx))
         str.append(once " (")
         if byte < 128 then
            byte.append_in(str)
         else
            (byte - 256).append_in(str)
         end
         str.append(once ")")
      end

   print_one_instruction(pc_idx, pc: INTEGER): INTEGER is
         -- Return the following `pc_idx'.
      local
         opcode: INTEGER
         idx, i: INTEGER
         low, up, cnt: INTEGER
         in: like inst
      do
         in := inst -- for debug purposes (show the contents of the `inst' buffer)

         debug
            inst.extend('<')
            pc.append_in(inst)
            inst.extend('>')
         end

         Result := pc_idx + 1
         opcode := bytes.item(pc_idx)
         inspect
            opcode
         when 0 then
            inst_opcode(once "nop (Do nothing)")
         when 1 then
            inst_opcode(once "aconst_null (Push null)")
         when 2 then
            inst_opcode(once "iconst_m1 (Push int -1)")
         when 3 .. 8 then
            inst_opcode(once "iconst_")
            ; (opcode - 3).append_in(inst)
            inst.append(once " (Push int ")
            ; (opcode - 3).append_in(inst)
            inst.extend(')')
         when 9 then
            inst_opcode(once "lconst_0 (Push long 0)")
         when 10 then
            inst_opcode(once "lconst_1 (Push long 1)")
         when 11 .. 13 then
            inst_opcode(once "fconst_")
            ; (opcode - 11).append_in(inst)
         when 14 .. 15 then
            inst_opcode(once "dconst_")
            ; (opcode - 14).append_in(inst)
         when 16 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "bipush ")
            u2sign_extended_view(inst,pc_idx + 1)
            Result := Result + 1
         when 17 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "sipush ")
            inst.append(hexa2_at(pc_idx + 1))
            inst_opcode(once "(Push short with sign-extension)")
            Result := Result + 2
         when 18 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            idx := bytes.item(pc_idx + 1)
            inst_opcode(once "ldc at ")
            idx.append_in(inst)
            inst.append(once " : ")
            if constant_pool.valid_index(idx) then
               constant_pool.view_in(inst,idx)
            else
               io.put_string(once "??%N")
               bad_class_file(once "Constant pool index out of range.",pc_idx + 1)
            end
            Result := Result + 1
         when 19 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "ldc_w ")
            idx := u2_integer_at(pc_idx + 1)
            if constant_pool.valid_index(idx) then
               constant_pool.view_in(inst,idx)
            else
               io.put_string(once "????%N")
               bad_class_file(once "Constant pool index out of range.",pc_idx + 1)
            end
            Result := Result + 2
         when 20 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "ldc2_w ")
            idx := u2_integer_at(pc_idx + 1)
            if constant_pool.valid_index(idx) then
               constant_pool.view_in(inst,idx)
            else
               io.put_string(once "????%N")
               bad_class_file(once "CONSTANT_Long or CONSTANT_Double expected.",pc_idx + 1)
            end
            Result := Result + 2
         when 21 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "iload ")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.append(once " (load int from local #")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.extend(')')
            Result := Result + 1
         when 22 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "lload ")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.append(once " (load long from local #")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.extend(')')
            Result := Result + 1
         when 23 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "fload ")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.append(once " (load float from local #")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.extend(')')
            Result := Result + 1
         when 24 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "dload ")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.append(once " (load double from local #")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.extend(')')
            Result := Result + 1
         when 25 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "aload ")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.append(once " (load reference from local #")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.extend(')')
            Result := Result + 1
         when 26 .. 29 then
            inst_opcode(once "iload_")
            ; (opcode - 26).append_in(inst)
            inst.append(once " (load int from local #")
            ; (opcode - 26).append_in(inst)
            inst.extend(')')
         when 30 .. 33 then
            inst_opcode(once "lload_")
            ; (opcode - 30).append_in(inst)
            inst.append(once " (load long from local #")
            ; (opcode - 30).append_in(inst)
            inst.extend(')')
         when 34 .. 37 then
            inst_opcode(once "fload_")
            ; (opcode - 34).append_in(inst)
            inst.append(once " (load float from local #")
            ; (opcode - 34).append_in(inst)
            inst.extend(')')
         when 38 .. 41 then
            inst_opcode(once "dload_")
            ; (opcode - 38).append_in(inst)
            inst.append(once " (load double from local #")
            ; (opcode - 38).append_in(inst)
            inst.extend(')')
         when 42 .. 45 then
            inst_opcode(once "aload_")
            ; (opcode - 42).append_in(inst)
            inst.append(once " (load reference from local #")
            ; (opcode - 42).append_in(inst)
            inst.extend(')')
         when 46 then
            inst_opcode(once "iaload")
         when 47 then
            inst_opcode(once "laload")
         when 48 then
            inst_opcode(once "faload")
         when 49 then
            inst_opcode(once "daload")
         when 50 then
            inst_opcode(once "aaload")
         when 51 then
            inst_opcode(once "baload")
         when 52 then
            inst_opcode(once "caload")
         when 53 then
            inst_opcode(once "saload")
         when 54 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "istore ")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.append(once " (store int into local #")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.extend(')')
            Result := Result + 1
         when 55 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "lstore ")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.append(once " (store long into local #")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.extend(')')
            Result := Result + 1
         when 56 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "fstore ")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.append(once " (store float into local #")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.extend(')')
            Result := Result + 1
         when 57 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "dstore ")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.append(once " (store double into local #")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.extend(')')
            Result := Result + 1
         when 58 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "astore ")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.append(once " (store reference into local #")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.extend(')')
            Result := Result + 1
         when 59 .. 62 then
            inst_opcode(once "istore_")
            ; (opcode - 59).append_in(inst)
         when 63 .. 66 then
            inst_opcode(once "lstore_")
            ; (opcode - 63).append_in(inst)
            inst.append(once " (store long into local #")
            ; (opcode - 63).append_in(inst)
            inst.extend(')')
         when 67 .. 70 then
            inst_opcode(once "fstore_")
            ; (opcode - 67).append_in(inst)
            inst.append(once " (store float into local #")
            ; (opcode - 67).append_in(inst)
            inst.extend(')')
         when 71 .. 74 then
            inst_opcode(once "dstore_")
            ; (opcode - 71).append_in(inst)
            inst.append(once " (store double into local #")
            ; (opcode - 71).append_in(inst)
            inst.extend(')')
         when 75 .. 78 then
            inst_opcode(once "astore_")
            ; (opcode - 75).append_in(inst)
            inst.append(once " (store reference into local #")
            ; (opcode - 75).append_in(inst)
            inst.extend(')')
         when 79 then
            inst_opcode(once "iastore")
         when 80 then
            inst_opcode(once "lastore")
         when 81 then
            inst_opcode(once "fastore")
         when 82 then
            inst_opcode(once "dastore")
         when 83 then
            inst_opcode(once "aastore")
         when 84 then
            inst_opcode(once "bastore")
         when 85 then
            inst_opcode(once "castore")
         when 86 then
            inst_opcode(once "sastore")
         when 87 then
            inst_opcode(once "pop (...,w => ...)")
         when 88 then
            inst_opcode(once "pop2 (...,w1,w2 => ...)")
         when 89 then
            inst_opcode(once "dup (...,w => ...,w,w)")
         when 90 then
            inst_opcode(once "dup_x1 (...,w2,w1 => ...,w1,w2,w1)")
         when 91 then
            inst_opcode(once "dup_x2 (...,w3,w2,w1 => ...,w1,w3,w2,w1)")
         when 92 then
            inst_opcode(once "dup2 (...,w2,w1 => ...,w2,w1,w2,w1)")
         when 93 then
            inst_opcode(once "dup2_x1 (...,w3,w2,w1 => ...,w2,w1,w3,w2,w1)")
         when 94 then
            inst_opcode(once "dup2_x2 (...,w4,w3,w2,w1 => ...,w2,w1,w4,w3,w2,w1)")
         when 95 then
            inst_opcode(once "swap (...,w2,w1 => ...,w1,w2)")
         when 96 then
            inst_opcode(once "iadd")
         when 97 then
            inst_opcode(once "ladd")
         when 98 then
            inst_opcode(once "fadd")
         when 99 then
            inst_opcode(once "dadd")
         when 100 then
            inst_opcode(once "isub")
         when 101 then
            inst_opcode(once "lsub")
         when 102 then
            inst_opcode(once "fsub")
         when 103 then
            inst_opcode(once "dsub")
         when 104 then
            inst_opcode(once "imul")
         when 105 then
            inst_opcode(once "lmul")
         when 106 then
            inst_opcode(once "fmul")
         when 107 then
            inst_opcode(once "dmul")
         when 108 then
            inst_opcode(once "idiv")
         when 109 then
            inst_opcode(once "ldiv")
         when 110 then
            inst_opcode(once "fdiv")
         when 111 then
            inst_opcode(once "ddiv")
         when 112 then
            inst_opcode(once "irem")
         when 116 then
            inst_opcode(once "ineg")
         when 117 then
            inst_opcode(once "lneg")
         when 118 then
            inst_opcode(once "fneg")
         when 119 then
            inst_opcode(once "dneg")
         when 120 then
            inst_opcode(once "ishl")
         when 124 then
            inst_opcode(once "iushr")
         when 126 then
            inst_opcode(once "iand")
         when 128 then
            inst_opcode(once "ior")
         when 130 then
            inst_opcode(once "ixor")
         when 132 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "iinc local #")
            bytes.item(pc_idx + 1).append_in(inst)
            inst.append(once " with: :")
            inst.append(hexa1_at(pc_idx + 2))
            inst.append(once " (sign-extended)")
            Result := Result + 2
         when 133 then
            inst_opcode(once "i2l (Convert int to long)")
         when 134 then
            inst_opcode(once "i2f (Convert int to float)")
         when 135 then
            inst_opcode(once "i2d (Convert int to double)")
         when 136 then
            inst_opcode(once "l2i (Convert long to int)")
         when 137 then
            inst_opcode(once "l2f (Convert long to float)")
         when 138 then
            inst_opcode(once "l2d (Convert long to double)")
         when 139 then
            inst_opcode(once "f2i (Convert float to int)")
         when 140 then
            inst_opcode(once "f2l (Convert float to long)")
         when 141 then
            inst_opcode(once "f2d (Convert float to double)")
         when 142 then
            inst_opcode(once "d2i (Convert double to int)")
         when 143 then
            inst_opcode(once "d2l (Convert double to long)")
         when 144 then
            inst_opcode(once "d2f (Convert double to float)")
         when 145 then
            inst_opcode(once "i2b (Convert int to byte)")
         when 146 then
            inst_opcode(once "i2c (Convert int to char)")
         when 149 then
            inst_opcode(once "fcmpl")
         when 150 then
            inst_opcode(once "fcmpg")
         when 151 .. 152 then
            inst_opcode(once "dcmp")
            inspect
               opcode
            when 151 then
               inst.append(once "l")
            when 152 then
               inst.append(once "g")
            end
         when 153 .. 158 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "if")
            inspect
               opcode
            when 153 then
               inst.append(once "eq")
            when 154 then
               inst.append(once "ne")
            when 155 then
               inst.append(once "lt")
            when 156 then
               inst.append(once "ge")
            when 157 then
               inst.append(once "gt")
            when 158 then
               inst.append(once "le")
            end
            inst.extend(' ')
            view_pc(u2_integer_at(pc_idx + 1),pc)
            Result := Result + 2
         when 159 .. 166 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "if_")
            inspect
               opcode
            when 159 .. 164 then
               inst.extend('i')
            else
               inst.extend('a')
            end
            inst.append(once "cmp")
            inspect
               opcode
            when 159 then
               inst.append(once "eq")
            when 160 then
               inst.append(once "ne")
            when 161 then
               inst.append(once "lt")
            when 162 then
               inst.append(once "ge")
            when 163 then
               inst.append(once "gt")
            when 164 then
               inst.append(once "le")
            when 165 then
               inst.append(once "eq")
            when 166 then
               inst.append(once "ne")
            end
            inst.extend(' ')
            view_pc(u2_integer_at(pc_idx + 1),pc)
            Result := Result + 2
         when 167 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "goto ")
            view_pc(u2_integer_at(pc_idx + 1),pc)
            Result := Result + 2
         when 170 then
            inst_opcode(once "tableswitch (")
            Result := pc_idx+1
            from
            until
               (pc + Result - pc_idx) & 0x03 = 0
            loop
               Result := Result + 1
            end
            low := u4_integer_at(Result+4)
            low.append_in(inst)
            inst.append(once "..")
            up := u4_integer_at(Result+8)
            up.append_in(inst)
            inst.append(once ")%N                     default: ")
            view_pc(u4_integer_at(Result), pc)
            from
               i := low
               Result := Result + 12
            until
               i > up
            loop
               inst.append(once "%N                     ")
               i.append_in(inst)
               inst.append(once ": ")
               view_pc(u4_integer_at(Result), pc)
               i := i + 1
               Result := Result + 4
            end
         when 171 then
            inst_opcode(once "lookupswitch (")
            Result := pc_idx+1
            from
            until
               (pc + Result - pc_idx) & 0x03 = 0
            loop
               debug
                  inst.append(once "[pad:")
                  bytes.item(Result).append_in(inst)
                  inst.extend(']')
               end
               Result := Result + 1
            end
            cnt := u4_integer_at(Result+4)
            cnt.append_in(inst)
            inst.append(once ")%N                     default: ")
            view_pc(u4_integer_at(Result), pc)
            from
               i := 0
               Result := Result + 8
            until
               i >= cnt
            loop
               inst.append(once "%N                     ")
               u4_integer_at(Result).append_in(inst)
               inst.append(once ": ")
               view_pc(u4_integer_at(Result+4), pc)
               i := i + 1
               Result := Result + 8
            end
         when 172 then
            inst_opcode(once "ireturn")
         when 173 then
            inst_opcode(once "lreturn")
         when 174 then
            inst_opcode(once "freturn")
         when 175 then
            inst_opcode(once "dreturn")
         when 176 then
            inst_opcode(once "areturn")
         when 177 then
            inst_opcode(once "return")
         when 178 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "getstatic ")
            inst_view(pc_idx + 1,Constant_fieldref)
            Result := Result + 2
         when 179 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "putstatic ")
            inst_view(pc_idx + 1,Constant_fieldref)
            Result := Result + 2
         when 180 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "getfield ")
            inst_view(pc_idx + 1,Constant_fieldref)
            Result := Result + 2
         when 181 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "putfield ")
            inst_view(pc_idx + 1,Constant_fieldref)
            Result := Result + 2
         when 182 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "invokevirtual ")
            inst_view(pc_idx + 1,Constant_methodref)
            Result := Result + 2
         when 183 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "invokespecial ")
            inst_view(pc_idx + 1,Constant_methodref)
            Result := Result + 2
         when 184 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "invokestatic ")
            inst_view(pc_idx + 1,Constant_methodref)
            Result := Result + 2
         when 185 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "invokeinterface ")
            inst_view(pc_idx + 1,Constant_interfacemethodref)
            Result := Result + 2
         when 187 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "new ")
            inst_view(pc_idx + 1,Constant_class)
            Result := Result + 2
         when 188 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            inst_opcode(once "newarray of ")
            inspect
               bytes.item(pc_idx + 1)
            when 4 then
               inst.append(once "boolean")
            when 5 then
               inst.append(once "character")
            when 6 then
               inst.append(once "float")
            when 7 then
               inst.append(once "double")
            when 8 then
               inst.append(once "byte")
            when 9 then
               inst.append(once "short")
            when 10 then
               inst.append(once "int")
            when 11 then
               inst.append(once "long")
            else
               io.put_string(once "??%NInvalid newarray instruction.%N")
               bad_class_file(once "Bad array type.",pc_idx + 1)
            end
            Result := Result + 1
         when 189 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "anewarray of ")
            inst_view(pc_idx + 1,Constant_class)
            Result := Result + 2
         when 190 then
            inst_opcode(once "arraylength")
         when 191 then
            inst_opcode(once "athrow")
         when 192 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "checkcast ")
            inst_view(pc_idx + 1,Constant_class)
            Result := Result + 2
         when 193 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "instanceof ")
            inst_view(pc_idx + 1,Constant_class)
            Result := Result + 2
         when 198 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "ifnull ")
            view_pc(u2_integer_at(pc_idx + 1),pc)
            Result := Result + 2
         when 199 then
            character_at(pc_idx + 1).to_hexadecimal_in(inst)
            character_at(pc_idx + 2).to_hexadecimal_in(inst)
            inst_opcode(once "ifnonnull ")
            view_pc(u2_integer_at(pc_idx + 1),pc)
            Result := Result + 2
         else
            io.put_string(inst)
            io.put_new_line
            io.put_string(once "Unknown Opcode: ")
            io.put_integer(opcode)
            io.put_string(once " (0x")
            io.put_string(opcode.to_character.to_hexadecimal)
            io.put_string(once ")%N")
            bad_class_file(once "Unknown Opcode.",pc_idx)
         end
      ensure
         Result >= pc_idx + 1
      end

   print_byte_code(start_idx, length: INTEGER) is
         -- Print the byte code stored in range :
         --    [`start_idx' .. `start_idx' + `length']
      require
         bytes.valid_index(start_idx)
         length >= 0
      local
         pc_idx, pc: INTEGER
      do
         from
            pc_idx := start_idx
         until
            pc_idx = start_idx + length
         loop
            pc := pc_idx - start_idx
            tmp_string.copy(once "  ")
            integer_to_hexa_in(pc,tmp_string)
            tmp_string.append(once "  ")
            pc.append_in(tmp_string)
            tmp_string.extend(' ')
            extend_string(tmp_string,' ',12)
            character_at(pc_idx).to_hexadecimal_in(tmp_string)
            io.put_string(tmp_string)
            inst.clear
            pc_idx := print_one_instruction(pc_idx, pc_idx - start_idx)
            io.put_string(inst)
            io.put_new_line
         end
      end

   print_exception_table(index, length: INTEGER) is
      local
         i, idx: INTEGER

      do
         from
            i := length
          idx := index
         until
            i = 0
         loop
            io.put_string(once "start:   ")
          io.put_integer(u2_integer_at(idx))
            io.put_string(once "%Nend:     ")
          io.put_integer(u2_integer_at(idx + 2))
            io.put_string(once "%Nhandler: ")
          io.put_integer(u2_integer_at(idx + 4))
            io.put_string(once "%Ntype:    ")
          io.put_integer(u2_integer_at(idx + 6))
          inst.copy(once "")
          inst_view(idx + 6, Constant_class)
          io.put_string(once " (class ")
          io.put_string(inst)
          io.put_string(once ")%N")
            i := i - 1
          idx := idx + 8
         end
      end

   tmp_string: STRING is
      once
         !!Result.make(32)
      end

   inst_opcode(msg: STRING) is
      do
         extend_string(inst,' ',4)
         inst.extend(' ')
         inst.append(msg)
      end

   inst: STRING is
      once
         !!Result.make(80)
      end

   view_pc(offset, pc: INTEGER) is
      local
         view: INTEGER; bits: BIT Integer_bits
      do
         if offset < ((2 ^ 15) - 1) then
            view := pc + offset
         else
            view := (offset - (2 ^ 16)).to_integer + pc
         end
         view.append_in(inst)
      end

end -- PRINT_JVM_CLASS