Initial revision
[cacao.git] / tests / jctest.java
1 /************************* test/jctest.java ************************************
2
3         Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
4
5         See file COPYRIGHT for information on usage and disclaimer of warranties
6
7         Eine Klasse zum Testen (fast) aller JavaVM-Instruktionen
8         in verschiedenen Konstellationen.
9
10         Die Ausgabe, die dieses Programm generiert, sollte bei allen
11         verschiedenen Java-Interpreter/Compiler-Systemen gleich
12         sein. Wenn nicht, dann ist wahrscheinlich eines der Systeme
13         fehlerhaft.
14
15         Authors: Reinhard Grafl      EMAIL: cacao@complang.tuwien.ac.at
16
17         Last Change: 1996/12/03
18
19 *******************************************************************************/
20
21
22 public class jctest implements jcinterface {
23         static int i1=77;
24         static long l1=123456789,l2=987654321,l3=-99999999999999L;
25         static int i2,i3=-100;
26         static float f1=0.1F,f2=0.2F,f3=0.3F;
27         static double d1=0.001,d2=0.002,d3=0.003;
28         static String s1,s2="der konstante String";
29
30         int n_i1,n_i2,n_i3;
31         long n_l1,n_l2,n_l3,n_l4;
32         float n_f1,n_f2,n_f3,n_f4;
33         int n_i4;
34         double n_d1,n_d2,n_d3,n_d4;
35
36         
37         public static void main(String[] s) {
38                 p ("=================== JavaVM - Tester ========================");
39
40                 p ("------------------- test arguments");
41                 int i;
42                 for (i=0; i<s.length; i++) p(s[i]);
43
44                 testgeneral();
45                 testtables();
46                 testcasts();
47                 testspecialnullpointers();
48                 testarrays();
49                 
50                 p ("------------------- test consts");
51                 testconst ( 1,          1);
52                 testconst (-1,         -1);
53                 testconst (-24123,     -4918923241323L);
54                 testconst (-243511,    -4423423234231423L);
55                 testconst (0x7fffffff, 0x7fffffffffffffffL);
56
57                 p ("------------------- test ints");
58                 testint (1,2);
59                 testint (-1,17);
60                 testint (-24351,24123);
61                 testint (4918923,-441423);
62                 testint (0,0);
63                 testint (-1,-1);
64                 testint (1423487,123444444);
65                 testint (0x7fffffff,1);
66                 testint (0,0x7fffffff);
67                 testint (0x3333,143444);
68                 testint (4444441,12342);
69
70                 p ("------------------- test longs");
71                 testlong (1,2);
72                 testlong (-1,17);
73                 testlong (-24351,24123);
74                 testlong (4918923241323L,-4423423234231423L);
75                 testlong (0,0);
76                 testlong (-1,-1);
77                 testlong (1423487,123444442344L);
78                 testlong (0x7fffffffffffffffL,1);
79                 testlong (0,0x7fffffffffffffffL);
80                 testlong (0x3333,143444);
81                 testlong (4444441,12342);
82
83                 p ("------------------- test floats");
84                 testfloat ((float) 1,(float) 2.042);
85                 testfloat ((float) -1.234,(float) 17.44);
86                 testfloat ((float) -24351,(float) 24123);
87                 testfloat ((float) 0.1,(float) 1243);
88                 testfloat ((float) 0.0,(float) -555.4132);
89                 testfloat ((float) 77.0,(float) -555);
90                 testfloat ((float) 2147483000.0,(float) -555234);
91
92                 p ("------------------- test doubles");
93                 testdouble (1,2.042);
94                 testdouble (-1.234,17.44);
95                 testdouble (-24351,24123);
96                 testdouble (0.1,1243);
97                 testdouble (0.0,-555.4132);
98                 testdouble (77.0,-555);
99                 testdouble (2147483000.0,-555234);
100                 
101
102                 p ("=================== end of test =========================");                        
103                 }
104
105
106         static /* init */ {
107                 p ("successful initialisation");
108                 }
109
110
111                 
112         public static void testgeneral() {
113                 
114                 int i;
115                 // ******************** basic data types *******************************
116                 
117                 p ("------------------- test int-PUSH-STORE-LOAD");
118                 int j = -1;
119                 p(j); p (0); p(2); p(17); p(-100); 
120                 p (500); p(-32768); p(-32769); p(32767); p(32768);
121                 p (90000); p(-1000000000);
122                 
123                 p ("------------------- test long-PUSH-STORE-LOAD");
124                 long l = 3L;
125                 p ( l ); p ( 0L ); p ( 99L );
126                 p (500L); p(-32768L); p(-32769L); p(32767L); p(32768L);
127                 p ( 6900000000000L ); p ( 349827389478173274L );
128
129                 p ("------------------- test float-PUSH-STORE-LOAD");
130                 float f = 99.444F;
131                 p ( f ); p (0.0F); p (1.0F); p (342323423478.2223434234232334F);
132         
133                 p ("------------------- test double-PUSH-STORE-LOAD");
134                 double d = 99234.42D;
135                 p ( d ); p (0.0D); p (1.0D); p (342323423478.2223434234232334D);
136
137
138                 // ******************** static variables *******************************
139
140                 p ("------------------- test static variables");        
141                 i1 = i1+i2+i3;
142                 l2 = l1+l2+l3;
143                 f1 = f1*f2;
144                 p (i1); p(i2); p(i3); 
145                 p (l1); p(l2); p(l3);
146                 p (f1); p(f2); p(f3);
147                 p (d1); p(d2); p(d3);
148
149                 // ******************** arithmetic test ********************************
150                 
151                 p ("------------------- test arithmetic");
152                 i1 = 17;
153                 i2 = 0x7fffffff;
154                 p (i2);
155                 p (i2+1);
156                 p (i1-i2);
157                 l1 = 0x7fffffffffffffffL;
158                 p (l1);
159                 p (l1+1);
160                 p (l1+0x7fffffffffffffffL);
161                 
162                 
163                 // ******************** test method calls ******************************
164                 
165                 p ("statische methode");
166                 jctest ttt = new jctest ();
167                 ttt.p_manyparam (19,18,17,16, 88,77,66,55, 
168                                  0.1F,0.2F,0.3F,0.4F, -2.0D,-3.0D,-4.0D,-5.0D );
169                 jcinterface ttt2 = ttt;
170                 ttt2.p_nonstatic ("interface method");
171
172                 }
173
174
175
176         // ************************ test tables ************************************
177                 
178         public static void testtables() {
179                 int i;
180
181                 p ("------------------- test tableswitch");
182
183                 for (i = -5; i < 15; i++) {
184                         switch (i) {
185                                 case  2:  p ("->  2"); break;   
186                                 case  3:  p ("->  3"); break;   
187                                 case  5:  p ("->  5"); break;   
188                                 case  6:  p ("->  6"); break;
189                                 case  7:  p ("->  7"); break;
190                                 case  8:  p ("->  8"); break;
191                                 case 10:  p ("-> 10"); break;
192                                 default:  p ("default"); break;
193                                 }
194                         }
195
196                 p ("------------------- test lookupswitch");
197
198                 for (i = -5; i < 15; i++) {
199                         switch (i) {
200                                 case  2:  p ("->  2"); break;
201                                 case  8:  p ("->  8"); break;
202                                 case 14:  p ("-> 14"); break;
203                                 case -4:  p ("-> -4"); break;
204                                 default:  p ("default"); break;
205                                 }
206                         }       
207                 }
208
209
210         // ****************** test type casts and array stores *********************            
211
212         public static void testcasts() {
213                 Object    o   = new Object();
214                 Object    oi  = new Integer(0);
215                 Object[]  oa  = new Object [1];
216                 Object[]  oia = new Integer[1];
217                 Integer   i   = new Integer(0);
218                 Integer[] ia;
219
220                 p ("------------------- test casts");
221
222                 try {
223                         p ("type cast check: Integer = Object(Integer)");
224                         i = (Integer) oi;
225                         p ("type cast check: Integer = Object");
226                         i = (Integer) o;
227                         p ("error: class cast exception not thrown");
228                         }       
229                 catch (ClassCastException c) {
230                         p ("exception: class cast");
231                         }
232
233                 try {
234                         p ("type cast check: Integer[] = Object(Integer)[]");
235                         ia = (Integer[]) oia;
236                         p ("type cast check: Integer[] = Object[]");
237                         ia = (Integer[]) oa;
238                         p ("error: class cast exception not thrown");
239                         }       
240                 catch (ClassCastException c) {
241                         p ("exception: class cast");
242                         }
243
244                 try {
245                         p ("array store check: Object(Integer)[0] = Integer");
246                         oia[0] = i;
247                         p ("array store check: Object(Integer)[0] = Object");
248                         oia[0] = o;
249                         p ("error: array store exception not thrown");
250                         }       
251                 catch (ArrayStoreException c) {
252                         p ("exception: array store");
253                         }
254                 }
255
256
257         // ****************** test special null pointers ***************************            
258
259         public static void testspecialnullpointers() {
260                 int i = 0;
261                 jctest c = null;
262                 jcinterface f = null;
263
264                 p ("------------------- test special null pointers");
265
266                 try {
267                         p ("null pointer check: put field");
268                         c.n_i1 = 0;
269                         p ("error: put field null pointer exception not thrown");
270                         }       
271                 catch (NullPointerException x) {
272                         p ("exception: null pointer");
273                         }
274
275                 try {
276                         p ("null pointer check: get field");
277                         i = c.n_i1;
278                         p ("error: get field null pointer exception not thrown");
279                         }       
280                 catch (NullPointerException x) {
281                         p ("exception: null pointer");
282                         }
283
284                 try {
285                         p ("null pointer check: invokevirtual");
286                         c.p_nonstatic("invokevirtual");
287                         p ("error: invokevirtual null pointer exception not thrown");
288                         }       
289                 catch (NullPointerException x) {
290                         p ("exception: null pointer");
291                         }
292
293                 try {
294                         p ("null pointer check: invokeinterface");
295                         f.p_nonstatic("invokeinterface");
296                         p ("error: invokeinterface null pointer exception not thrown");
297                         }       
298                 catch (NullPointerException x) {
299                         p ("exception: null pointer");
300                         }
301
302                 try {
303                         p ("null pointer check: monitorenter");
304                         synchronized (c) {
305                                 p ("error: monitorenter null pointer exception not thrown");
306                                 }
307                         }       
308                 catch (NullPointerException x) {
309                         p ("exception: null pointer");
310                         }
311                 }
312
313
314         // ************************ test array bounds ******************************            
315
316         public static void testarraybounds(byte[] ba, int i) {
317                 
318                         p ("testarraybounds: " + (i - 10));
319                         ba[i-10] = 0;
320                         p ("testarraybounds: " + (i - 5));
321                         ba[i-5]  = 0;
322                         p ("testarraybounds: " + (i));
323                         ba[i]    = 0;
324                         p ("testarraybounds: " + (i + 5));
325                         ba[i+5]  = 0;
326                         p ("testarraybounds: " + (i + 10));
327                         ba[i+10] = 0;
328                 }
329
330
331         // ************************ test arrays ************************************            
332
333         public static void testarrays() {
334                 int    i;
335                 long   l;
336                 float  f;
337                 double d;
338                 String s;
339                 
340                 p ("------------------- test byte arrays");
341
342                 byte[] ba = null;
343
344                 try {
345                         p ("null pointer check: byte array store");
346                         ba[1] = 0;
347                         p ("error: null pointer exception not thrown");
348                         }       
349                 catch (NullPointerException c) {
350                         p ("exception: null pointer");
351                         }
352                 try {
353                         p ("null pointer check: byte array load");
354                         i = ba[1];
355                         p ("error: null pointer exception not thrown");
356                         }       
357                 catch (NullPointerException c) {
358                         p ("exception: null pointer");
359                         }
360
361                 try {
362                         p ("negative array size check: byte array");
363                         ba = new byte [-2];
364                         p ("error: negative array size exception not thrown");
365                         }       
366                 catch (NegativeArraySizeException c) {
367                         p ("exception: negative array size");
368                         }
369
370                 ba = new byte [100];
371
372
373                 try {
374                         p ("array bound check: byte array store");
375                         ba[-1] = 0;
376                         p ("error: exception not thrown");
377                         }       
378                 catch (ArrayIndexOutOfBoundsException c) {
379                         p ("exception: out of bounds: "+(-1));
380                         }
381                 try {
382                         p ("array bound check: byte array load");
383                         i = ba[-1];
384                         p ("error: exception not thrown");
385                         }       
386                 catch (ArrayIndexOutOfBoundsException c) {
387                         p ("exception: out of bounds: "+(-1));
388                         }
389
390                 try {
391                         testarraybounds(ba, 5);
392                         }       
393                 catch (ArrayIndexOutOfBoundsException c) {
394                         p ("exception: out of bounds: "+5);
395                         }
396                 try {
397                         testarraybounds(ba, 50);
398                         }       
399                 catch (ArrayIndexOutOfBoundsException c) {
400                         p ("exception: out of bounds: "+50);
401                         }
402                 try {
403                         testarraybounds(ba, 100);
404                         }       
405                 catch (ArrayIndexOutOfBoundsException c) {
406                         p ("exception: out of bounds: "+100);
407                         }
408
409                 try {
410                         ba[-4] = 0;
411                         }       
412                 catch (ArrayIndexOutOfBoundsException c) {
413                         p ("exception: out of bounds: "+(-4));
414                         }
415                 try {
416                         ba[-3] = 0;
417                         }       
418                 catch (ArrayIndexOutOfBoundsException c) {
419                         p ("exception: out of bounds: "+(-3));
420                         }
421                 for (i=-2; i<102; i++) { 
422                         try {
423                                 ba[i] = (byte) (i-50);
424                                 }       
425                         catch (ArrayIndexOutOfBoundsException c) {
426                                 p ("exception: out of bounds: "+i);
427                                 }
428                         }
429                 try {
430                         ba[102] = 0;
431                         }       
432                 catch (ArrayIndexOutOfBoundsException c) {
433                         p ("exception: out of bounds: "+102);
434                         }
435                 try {
436                         ba[103] = 0;
437                         }       
438                 catch (ArrayIndexOutOfBoundsException c) {
439                         p ("exception: out of bounds: "+103);
440                         }
441                 for (i=0; i<100; i++) p (ba[i]);                
442
443
444                 p ("-------- test short arrays");               
445
446                 short[] sa = null;
447
448                 try {
449                         p ("null pointer check: short array store");
450                         sa[1] = 0;
451                         p ("error: null pointer exception not thrown");
452                         }       
453                 catch (NullPointerException c) {
454                         p ("exception: null pointer");
455                         }
456                 try {
457                         p ("null pointer check: short array load");
458                         i = sa[1];
459                         p ("error: null pointer exception not thrown");
460                         }       
461                 catch (NullPointerException c) {
462                         p ("exception: null pointer");
463                         }
464
465                 sa = new short [100];
466
467                 try {
468                         p ("array bound check: short array store");
469                         sa[-1] = 0;
470                         p ("error: exception not thrown");
471                         }       
472                 catch (ArrayIndexOutOfBoundsException c) {
473                         p ("exception: out of bounds: "+(-1));
474                         }
475                 try {
476                         p ("array bound check: short array load");
477                         i = sa[-1];
478                         p ("error: exception not thrown");
479                         }       
480                 catch (ArrayIndexOutOfBoundsException c) {
481                         p ("exception: out of bounds: "+(-1));
482                         }
483
484                 for (i=0; i<100; i++) sa[i] = (short) (i-50);
485                 for (i=0; i<100; i++) p (sa[i]);
486                 
487
488                 p ("-------- test int arrays");         
489
490                 int[] ia = null;
491
492                 try {
493                         p ("null pointer check: int array store");
494                         ia[1] = 0;
495                         p ("error: null pointer exception not thrown");
496                         }       
497                 catch (NullPointerException c) {
498                         p ("exception: null pointer");
499                         }
500                 try {
501                         p ("null pointer check: int array load");
502                         i = ia[1];
503                         p ("error: null pointer exception not thrown");
504                         }       
505                 catch (NullPointerException c) {
506                         p ("exception: null pointer");
507                         }
508
509                 ia = new int [50];
510
511                 try {
512                         p ("array bound check: int array store");
513                         ia[-1] = 0;
514                         p ("error: exception not thrown");
515                         }       
516                 catch (ArrayIndexOutOfBoundsException c) {
517                         p ("exception: out of bounds: "+(-1));
518                         }
519                 try {
520                         p ("array bound check: int array load");
521                         i = ia[-1];
522                         p ("error: exception not thrown");
523                         }       
524                 catch (ArrayIndexOutOfBoundsException c) {
525                         p ("exception: out of bounds: "+(-1));
526                         }
527
528                 for (i=0; i<10; i++) ia[i] = (123456 + i);
529                 for (i=0; i<10; i++) p (ia[i]);
530
531                 
532
533                 p ("-------- test long arrays");                
534
535                 long[] la = null;
536
537                 try {
538                         p ("null pointer check: long array store");
539                         la[1] = 0;
540                         p ("error: null pointer exception not thrown");
541                         }       
542                 catch (NullPointerException c) {
543                         p ("exception: null pointer");
544                         }
545                 try {
546                         p ("null pointer check: long array load");
547                         l = la[1];
548                         p ("error: null pointer exception not thrown");
549                         }       
550                 catch (NullPointerException c) {
551                         p ("exception: null pointer");
552                         }
553
554                 la = new long [10];
555
556                 try {
557                         p ("array bound check: long array store");
558                         la[-1] = 0;
559                         p ("error: exception not thrown");
560                         }       
561                 catch (ArrayIndexOutOfBoundsException c) {
562                         p ("exception: out of bounds: "+(-1));
563                         }
564                 try {
565                         p ("array bound check: long array load");
566                         l = la[-1];
567                         p ("error: exception not thrown");
568                         }       
569                 catch (ArrayIndexOutOfBoundsException c) {
570                         p ("exception: out of bounds: "+(-1));
571                         }
572
573                 for (i=0; i<10; i++) la[i] = (1234567890123L + i);
574                 for (i=0; i<10; i++) p (la[i]);
575
576                 
577                 p ("-------- test char arrays");                
578
579                 char[] ca = null;
580
581                 try {
582                         p ("null pointer check: char array store");
583                         ca[1] = 0;
584                         p ("error: null pointer exception not thrown");
585                         }       
586                 catch (NullPointerException c) {
587                         p ("exception: null pointer");
588                         }
589                 try {
590                         p ("null pointer check: char array load");
591                         i = ca[1];
592                         p ("error: null pointer exception not thrown");
593                         }       
594                 catch (NullPointerException c) {
595                         p ("exception: null pointer");
596                         }
597
598                 ca = new char [50];
599
600                 try {
601                         p ("array bound check: char array store");
602                         ca[-1] = 0;
603                         p ("error: exception not thrown");
604                         }       
605                 catch (ArrayIndexOutOfBoundsException c) {
606                         p ("exception: out of bounds: "+(-1));
607                         }
608                 try {
609                         p ("array bound check: char array load");
610                         i = ca[-1];
611                         p ("error: exception not thrown");
612                         }       
613                 catch (ArrayIndexOutOfBoundsException c) {
614                         p ("exception: out of bounds: "+(-1));
615                         }
616
617                 for (i=0; i<50; i++) ca[i] = (char) ('A' + i);
618                 for (i=0; i<50; i++) p (ca[i]);
619
620                 p ("-------- test address arrays");
621
622                 String[] sta = null;
623
624                 try {
625                         p ("null pointer check: address array store");
626                         sta[1] = null;
627                         p ("error: null pointer exception not thrown");
628                         }       
629                 catch (NullPointerException c) {
630                         p ("exception: null pointer");
631                         }
632                 try {
633                         p ("null pointer check: address array load");
634                         s = sta[1];
635                         p ("error: null pointer exception not thrown");
636                         }       
637                 catch (NullPointerException c) {
638                         p ("exception: null pointer");
639                         }
640
641                 try {
642                         p ("negative array size check: address array");
643                         sta = new String[-3];
644                         p ("error: negative array size exception not thrown");
645                         }       
646                 catch (NegativeArraySizeException c) {
647                         p ("exception: negative array size");
648                         }
649
650                 sta = new String[5];
651
652                 try {
653                         p ("array bound check: address array store");
654                         sta[-1] = null;
655                         p ("error: exception not thrown");
656                         }       
657                 catch (ArrayIndexOutOfBoundsException c) {
658                         p ("exception: out of bounds: "+(-1));
659                         }
660                 try {
661                         p ("array bound check: address array load");
662                         s = sta[-1];
663                         p ("error: exception not thrown");
664                         }       
665                 catch (ArrayIndexOutOfBoundsException c) {
666                         p ("exception: out of bounds: "+(-1));
667                         }
668
669                 for (i=0; i<5; i++) sta[i] = Integer.toString(i) + ". Zeile";
670                 for (i=0; i<5; i++) p (sta[i]);
671                 
672                 p ("-------- test multi dimensional arrays");
673
674                 int [][][] iaaa = null;
675
676                 try {
677                         p ("negative array size check: multi dimensional array");
678                         iaaa = new int[2][3][-4];
679                         p ("error: negative array size exception not thrown");
680                         }       
681                 catch (NegativeArraySizeException c) {
682                         p ("exception: negative array size");
683                         }
684
685                 iaaa = new int[2][3][4];
686                 long [][][] laaa = new long[2][3][6];
687                 float [][][] faaa = new float[2][3][4];
688                 double [][][] daaa = new double[3][4][7];
689                 for (i=0; i<2; i++) {
690                         int i2; for (i2=0; i2<3; i2++) {
691                                 int i3; for (i3=0; i3<4; i3++) {
692                                         iaaa[i][i2][i3] = i*i*i + i2*i2 + i3;
693                                         laaa[i][i2][i3] = i*i*i + i2*i2 + i3 + 7;
694                                         faaa[i][i2][i3] = i*i*i + i2*i2 + i3 + 0.4F;
695                                         daaa[i][i2][i3] = i*i*i + i2*i2 + i3 - 47.0001;
696                                         p (iaaa[i][i2][i3]);
697                                         p (laaa[i][i2][i3]);
698                                         p (faaa[i][i2][i3]);
699                                         p (daaa[i][i2][i3]);
700                                         }
701                                 }
702                         }
703
704
705                                         
706                 }
707
708
709         static public void testconst(int i, long l) {
710                 p ("TESTCONST CALLED WITH ", i);
711                 p ("                  AND ", l);
712                 
713                 if (!(i == (0))) p("not IF_ICMPEQ", (0));
714                 if (!(i != (0))) p("not IF_ICMPNE", (0));
715                 if (!(i <  (0))) p("not IF_ICMPLT", (0));
716                 if (!(i <= (0))) p("not IF_ICMPLE", (0));
717                 if (!(i >  (0))) p("not IF_ICMPGT", (0));
718                 if (!(i >= (0))) p("not IF_ICMPGE", (0));
719
720                 if (!(l == (0))) p("not IF_LCMPEQ", (0));
721                 if (!(l != (0))) p("not IF_LCMPNE", (0));
722                 if (!(l <  (0))) p("not IF_LCMPLT", (0));
723                 if (!(l <= (0))) p("not IF_LCMPLE", (0));
724                 if (!(l >  (0))) p("not IF_LCMPGT", (0));
725                 if (!(l >= (0))) p("not IF_LCMPGE", (0));
726
727                 p("IADDCONST:  ", i  +  (-1));
728                 p("ISUBCONST:  ", i  -  (-1));
729                 p("IMULCONST:  ", i  *  (-1));
730                 p("ISHLCONST:  ", i <<  (-1));
731                 p("ISHRCONST:  ", i >>  (-1));
732                 p("IUSHRCONST: ", i >>> (-1));
733                 p("IANDCONST:  ", i  &  (-1));
734                 p("IORCONST:   ", i  |  (-1));
735                 p("IXORCONST:  ", i  ^  (-1));
736
737                 if (!(i == (-1))) p("not IF_ICMPEQ", (-1));
738                 if (!(i != (-1))) p("not IF_ICMPNE", (-1));
739                 if (!(i <  (-1))) p("not IF_ICMPLT", (-1));
740                 if (!(i <= (-1))) p("not IF_ICMPLE", (-1));
741                 if (!(i >  (-1))) p("not IF_ICMPGT", (-1));
742                 if (!(i >= (-1))) p("not IF_ICMPGE", (-1));
743
744                 p("LADDCONST:  ", l  +  (-1));
745                 p("LSUBCONST:  ", l  -  (-1));
746                 p("LMULCONST:  ", l  *  (-1));
747                 p("LSHLCONST:  ", l <<  (-1));
748                 p("LSHRCONST:  ", l >>  (-1));
749                 p("LUSHRCONST: ", l >>> (-1));
750                 p("LANDCONST:  ", l  &  (-1));
751                 p("LORCONST:   ", l  |  (-1));
752                 p("LXORCONST:  ", l  ^  (-1));
753
754                 if (!(l == (-1))) p("not IF_LCMPEQ", (-1));
755                 if (!(l != (-1))) p("not IF_LCMPNE", (-1));
756                 if (!(l <  (-1))) p("not IF_LCMPLT", (-1));
757                 if (!(l <= (-1))) p("not IF_LCMPLE", (-1));
758                 if (!(l >  (-1))) p("not IF_LCMPGT", (-1));
759                 if (!(l >= (-1))) p("not IF_LCMPGE", (-1));
760
761                 p("IADDCONST:  ", i  +  (1));
762                 p("ISUBCONST:  ", i  -  (1));
763                 p("IMULCONST:  ", i  *  (1));
764                 p("ISHLCONST:  ", i <<  (1));
765                 p("ISHRCONST:  ", i >>  (1));
766                 p("IUSHRCONST: ", i >>> (1));
767                 p("IANDCONST:  ", i  &  (1));
768                 p("IORCONST:   ", i  |  (1));
769                 p("IXORCONST:  ", i  ^  (1));
770
771                 if (!(i == (1))) p("not IF_ICMPEQ", (1));
772                 if (!(i != (1))) p("not IF_ICMPNE", (1));
773                 if (!(i <  (1))) p("not IF_ICMPLT", (1));
774                 if (!(i <= (1))) p("not IF_ICMPLE", (1));
775                 if (!(i >  (1))) p("not IF_ICMPGT", (1));
776                 if (!(i >= (1))) p("not IF_ICMPGE", (1));
777
778                 p("LADDCONST:  ", l  +  (1));
779                 p("LSUBCONST:  ", l  -  (1));
780                 p("LMULCONST:  ", l  *  (1));
781                 p("LSHLCONST:  ", l <<  (1));
782                 p("LSHRCONST:  ", l >>  (1));
783                 p("LUSHRCONST: ", l >>> (1));
784                 p("LANDCONST:  ", l  &  (1));
785                 p("LORCONST:   ", l  |  (1));
786                 p("LXORCONST:  ", l  ^  (1));
787
788                 if (!(l == (1))) p("not IF_LCMPEQ", (1));
789                 if (!(l != (1))) p("not IF_LCMPNE", (1));
790                 if (!(l <  (1))) p("not IF_LCMPLT", (1));
791                 if (!(l <= (1))) p("not IF_LCMPLE", (1));
792                 if (!(l >  (1))) p("not IF_LCMPGT", (1));
793                 if (!(l >= (1))) p("not IF_LCMPGE", (1));
794
795                 p("IADDCONST:  ", i  +  (255));
796                 p("ISUBCONST:  ", i  -  (255));
797                 p("IMULCONST:  ", i  *  (255));
798                 p("ISHLCONST:  ", i <<  (255));
799                 p("ISHRCONST:  ", i >>  (255));
800                 p("IUSHRCONST: ", i >>> (255));
801                 p("IANDCONST:  ", i  &  (255));
802                 p("IORCONST:   ", i  |  (255));
803                 p("IXORCONST:  ", i  ^  (255));
804
805                 if (!(i == (255))) p("not IF_ICMPEQ", (255));
806                 if (!(i != (255))) p("not IF_ICMPNE", (255));
807                 if (!(i <  (255))) p("not IF_ICMPLT", (255));
808                 if (!(i <= (255))) p("not IF_ICMPLE", (255));
809                 if (!(i >  (255))) p("not IF_ICMPGT", (255));
810                 if (!(i >= (255))) p("not IF_ICMPGE", (255));
811
812                 p("LADDCONST:  ", l  +  (255));
813                 p("LSUBCONST:  ", l  -  (255));
814                 p("LMULCONST:  ", l  *  (255));
815                 p("LSHLCONST:  ", l <<  (255));
816                 p("LSHRCONST:  ", l >>  (255));
817                 p("LUSHRCONST: ", l >>> (255));
818                 p("LANDCONST:  ", l  &  (255));
819                 p("LORCONST:   ", l  |  (255));
820                 p("LXORCONST:  ", l  ^  (255));
821
822                 if (!(l == (255))) p("not IF_LCMPEQ", (255));
823                 if (!(l != (255))) p("not IF_LCMPNE", (255));
824                 if (!(l <  (255))) p("not IF_LCMPLT", (255));
825                 if (!(l <= (255))) p("not IF_LCMPLE", (255));
826                 if (!(l >  (255))) p("not IF_LCMPGT", (255));
827                 if (!(l >= (255))) p("not IF_LCMPGE", (255));
828
829                 p("IADDCONST:  ", i  +  (256));
830                 p("ISUBCONST:  ", i  -  (256));
831                 p("IMULCONST:  ", i  *  (256));
832                 p("ISHLCONST:  ", i <<  (256));
833                 p("ISHRCONST:  ", i >>  (256));
834                 p("IUSHRCONST: ", i >>> (256));
835                 p("IANDCONST:  ", i  &  (256));
836                 p("IORCONST:   ", i  |  (256));
837                 p("IXORCONST:  ", i  ^  (256));
838
839                 if (!(i == (256))) p("not IF_ICMPEQ", (256));
840                 if (!(i != (256))) p("not IF_ICMPNE", (256));
841                 if (!(i <  (256))) p("not IF_ICMPLT", (256));
842                 if (!(i <= (256))) p("not IF_ICMPLE", (256));
843                 if (!(i >  (256))) p("not IF_ICMPGT", (256));
844                 if (!(i >= (256))) p("not IF_ICMPGE", (256));
845
846                 p("LADDCONST:  ", l  +  (256));
847                 p("LSUBCONST:  ", l  -  (256));
848                 p("LMULCONST:  ", l  *  (256));
849                 p("LSHLCONST:  ", l <<  (256));
850                 p("LSHRCONST:  ", l >>  (256));
851                 p("LUSHRCONST: ", l >>> (256));
852                 p("LANDCONST:  ", l  &  (256));
853                 p("LORCONST:   ", l  |  (256));
854                 p("LXORCONST:  ", l  ^  (256));
855
856                 if (!(l == (256))) p("not IF_LCMPEQ", (256));
857                 if (!(l != (256))) p("not IF_LCMPNE", (256));
858                 if (!(l <  (256))) p("not IF_LCMPLT", (256));
859                 if (!(l <= (256))) p("not IF_LCMPLE", (256));
860                 if (!(l >  (256))) p("not IF_LCMPGT", (256));
861                 if (!(l >= (256))) p("not IF_LCMPGE", (256));
862
863                 p("IADDCONST:  ", i  +  (32767));
864                 p("ISUBCONST:  ", i  -  (32767));
865                 p("IMULCONST:  ", i  *  (32767));
866                 p("ISHLCONST:  ", i <<  (32767));
867                 p("ISHRCONST:  ", i >>  (32767));
868                 p("IUSHRCONST: ", i >>> (32767));
869                 p("IANDCONST:  ", i  &  (32767));
870                 p("IORCONST:   ", i  |  (32767));
871                 p("IXORCONST:  ", i  ^  (32767));
872
873                 if (!(i == (32767))) p("not IF_ICMPEQ", (32767));
874                 if (!(i != (32767))) p("not IF_ICMPNE", (32767));
875                 if (!(i <  (32767))) p("not IF_ICMPLT", (32767));
876                 if (!(i <= (32767))) p("not IF_ICMPLE", (32767));
877                 if (!(i >  (32767))) p("not IF_ICMPGT", (32767));
878                 if (!(i >= (32767))) p("not IF_ICMPGE", (32767));
879
880                 p("LADDCONST:  ", l  +  (32767));
881                 p("LSUBCONST:  ", l  -  (32767));
882                 p("LMULCONST:  ", l  *  (32767));
883                 p("LSHLCONST:  ", l <<  (32767));
884                 p("LSHRCONST:  ", l >>  (32767));
885                 p("LUSHRCONST: ", l >>> (32767));
886                 p("LANDCONST:  ", l  &  (32767));
887                 p("LORCONST:   ", l  |  (32767));
888                 p("LXORCONST:  ", l  ^  (32767));
889
890                 if (!(l == (32767))) p("not IF_LCMPEQ", (32767));
891                 if (!(l != (32767))) p("not IF_LCMPNE", (32767));
892                 if (!(l <  (32767))) p("not IF_LCMPLT", (32767));
893                 if (!(l <= (32767))) p("not IF_LCMPLE", (32767));
894                 if (!(l >  (32767))) p("not IF_LCMPGT", (32767));
895                 if (!(l >= (32767))) p("not IF_LCMPGE", (32767));
896
897                 p("IADDCONST:  ", i  +  (32768));
898                 p("ISUBCONST:  ", i  -  (32768));
899                 p("IMULCONST:  ", i  *  (32768));
900                 p("ISHLCONST:  ", i <<  (32768));
901                 p("ISHRCONST:  ", i >>  (32768));
902                 p("IUSHRCONST: ", i >>> (32768));
903                 p("IANDCONST:  ", i  &  (32768));
904                 p("IORCONST:   ", i  |  (32768));
905                 p("IXORCONST:  ", i  ^  (32768));
906
907                 if (!(i == (32768))) p("not IF_ICMPEQ", (32768));
908                 if (!(i != (32768))) p("not IF_ICMPNE", (32768));
909                 if (!(i <  (32768))) p("not IF_ICMPLT", (32768));
910                 if (!(i <= (32768))) p("not IF_ICMPLE", (32768));
911                 if (!(i >  (32768))) p("not IF_ICMPGT", (32768));
912                 if (!(i >= (32768))) p("not IF_ICMPGE", (32768));
913
914                 p("LADDCONST:  ", l  +  (32768));
915                 p("LSUBCONST:  ", l  -  (32768));
916                 p("LMULCONST:  ", l  *  (32768));
917                 p("LSHLCONST:  ", l <<  (32768));
918                 p("LSHRCONST:  ", l >>  (32768));
919                 p("LUSHRCONST: ", l >>> (32768));
920                 p("LANDCONST:  ", l  &  (32768));
921                 p("LORCONST:   ", l  |  (32768));
922                 p("LXORCONST:  ", l  ^  (32768));
923
924                 if (!(l == (32768))) p("not IF_LCMPEQ", (32768));
925                 if (!(l != (32768))) p("not IF_LCMPNE", (32768));
926                 if (!(l <  (32768))) p("not IF_LCMPLT", (32768));
927                 if (!(l <= (32768))) p("not IF_LCMPLE", (32768));
928                 if (!(l >  (32768))) p("not IF_LCMPGT", (32768));
929                 if (!(l >= (32768))) p("not IF_LCMPGE", (32768));
930
931                 p("IADDCONST:  ", i  +  (-32768));
932                 p("ISUBCONST:  ", i  -  (-32768));
933                 p("IMULCONST:  ", i  *  (-32768));
934                 p("ISHLCONST:  ", i <<  (-32768));
935                 p("ISHRCONST:  ", i >>  (-32768));
936                 p("IUSHRCONST: ", i >>> (-32768));
937                 p("IANDCONST:  ", i  &  (-32768));
938                 p("IORCONST:   ", i  |  (-32768));
939                 p("IXORCONST:  ", i  ^  (-32768));
940
941                 if (!(i == (-32768))) p("not IF_ICMPEQ", (-32768));
942                 if (!(i != (-32768))) p("not IF_ICMPNE", (-32768));
943                 if (!(i <  (-32768))) p("not IF_ICMPLT", (-32768));
944                 if (!(i <= (-32768))) p("not IF_ICMPLE", (-32768));
945                 if (!(i >  (-32768))) p("not IF_ICMPGT", (-32768));
946                 if (!(i >= (-32768))) p("not IF_ICMPGE", (-32768));
947
948                 p("LADDCONST:  ", l  +  (-32768));
949                 p("LSUBCONST:  ", l  -  (-32768));
950                 p("LMULCONST:  ", l  *  (-32768));
951                 p("LSHLCONST:  ", l <<  (-32768));
952                 p("LSHRCONST:  ", l >>  (-32768));
953                 p("LUSHRCONST: ", l >>> (-32768));
954                 p("LANDCONST:  ", l  &  (-32768));
955                 p("LORCONST:   ", l  |  (-32768));
956                 p("LXORCONST:  ", l  ^  (-32768));
957
958                 if (!(l == (-32768))) p("not IF_LCMPEQ", (-32768));
959                 if (!(l != (-32768))) p("not IF_LCMPNE", (-32768));
960                 if (!(l <  (-32768))) p("not IF_LCMPLT", (-32768));
961                 if (!(l <= (-32768))) p("not IF_LCMPLE", (-32768));
962                 if (!(l >  (-32768))) p("not IF_LCMPGT", (-32768));
963                 if (!(l >= (-32768))) p("not IF_LCMPGE", (-32768));
964
965                 p("IADDCONST:  ", i  +  (-32769));
966                 p("ISUBCONST:  ", i  -  (-32769));
967                 p("IMULCONST:  ", i  *  (-32769));
968                 p("ISHLCONST:  ", i <<  (-32769));
969                 p("ISHRCONST:  ", i >>  (-32769));
970                 p("IUSHRCONST: ", i >>> (-32769));
971                 p("IANDCONST:  ", i  &  (-32769));
972                 p("IORCONST:   ", i  |  (-32769));
973                 p("IXORCONST:  ", i  ^  (-32769));
974
975                 if (!(i == (-32769))) p("not IF_ICMPEQ", (-32769));
976                 if (!(i != (-32769))) p("not IF_ICMPNE", (-32769));
977                 if (!(i <  (-32769))) p("not IF_ICMPLT", (-32769));
978                 if (!(i <= (-32769))) p("not IF_ICMPLE", (-32769));
979                 if (!(i >  (-32769))) p("not IF_ICMPGT", (-32769));
980                 if (!(i >= (-32769))) p("not IF_ICMPGE", (-32769));
981
982                 p("LADDCONST:  ", l  +  (-32769));
983                 p("LSUBCONST:  ", l  -  (-32769));
984                 p("LMULCONST:  ", l  *  (-32769));
985                 p("LSHLCONST:  ", l <<  (-32769));
986                 p("LSHRCONST:  ", l >>  (-32769));
987                 p("LUSHRCONST: ", l >>> (-32769));
988                 p("LANDCONST:  ", l  &  (-32769));
989                 p("LORCONST:   ", l  |  (-32769));
990                 p("LXORCONST:  ", l  ^  (-32769));
991
992                 if (!(l == (-32769))) p("not IF_LCMPEQ", (-32769));
993                 if (!(l != (-32769))) p("not IF_LCMPNE", (-32769));
994                 if (!(l <  (-32769))) p("not IF_LCMPLT", (-32769));
995                 if (!(l <= (-32769))) p("not IF_LCMPLE", (-32769));
996                 if (!(l >  (-32769))) p("not IF_LCMPGT", (-32769));
997                 if (!(l >= (-32769))) p("not IF_LCMPGE", (-32769));
998         }
999
1000         static public void testint(int a, int b) {
1001                 p ("TESTINT CALLED WITH ", a);
1002                 p ("                AND ", b);
1003                 
1004                 p("IADD:  ", a+b);
1005                 p("ISUB:  ", a-b);
1006                 p("IMUL:  ", a*b);
1007                 try { p("IDIV:  ", a/b); } 
1008                 catch (ArithmeticException e) { p("divison by zero"); }
1009                 try { p("IREM:  ", a%b); } 
1010                 catch (ArithmeticException e) { p("divison by zero"); }
1011                 p("INEG:  ", -a);
1012                 p("ISHL:  ", a<<b);
1013                 p("ISHR:  ", a>>b);
1014                 p("IUSHR: ", a>>>b);
1015                 p("IAND:  ", a & b);
1016                 p("IOR:   ", a | b);
1017                 p("IXOR:  ", a ^ b);
1018
1019                 p("I2L:   ", (long) a);
1020                 p("I2F:   ", (float) a);
1021                 p("I2D:   ", (double) a);
1022                 p("INT2BYTE: ", (byte) a);      
1023                 p("INT2CHAR: ", (char) a);      
1024                 p("INT2SHORT: ", (short) a);    
1025
1026                 if (!(a==0)) p("not IFEQ");
1027                 if (!(a!=0)) p("not IFNE");
1028                 if (!(a<0))  p("not IFLT");
1029                 if (!(a<=0)) p("not IFLE");
1030                 if (!(a>0))  p("not IFGT");
1031                 if (!(a>=0)) p("not IFGE");
1032
1033                 if (!(a==b)) p("not IF_ICMPEQ");
1034                 if (!(a!=b)) p("not IF_ICMPNE");
1035                 if (!(a<b))  p("not IF_ICMPLT");
1036                 if (!(a<=b)) p("not IF_ICMPLE");
1037                 if (!(a>b))  p("not IF_ICMPGT");
1038                 if (!(a>=b)) p("not IF_ICMPGE");
1039                 
1040         }
1041
1042         static public void testlong(long a, long b) {
1043                 p ("TESTLONG called with ", a);
1044                 p ("                 AND ", b);
1045                 
1046                 p("LADD:  ", a + b);
1047                 p("LSUB:  ", a - b);
1048                 p("LMUL:  ", a * b);
1049                 try { p("LDIV:  ", a / b); } 
1050                 catch (ArithmeticException e) { p("divison by zero"); }
1051                 try { p("LREM:  ", a % b); } 
1052                 catch (ArithmeticException e) { p("divison by zero"); }
1053                 p("LNEG:  ", -a);
1054                 p("LSHL:  ", a << b);
1055                 p("LSHR:  ", a >> b);
1056                 p("LUSHR: ", a >>>b);
1057                 p("LAND:  ", a &  b);
1058                 p("LOR:   ", a |  b);
1059                 p("LXOR:  ", a ^  b);
1060
1061                 p("L2I:   ", (int) a);
1062                 p("L2F:   ", (float) a);
1063                 p("L2D:   ", (double) a);
1064
1065                 p("LCMP a == b : ", a == b);
1066                 p("LCMP a != b : ", a != b);
1067                 p("LCMP a <  b : ", a <  b);
1068                 p("LCMP a <= b : ", a <= b);
1069                 p("LCMP a >  b : ", a >  b);
1070                 p("LCMP a >= b : ", a >= b);
1071
1072                 if ((a==b)) p("not IF_LCMPEQ");
1073                 if ((a!=b)) p("not IF_LCMPNE");
1074                 if ((a<b))  p("not IF_LCMPLT");
1075                 if ((a<=b)) p("not IF_LCMPLE");
1076                 if ((a>b))  p("not IF_LCMPGT");
1077                 if ((a>=b)) p("not IF_LCMPGE");
1078         }
1079
1080         static public void testfloat(float a, float b) {
1081                 p ("TESTFLOAT called with ", a);
1082                 p ("                  AND ", b);
1083                 
1084                 p("FADD:  ", a+b);
1085                 p("FSUB:  ", a-b);
1086                 p("FMUL:  ", a*b);
1087                 p("FDIV:  ", a/b); 
1088                 p("FREM:  ", a%b);
1089                 
1090                 p("F2I:   ", (int) a);
1091                 p("F2L:   ", (long) a);
1092                 p("F2D:   ", (double) a);
1093
1094                 if ((a==b)) p("FCMP a=b");
1095                 if ((a!=b)) p("FCMP a!=b");
1096                 if ((a<b))  p("FCMP a<b");
1097                 if ((a<=b)) p("FCMP a<=b");
1098                 if ((a>b))  p("FCMP a>b");
1099                 if ((a>=b)) p("FCMP a>=b");
1100         }
1101
1102         static public void testdouble(double a, double b) {
1103                 p ("TESTDOUBLE called with ", a);
1104                 p ("                   AND ", b);
1105                 
1106                 p("DADD:  ", a+b);
1107                 p("DSUB:  ", a-b);
1108                 p("DMUL:  ", a*b);
1109                 p("DDIV:  ", a/b); 
1110                 p("DREM:  ", a%b);
1111                 
1112                 p("D2I:   ", (int) a);
1113                 p("D2L:   ", (long) a);
1114                 p("D2F:   ", (float) a);
1115
1116                 if ((a==b)) p("DCMP a=b");
1117                 if ((a!=b)) p("DCMP a!=b");
1118                 if ((a<b))  p("DCMP a<b");
1119                 if ((a<=b)) p("DCMP a<=b");
1120                 if ((a>b))  p("DCMP a>b");
1121                 if ((a>=b)) p("DCMP a>=b");
1122         }
1123
1124
1125         // ********************* output methods ****************************
1126         
1127         public static int linenum = 0;
1128         public static void pnl() {
1129                 System.out.println ();
1130                 System.out.print (linenum);
1131                 System.out.print (".    ");
1132                 linenum++;
1133                 }
1134
1135         public static void p(String a) { System.out.print(a); pnl(); }
1136         public static void p(boolean a) {System.out.print(a); 
1137                                       pnl();  }
1138         public static void p(int a) { System.out.print ("int: ");
1139                                       System.out.print(a); 
1140                                       pnl();  }
1141         public static void p(long a) { System.out.print ("long: ");
1142                                        System.out.print(a); 
1143                                        pnl(); }
1144         public static void p(short a) { System.out.print ("short: ");
1145                                        System.out.print(a); 
1146                                        pnl(); }
1147         public static void p(byte a) { System.out.print ("byte: ");
1148                                        System.out.print(a); 
1149                                        pnl(); }
1150         public static void p(char a) { System.out.print ("char: ");
1151                                        System.out.print((int)a); 
1152                                        pnl(); }
1153         public static void p(float a) { System.out.print ("float: ");
1154                                         System.out.print ( java.lang.Float.floatToIntBits(a) ); 
1155                                         pnl(); }
1156         public static void p(double a) { System.out.print ("double: ");
1157                                          System.out.print( java.lang.Double.doubleToLongBits(a) ); 
1158                                          pnl(); }
1159
1160         public static void p(String s,boolean i) { 
1161                 System.out.print(s); p(i);
1162                 }
1163         public static void p(String s,int i) { 
1164                 System.out.print(s); p(i);
1165                 }
1166         public static void p(String s,byte i) { 
1167                 System.out.print(s); p(i);
1168                 }
1169         public static void p(String s,char i) { 
1170                 System.out.print(s); p(i);
1171                 }
1172         public static void p(String s,short i) { 
1173                 System.out.print(s); p(i);
1174                 }
1175         public static void p(String s,long l) { 
1176                 System.out.print(s); p(l);
1177                 }
1178         public static void p(String s,float f) { 
1179                 System.out.print(s); p(f);
1180                 }
1181         public static void p(String s,double d) {
1182                 System.out.print(s); p(d);
1183                 }
1184
1185
1186
1187
1188         // methods for testing interface and method calls
1189
1190         public void jctest() { p (" <init> wird aktiviert"); };
1191         public void p_manyparam (int p_i1,int p_i2,
1192                                  int p_i3, int p_i4, 
1193                                  long p_l1,long p_l2,
1194                                  long p_l3,long p_l4, 
1195                                  float p_f1, float p_f2, 
1196                                  float p_f3, float p_f4,
1197                                  double p_d1, double p_d2,
1198                                  double p_d3, double p_d4) {
1199                 n_i1 = p_i1;
1200                 n_i2 = p_i2;
1201                 n_i3 = p_i3;
1202                 n_i4 = p_i4;
1203                 n_l1 = p_l1;
1204                 n_l2 = p_l2;
1205                 n_l3 = p_l3;
1206                 n_l4 = p_l4;
1207                 n_f1 = p_f1;
1208                 n_f2 = p_f2;
1209                 n_f3 = p_f3;
1210                 n_f4 = p_f4;
1211                 n_d1 = p_d1;
1212                 n_d2 = p_d2;
1213                 n_d3 = p_d3;
1214                 n_d4 = p_d4;
1215                 }
1216                 
1217         public void p_nonstatic (String a) { 
1218                 p(a); 
1219                 p(n_i1);
1220                 p(n_i2);
1221                 p(n_i3);
1222                 p(n_i4);
1223                 p(n_l1);
1224                 p(n_l2);
1225                 p(n_l3);
1226                 p(n_l4);
1227                 p(n_f1);
1228                 p(n_f2);
1229                 p(n_f3);
1230                 p(n_f4);
1231                 p(n_d1);
1232                 p(n_d2);
1233                 p(n_d3);
1234                 p(n_d4);
1235                 
1236                 }
1237
1238         }
1239         
1240         
1241 interface jcinterface { 
1242         public void p_nonstatic (String a);
1243         }
1244         
1245