narray first check in
[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                 testconst (0x80000000, 0x8000000000000000L);
57
58                 p ("------------------- test div and rem consts");
59                 testdivremconst(17);
60                 testdivremconst(12347);
61                 testdivremconst(8893427);
62                 testdivremconst(1005234562);
63                 testdivremconst(-17);
64                 testdivremconst(-12347);
65                 testdivremconst(-8893427);
66                 testdivremconst(-1005234562);
67
68                 testdivremconst(17L);
69                 testdivremconst(12347L);
70                 testdivremconst(8893427L);
71                 testdivremconst(1005234562L);
72                 testdivremconst(12135005234562L);
73                 testdivremconst(2343552355623464626L);
74                 testdivremconst(-17L);
75                 testdivremconst(-12347L);
76                 testdivremconst(-8893427L);
77                 testdivremconst(-1005234562L);
78                 testdivremconst(-12135005234562L);
79                 testdivremconst(-2343552355623464626L);
80
81                 p ("------------------- test rem 0x10001");
82                 testrem0x10001(0);
83                 testrem0x10001(1);
84                 testrem0x10001(17);
85                 testrem0x10001(123);
86                 testrem0x10001(1234);
87                 testrem0x10001(13247);
88                 testrem0x10001(563467);
89                 testrem0x10001(7456774);
90                 testrem0x10001(34523525);
91                 testrem0x10001(234523456);
92                 testrem0x10001(1005234562);
93                 testrem0x10001(2147483647);
94                 testrem0x10001(-1);
95                 testrem0x10001(-17);
96                 testrem0x10001(-123);
97                 testrem0x10001(-1234);
98                 testrem0x10001(-13247);
99                 testrem0x10001(-563467);
100                 testrem0x10001(-7456774);
101                 testrem0x10001(-34523525);
102                 testrem0x10001(-234523456);
103                 testrem0x10001(-1005234562);
104                 testrem0x10001(-2147483647);
105                 testrem0x10001(-2147483648);
106
107                 testrem0x10001(0L);
108                 testrem0x10001(1L);
109                 testrem0x10001(17L);
110                 testrem0x10001(123L);
111                 testrem0x10001(1234L);
112                 testrem0x10001(13247L);
113                 testrem0x10001(563467L);
114                 testrem0x10001(7456774L);
115                 testrem0x10001(34523525L);
116                 testrem0x10001(234523456L);
117                 testrem0x10001(1005234562L);
118                 testrem0x10001(1983223864L);
119                 testrem0x10001(2147483646L);
120                 testrem0x10001(2147483647L);
121                 testrem0x10001(2147483648L);
122                 testrem0x10001(10052234562L);
123                 testrem0x10001(561005234562L);
124                 testrem0x10001(2100527345962L);
125                 testrem0x10001(34600523456287L);
126                 testrem0x10001(546805234456882L);
127                 testrem0x10001(1360052334734722L);
128                 testrem0x10001(23456705569626354L);
129                 testrem0x10001(9223372036854775807L);
130                 testrem0x10001(-1L);
131                 testrem0x10001(-17L);
132                 testrem0x10001(-123L);
133                 testrem0x10001(-1234L);
134                 testrem0x10001(-13247L);
135                 testrem0x10001(-563467L);
136                 testrem0x10001(-7456774L);
137                 testrem0x10001(-34523525L);
138                 testrem0x10001(-234523456L);
139                 testrem0x10001(-1005234562L);
140                 testrem0x10001(-1983223864L);
141                 testrem0x10001(-2147483647L);
142                 testrem0x10001(-2147483648L);
143                 testrem0x10001(-10052234562L);
144                 testrem0x10001(-561005234562L);
145                 testrem0x10001(-2100527345962L);
146                 testrem0x10001(-34600523456287L);
147                 testrem0x10001(-546805234456882L);
148                 testrem0x10001(-1360052334734722L);
149                 testrem0x10001(-23456705569626354L);
150                 testrem0x10001(-9223372036854775807L);
151                 testrem0x10001(-9223372036854775808L);
152
153                 p ("------------------- test ints");
154                 testint (1,2);
155                 testint (-1,17);
156                 testint (-24351,24123);
157                 testint (4918923,-441423);
158                 testint (0,0);
159                 testint (-1,-1);
160                 testint (1423487,123444444);
161                 testint (0x7fffffff,1);
162                 testint (0,0x7fffffff);
163                 testint (0x3333,143444);
164                 testint (4444441,12342);
165
166                 p ("------------------- test longs");
167                 testlong (1,2);
168                 testlong (-1,17);
169                 testlong (-24351,24123);
170                 testlong (4918923241323L,-4423423234231423L);
171                 testlong (0,0);
172                 testlong (-1,-1);
173                 testlong (1423487,123444442344L);
174                 testlong (0x7fffffffffffffffL,1);
175                 testlong (0,0x7fffffffffffffffL);
176                 testlong (0x3333,143444);
177                 testlong (4444441,12342);
178
179                 p ("------------------- test floats");
180                 testfloat ((float) 1,(float) 2.042);
181                 testfloat ((float) -1.234,(float) 17.44);
182                 testfloat ((float) -24351,(float) 24123);
183                 testfloat ((float) 0.1,(float) 1243);
184                 testfloat ((float) 0.0,(float) -555.4132);
185                 testfloat ((float) 77.0,(float) -555);
186                 testfloat ((float) 2147483000.0,(float) -555234);
187
188                 p ("------------------- test doubles");
189                 testdouble (1,2.042);
190                 testdouble (-1.234,17.44);
191                 testdouble (-24351,24123);
192                 testdouble (0.1,1243);
193                 testdouble (0.0,-555.4132);
194                 testdouble (77.0,-555);
195                 testdouble (2147483000.0,-555234);
196                 
197
198                 p ("=================== end of test =========================");                        
199                 }
200
201
202         static /* init */ {
203                 p ("successful initialisation");
204                 }
205
206
207                 
208         public static void testgeneral() {
209                 
210                 int i;
211                 // ******************** basic data types *******************************
212                 
213                 p ("------------------- test int-PUSH-STORE-LOAD");
214                 int j = -1;
215                 p(j); p (0); p(2); p(17); p(-100); 
216                 p (500); p(-32768); p(-32769); p(32767); p(32768);
217                 p (90000); p(-1000000000);
218                 
219                 p ("------------------- test long-PUSH-STORE-LOAD");
220                 long l = 3L;
221                 p ( l ); p ( 0L ); p ( 99L );
222                 p (500L); p(-32768L); p(-32769L); p(32767L); p(32768L);
223                 p ( 6900000000000L ); p ( 349827389478173274L );
224
225                 p ("------------------- test float-PUSH-STORE-LOAD");
226                 float f = 99.444F;
227                 p ( f ); p (0.0F); p (1.0F); p (342323423478.2223434234232334F);
228         
229                 p ("------------------- test double-PUSH-STORE-LOAD");
230                 double d = 99234.42D;
231                 p ( d ); p (0.0D); p (1.0D); p (342323423478.2223434234232334D);
232
233
234                 // ******************** static variables *******************************
235
236                 p ("------------------- test static variables");        
237                 i1 = i1+i2+i3;
238                 l2 = l1+l2+l3;
239                 f1 = f1*f2;
240                 p (i1); p(i2); p(i3); 
241                 p (l1); p(l2); p(l3);
242                 p (f1); p(f2); p(f3);
243                 p (d1); p(d2); p(d3);
244
245                 // ******************** arithmetic test ********************************
246                 
247                 p ("------------------- test arithmetic");
248                 i1 = 17;
249                 i2 = 0x7fffffff;
250                 p (i2);
251                 p (i2+1);
252                 p (i1-i2);
253                 l1 = 0x7fffffffffffffffL;
254                 p (l1);
255                 p (l1+1);
256                 p (l1+0x7fffffffffffffffL);
257                 
258                 
259                 // ******************** test method calls ******************************
260                 
261                 p ("statische methode");
262                 jctest ttt = new jctest ();
263                 ttt.p_manyparam (19,18,17,16, 88,77,66,55, 
264                                  0.1F,0.2F,0.3F,0.4F, -2.0D,-3.0D,-4.0D,-5.0D );
265                 jcinterface ttt2 = ttt;
266                 ttt2.p_nonstatic ("interface method");
267
268                 }
269
270
271
272         // ************************ test tables ************************************
273                 
274         public static void testtables() {
275                 int i;
276
277                 p ("------------------- test tableswitch");
278
279                 for (i = -5; i < 15; i++) {
280                         switch (i) {
281                                 case  2:  p ("->  2"); break;   
282                                 case  3:  p ("->  3"); break;   
283                                 case  5:  p ("->  5"); break;   
284                                 case  6:  p ("->  6"); break;
285                                 case  7:  p ("->  7"); break;
286                                 case  8:  p ("->  8"); break;
287                                 case 10:  p ("-> 10"); break;
288                                 default:  p ("default"); break;
289                                 }
290                         }
291
292                 p ("------------------- test lookupswitch");
293
294                 for (i = -5; i < 15; i++) {
295                         switch (i) {
296                                 case  2:  p ("->  2"); break;
297                                 case  8:  p ("->  8"); break;
298                                 case 14:  p ("-> 14"); break;
299                                 case -4:  p ("-> -4"); break;
300                                 default:  p ("default"); break;
301                                 }
302                         }       
303                 }
304
305
306         // ****************** test type casts and array stores *********************            
307
308         public static void testcasts() {
309                 Object     o   = new Object();
310                 Object     oi  = new Integer(0);
311                 Object[]   oa  = new Object [1];
312                 Object[]   oia = new Integer[1];
313                 Integer    i   = new Integer(0);
314                 Integer[]  ia;
315                 java.io.DataOutput dataout = null;
316                 Object             od  = new java.io.DataOutputStream(
317                                              (java.io.DataOutputStream)dataout);
318
319                 p ("------------------- test casts");
320
321                 p("Integer is instanceof Object:  ", oi instanceof Object);
322                 p("Integer is instanceof Integer: ", oi instanceof Integer);
323                 p("Object is instanceof Integer:  ", o instanceof Integer);
324
325                 try {
326                         p ("type cast check: Integer = Object(Integer)");
327                         i = (Integer) oi;
328                         p ("type cast check: Integer = Object");
329                         i = (Integer) o;
330                         p ("error: class cast exception not thrown");
331                         }       
332                 catch (ClassCastException c) {
333                         p ("exception: class cast");
334                         }
335
336                 p("DataOutputStream is instanceof DataOutput: ",
337                                                       od instanceof java.io.DataOutput);
338                 p("Object is instanceof DataOutput: ", o instanceof java.io.DataOutput);
339
340                 try {
341                         p ("type cast check: DataOutput = Object(DataOutputStream)");
342                         dataout = (java.io.DataOutput) od;
343                         p ("type cast check: DataOutput = Object");
344                         dataout = (java.io.DataOutput) o;
345                         p ("error: class cast exception not thrown");
346                         }       
347                 catch (ClassCastException c) {
348                         p ("exception: class cast");
349                         }
350
351                 try {
352                         p ("type cast check: Integer[] = Object(Integer)[]");
353                         ia = (Integer[]) oia;
354                         p ("type cast check: Integer[] = Object[]");
355                         ia = (Integer[]) oa;
356                         p ("error: class cast exception not thrown");
357                         }       
358                 catch (ClassCastException c) {
359                         p ("exception: class cast");
360                         }
361
362                 try {
363                         p ("array store check: Object(Integer)[0] = Integer");
364                         oia[0] = i;
365                         p ("array store check: Object(Integer)[0] = Object");
366                         oia[0] = o;
367                         p ("error: array store exception not thrown");
368                         }       
369                 catch (ArrayStoreException c) {
370                         p ("exception: array store");
371                         }
372                 }
373
374
375         // ****************** test special null pointers ***************************            
376
377         public static void testspecialnullpointers() {
378                 int i = 0;
379                 jctest c = null;
380                 jcinterface f = null;
381
382                 p ("------------------- test special null pointers");
383
384                 try {
385                         p ("null pointer check: put field");
386                         c.n_i1 = 0;
387                         p ("error: put field null pointer exception not thrown");
388                         }       
389                 catch (NullPointerException x) {
390                         p ("exception: null pointer");
391                         }
392
393                 try {
394                         p ("null pointer check: get field");
395                         i = c.n_i1;
396                         p ("error: get field null pointer exception not thrown");
397                         }       
398                 catch (NullPointerException x) {
399                         p ("exception: null pointer");
400                         }
401
402                 try {
403                         p ("null pointer check: invokevirtual");
404                         c.p_nonstatic("invokevirtual");
405                         p ("error: invokevirtual null pointer exception not thrown");
406                         }       
407                 catch (NullPointerException x) {
408                         p ("exception: null pointer");
409                         }
410
411                 try {
412                         p ("null pointer check: invokeinterface");
413                         f.p_nonstatic("invokeinterface");
414                         p ("error: invokeinterface null pointer exception not thrown");
415                         }       
416                 catch (NullPointerException x) {
417                         p ("exception: null pointer");
418                         }
419
420                 try {
421                         p ("null pointer check: monitorenter");
422                         synchronized (c) {
423                                 p ("error: monitorenter null pointer exception not thrown");
424                                 }
425                         }       
426                 catch (NullPointerException x) {
427                         p ("exception: null pointer");
428                         }
429                 }
430
431
432         // ************************ test array bounds ******************************            
433
434         public static void testarraybounds(byte[] ba, int i) {
435                         p ("testarraybounds: " + (i - 10));
436                         ba[i-10] = 0;
437                         p ("testarraybounds: " + (i - 5));
438                         ba[i-5]  = 0;
439                         p ("testarraybounds: " + (i));
440                         ba[i]    = 0;
441                         p ("testarraybounds: " + (i + 5));
442                         ba[i+5]  = 0;
443                         p ("testarraybounds: " + (i + 10));
444                         ba[i+10] = 0; 
445                 }
446
447
448         // ************************ test arrays ************************************            
449
450         public static void testarrays() {
451                 int    i;
452                 long   l;
453                 float  f;
454                 double d;
455                 String s;
456                 
457                 p ("------------------- test byte arrays");
458
459                 byte[] ba = null;
460
461                 try {
462                         p ("null pointer check: byte array store");
463                         ba[1] = 0;
464                         p ("error: null pointer exception not thrown");
465                         }       
466                 catch (NullPointerException c) {
467                         p ("exception: null pointer");
468                         }
469                 try {
470                         p ("null pointer check: byte array load");
471                         i = ba[1];
472                         p ("error: null pointer exception not thrown");
473                         }       
474                 catch (NullPointerException c) {
475                         p ("exception: null pointer");
476                         }
477
478                 try {
479                         p ("negative array size check: byte array");
480                         ba = new byte [-2];
481                         p ("error: negative array size exception not thrown");
482                         }       
483                 catch (NegativeArraySizeException c) {
484                         p ("exception: negative array size");
485                         }
486
487                 ba = new byte [100];
488
489
490                 try {
491                         p ("array bound check: byte array store");
492                         ba[-1] = 0;
493                         p ("error: exception not thrown");
494                         }       
495                 catch (ArrayIndexOutOfBoundsException c) {
496                         p ("exception_1: out of bounds: "+(-1));
497                         }
498                 try {
499                         p ("array bound check: byte array load");
500                         i = ba[-1];
501                         p ("error: exception not thrown");
502                         }       
503                 catch (ArrayIndexOutOfBoundsException c) {
504                         p ("exception_2: out of bounds: "+(-1));
505                         }
506
507                 try {
508                         testarraybounds(ba, 5);
509                         }       
510                 catch (ArrayIndexOutOfBoundsException c) {
511                         p ("exception_3: out of bounds: "+5);
512                         }
513                 try {
514                         testarraybounds(ba, 50);
515                         }       
516                 catch (ArrayIndexOutOfBoundsException c) {
517                         p ("exception_4: out of bounds: "+50);
518                         }
519                 try {
520                         testarraybounds(ba, 100);
521                         }       
522                 catch (ArrayIndexOutOfBoundsException c) {
523                         p ("exception_5: out of bounds: "+100);
524                         }
525
526                 try {
527                         ba[-4] = 0;
528                         }       
529                 catch (ArrayIndexOutOfBoundsException c) {
530                         p ("exception_6: out of bounds: "+(-4));
531                         }
532                 try {
533                         ba[-3] = 0;
534                         }       
535                 catch (ArrayIndexOutOfBoundsException c) {
536                         p ("exception_7: out of bounds: "+(-3));
537                         }
538                 System.out.println("starting 8. loop");
539
540                 for (i=-2; i<102; i++) { 
541                         try {
542                                 ba[i] = (byte) (i-50);
543                                 }       
544                         catch (ArrayIndexOutOfBoundsException c) {
545                                 p ("exception_8: out of bounds: "+i);
546                                 }
547                         }
548                 
549                 try {
550                         ba[102] = 0;
551                         }       
552                 catch (ArrayIndexOutOfBoundsException c) {
553                         p ("exception_9: out of bounds: "+102);
554                         }
555                 try {
556                         ba[103] = 0;
557                         }       
558                 catch (ArrayIndexOutOfBoundsException c) {
559                         p ("exception_10: out of bounds: "+103);
560                         }
561                 for (i=0; i<100; i++) p (ba[i]);                
562
563
564                 
565
566                 p ("-------- test short arrays");               
567
568                 short[] sa = null;
569
570                 try {
571                         p ("null pointer check: short array store");
572                         sa[1] = 0;
573                         p ("error: null pointer exception not thrown");
574                         }       
575                 catch (NullPointerException c) {
576                         p ("exception: null pointer");
577                         }
578                 try {
579                         p ("null pointer check: short array load");
580                         i = sa[1];
581                         p ("error: null pointer exception not thrown");
582                         }       
583                 catch (NullPointerException c) {
584                         p ("exception: null pointer");
585                         }
586
587                 sa = new short [100];
588
589                 try {
590                         p ("array bound check: short array store");
591                         sa[-1] = 0;
592                         p ("error: exception not thrown");
593                         }       
594                 catch (ArrayIndexOutOfBoundsException c) {
595                         p ("exception_11: out of bounds: "+(-1));
596                         }
597                 try {
598                         p ("array bound check: short array load");
599                         i = sa[-1];
600                         p ("error: exception not thrown");
601                         }       
602                 catch (ArrayIndexOutOfBoundsException c) {
603                         p ("exception_12: out of bounds: "+(-1));
604                         }
605
606                 for (i=0; i<100; i++) sa[i] = (short) (i-50);
607                 for (i=0; i<100; i++) p (sa[i]);
608                 
609                 
610
611                 p ("-------- test int arrays");         
612
613                 int[] ia = null;
614
615                 try {
616                         p ("null pointer check: int array store");
617                         ia[1] = 0;
618                         p ("error: null pointer exception not thrown");
619                         }       
620                 catch (NullPointerException c) {
621                         p ("exception: null pointer");
622                         }
623                 try {
624                         p ("null pointer check: int array load");
625                         i = ia[1];
626                         p ("error: null pointer exception not thrown");
627                         }       
628                 catch (NullPointerException c) {
629                         p ("exception: null pointer");
630                         }
631
632                 ia = new int [50];
633
634                 try {
635                         p ("array bound check: int array store");
636                         ia[-1] = 0;
637                         p ("error: exception not thrown");
638                         }       
639                 catch (ArrayIndexOutOfBoundsException c) {
640                         p ("exception: out of bounds: "+(-1));
641                         }
642                 try {
643                         p ("array bound check: int array load");
644                         i = ia[-1];
645                         p ("error: exception not thrown");
646                         }       
647                 catch (ArrayIndexOutOfBoundsException c) {
648                         p ("exception: out of bounds: "+(-1));
649                         }
650
651                 for (i=0; i<10; i++) ia[i] = (123456 + i);
652                 for (i=0; i<10; i++) p (ia[i]);
653
654                 
655
656                 p ("-------- test long arrays");                
657
658                 long[] la = null;
659
660                 try {
661                         p ("null pointer check: long array store");
662                         la[1] = 0;
663                         p ("error: null pointer exception not thrown");
664                         }       
665                 catch (NullPointerException c) {
666                         p ("exception: null pointer");
667                         }
668                 try {
669                         p ("null pointer check: long array load");
670                         l = la[1];
671                         p ("error: null pointer exception not thrown");
672                         }       
673                 catch (NullPointerException c) {
674                         p ("exception: null pointer");
675                         }
676
677                 la = new long [10];
678
679                 try {
680                         p ("array bound check: long array store");
681                         la[-1] = 0;
682                         p ("error: exception not thrown");
683                         }       
684                 catch (ArrayIndexOutOfBoundsException c) {
685                         p ("exception: out of bounds: "+(-1));
686                         }
687                 try {
688                         p ("array bound check: long array load");
689                         l = la[-1];
690                         p ("error: exception not thrown");
691                         }       
692                 catch (ArrayIndexOutOfBoundsException c) {
693                         p ("exception: out of bounds: "+(-1));
694                         }
695
696                 for (i=0; i<10; i++) la[i] = (1234567890123L + i);
697                 for (i=0; i<10; i++) p (la[i]);
698
699                 
700                 p ("-------- test char arrays");                
701
702                 char[] ca = null;
703
704                 try {
705                         p ("null pointer check: char array store");
706                         ca[1] = 0;
707                         p ("error: null pointer exception not thrown");
708                         }       
709                 catch (NullPointerException c) {
710                         p ("exception: null pointer");
711                         }
712                 try {
713                         p ("null pointer check: char array load");
714                         i = ca[1];
715                         p ("error: null pointer exception not thrown");
716                         }       
717                 catch (NullPointerException c) {
718                         p ("exception: null pointer");
719                         }
720
721                 ca = new char [50];
722
723                 try {
724                         p ("array bound check: char array store");
725                         ca[-1] = 0;
726                         p ("error: exception not thrown");
727                         }       
728                 catch (ArrayIndexOutOfBoundsException c) {
729                         p ("exception: out of bounds: "+(-1));
730                         }
731                 try {
732                         p ("array bound check: char array load");
733                         i = ca[-1];
734                         p ("error: exception not thrown");
735                         }       
736                 catch (ArrayIndexOutOfBoundsException c) {
737                         p ("exception: out of bounds: "+(-1));
738                         }
739
740                 for (i=0; i<50; i++) ca[i] = (char) ('A' + i);
741                 for (i=0; i<50; i++) p (ca[i]);
742
743                 p ("-------- test address arrays");
744
745                 String[] sta = null;
746
747                 try {
748                         p ("null pointer check: address array store");
749                         sta[1] = null;
750                         p ("error: null pointer exception not thrown");
751                         }       
752                 catch (NullPointerException c) {
753                         p ("exception: null pointer");
754                         }
755                 try {
756                         p ("null pointer check: address array load");
757                         s = sta[1];
758                         p ("error: null pointer exception not thrown");
759                         }       
760                 catch (NullPointerException c) {
761                         p ("exception: null pointer");
762                         }
763
764                 try {
765                         p ("negative array size check: address array");
766                         sta = new String[-3];
767                         p ("error: negative array size exception not thrown");
768                         }       
769                 catch (NegativeArraySizeException c) {
770                         p ("exception: negative array size");
771                         }
772
773                 sta = new String[5];
774
775                 try {
776                         p ("array bound check: address array store");
777                         sta[-1] = null;
778                         p ("error: exception not thrown");
779                         }       
780                 catch (ArrayIndexOutOfBoundsException c) {
781                         p ("exception: out of bounds: "+(-1));
782                         }
783                 try {
784                         p ("array bound check: address array load");
785                         s = sta[-1];
786                         p ("error: exception not thrown");
787                         }       
788                 catch (ArrayIndexOutOfBoundsException c) {
789                         p ("exception: out of bounds: "+(-1));
790                         }
791
792                 for (i=0; i<5; i++) sta[i] = Integer.toString(i) + ". Zeile";
793                 for (i=0; i<5; i++) p (sta[i]);
794                 
795                 p ("-------- test multi dimensional arrays");
796
797                 int [][][] iaaa = null;
798
799                 try {
800                         p ("negative array size check: multi dimensional array");
801                         iaaa = new int[2][3][-4];
802                         p ("error: negative array size exception not thrown");
803                         }       
804                 catch (NegativeArraySizeException c) {
805                         p ("exception: negative array size");
806                         }
807
808                 iaaa = new int[2][3][4];
809                 long [][][] laaa = new long[2][3][6];
810                 float [][][] faaa = new float[2][3][4];
811                 double [][][] daaa = new double[3][4][7];
812                 for (i=0; i<2; i++) {
813                         int i2; for (i2=0; i2<3; i2++) {
814                                 int i3; for (i3=0; i3<4; i3++) {
815                                         iaaa[i][i2][i3] = i*i*i + i2*i2 + i3;
816                                         laaa[i][i2][i3] = i*i*i + i2*i2 + i3 + 7;
817                                         faaa[i][i2][i3] = i*i*i + i2*i2 + i3 + 0.4F;
818                                         daaa[i][i2][i3] = i*i*i + i2*i2 + i3 - 47.0001;
819                                         p (iaaa[i][i2][i3]);
820                                         p (laaa[i][i2][i3]);
821                                         p (faaa[i][i2][i3]);
822                                         p (daaa[i][i2][i3]);
823                                         }
824                                 }
825                         }
826                 
827
828                 }
829
830
831         static public void testconst(int i, long l) {
832                 p ("TESTCONST CALLED WITH ", i);
833                 p ("                  AND ", l);
834                 
835                 if (!(i == (0))) p("not IF_ICMPEQ", (0));
836                 if (!(i != (0))) p("not IF_ICMPNE", (0));
837                 if (!(i <  (0))) p("not IF_ICMPLT", (0));
838                 if (!(i <= (0))) p("not IF_ICMPLE", (0));
839                 if (!(i >  (0))) p("not IF_ICMPGT", (0));
840                 if (!(i >= (0))) p("not IF_ICMPGE", (0));
841
842                 if (!(l == (0))) p("not IF_LCMPEQ", (0));
843                 if (!(l != (0))) p("not IF_LCMPNE", (0));
844                 if (!(l <  (0))) p("not IF_LCMPLT", (0));
845                 if (!(l <= (0))) p("not IF_LCMPLE", (0));
846                 if (!(l >  (0))) p("not IF_LCMPGT", (0));
847                 if (!(l >= (0))) p("not IF_LCMPGE", (0));
848
849                 p("IADDCONST:  ", i  +  (-1));
850                 p("ISUBCONST:  ", i  -  (-1));
851                 p("IMULCONST:  ", i  *  (-1));
852                 p("ISHLCONST:  ", i <<  (-1));
853                 p("ISHRCONST:  ", i >>  (-1));
854                 p("IUSHRCONST: ", i >>> (-1));
855                 p("IANDCONST:  ", i  &  (-1));
856                 p("IORCONST:   ", i  |  (-1));
857                 p("IXORCONST:  ", i  ^  (-1));
858
859                 if (!(i == (-1))) p("not IF_ICMPEQ", (-1));
860                 if (!(i != (-1))) p("not IF_ICMPNE", (-1));
861                 if (!(i <  (-1))) p("not IF_ICMPLT", (-1));
862                 if (!(i <= (-1))) p("not IF_ICMPLE", (-1));
863                 if (!(i >  (-1))) p("not IF_ICMPGT", (-1));
864                 if (!(i >= (-1))) p("not IF_ICMPGE", (-1));
865
866                 p("LADDCONST:  ", l  +  (-1));
867                 p("LSUBCONST:  ", l  -  (-1));
868                 p("LMULCONST:  ", l  *  (-1));
869                 p("LSHLCONST:  ", l <<  (-1));
870                 p("LSHRCONST:  ", l >>  (-1));
871                 p("LUSHRCONST: ", l >>> (-1));
872                 p("LANDCONST:  ", l  &  (-1));
873                 p("LORCONST:   ", l  |  (-1));
874                 p("LXORCONST:  ", l  ^  (-1));
875
876                 if (!(l == (-1))) p("not IF_LCMPEQ", (-1));
877                 if (!(l != (-1))) p("not IF_LCMPNE", (-1));
878                 if (!(l <  (-1))) p("not IF_LCMPLT", (-1));
879                 if (!(l <= (-1))) p("not IF_LCMPLE", (-1));
880                 if (!(l >  (-1))) p("not IF_LCMPGT", (-1));
881                 if (!(l >= (-1))) p("not IF_LCMPGE", (-1));
882
883                 p("IADDCONST:  ", i  +  (1));
884                 p("ISUBCONST:  ", i  -  (1));
885                 p("IMULCONST:  ", i  *  (1));
886                 p("ISHLCONST:  ", i <<  (1));
887                 p("ISHRCONST:  ", i >>  (1));
888                 p("IUSHRCONST: ", i >>> (1));
889                 p("IANDCONST:  ", i  &  (1));
890                 p("IORCONST:   ", i  |  (1));
891                 p("IXORCONST:  ", i  ^  (1));
892
893                 if (!(i == (1))) p("not IF_ICMPEQ", (1));
894                 if (!(i != (1))) p("not IF_ICMPNE", (1));
895                 if (!(i <  (1))) p("not IF_ICMPLT", (1));
896                 if (!(i <= (1))) p("not IF_ICMPLE", (1));
897                 if (!(i >  (1))) p("not IF_ICMPGT", (1));
898                 if (!(i >= (1))) p("not IF_ICMPGE", (1));
899
900                 p("LADDCONST:  ", l  +  (1));
901                 p("LSUBCONST:  ", l  -  (1));
902                 p("LMULCONST:  ", l  *  (1));
903                 p("LSHLCONST:  ", l <<  (1));
904                 p("LSHRCONST:  ", l >>  (1));
905                 p("LUSHRCONST: ", l >>> (1));
906                 p("LANDCONST:  ", l  &  (1));
907                 p("LORCONST:   ", l  |  (1));
908                 p("LXORCONST:  ", l  ^  (1));
909
910                 if (!(l == (1))) p("not IF_LCMPEQ", (1));
911                 if (!(l != (1))) p("not IF_LCMPNE", (1));
912                 if (!(l <  (1))) p("not IF_LCMPLT", (1));
913                 if (!(l <= (1))) p("not IF_LCMPLE", (1));
914                 if (!(l >  (1))) p("not IF_LCMPGT", (1));
915                 if (!(l >= (1))) p("not IF_LCMPGE", (1));
916
917                 p("IADDCONST:  ", i  +  (255));
918                 p("ISUBCONST:  ", i  -  (255));
919                 p("IMULCONST:  ", i  *  (255));
920                 p("ISHLCONST:  ", i <<  (255));
921                 p("ISHRCONST:  ", i >>  (255));
922                 p("IUSHRCONST: ", i >>> (255));
923                 p("IANDCONST:  ", i  &  (255));
924                 p("IORCONST:   ", i  |  (255));
925                 p("IXORCONST:  ", i  ^  (255));
926
927                 if (!(i == (255))) p("not IF_ICMPEQ", (255));
928                 if (!(i != (255))) p("not IF_ICMPNE", (255));
929                 if (!(i <  (255))) p("not IF_ICMPLT", (255));
930                 if (!(i <= (255))) p("not IF_ICMPLE", (255));
931                 if (!(i >  (255))) p("not IF_ICMPGT", (255));
932                 if (!(i >= (255))) p("not IF_ICMPGE", (255));
933
934                 p("LADDCONST:  ", l  +  (255));
935                 p("LSUBCONST:  ", l  -  (255));
936                 p("LMULCONST:  ", l  *  (255));
937                 p("LSHLCONST:  ", l <<  (255));
938                 p("LSHRCONST:  ", l >>  (255));
939                 p("LUSHRCONST: ", l >>> (255));
940                 p("LANDCONST:  ", l  &  (255));
941                 p("LORCONST:   ", l  |  (255));
942                 p("LXORCONST:  ", l  ^  (255));
943
944                 if (!(l == (255))) p("not IF_LCMPEQ", (255));
945                 if (!(l != (255))) p("not IF_LCMPNE", (255));
946                 if (!(l <  (255))) p("not IF_LCMPLT", (255));
947                 if (!(l <= (255))) p("not IF_LCMPLE", (255));
948                 if (!(l >  (255))) p("not IF_LCMPGT", (255));
949                 if (!(l >= (255))) p("not IF_LCMPGE", (255));
950
951                 p("IADDCONST:  ", i  +  (256));
952                 p("ISUBCONST:  ", i  -  (256));
953                 p("IMULCONST:  ", i  *  (256));
954                 p("ISHLCONST:  ", i <<  (256));
955                 p("ISHRCONST:  ", i >>  (256));
956                 p("IUSHRCONST: ", i >>> (256));
957                 p("IANDCONST:  ", i  &  (256));
958                 p("IORCONST:   ", i  |  (256));
959                 p("IXORCONST:  ", i  ^  (256));
960
961                 if (!(i == (256))) p("not IF_ICMPEQ", (256));
962                 if (!(i != (256))) p("not IF_ICMPNE", (256));
963                 if (!(i <  (256))) p("not IF_ICMPLT", (256));
964                 if (!(i <= (256))) p("not IF_ICMPLE", (256));
965                 if (!(i >  (256))) p("not IF_ICMPGT", (256));
966                 if (!(i >= (256))) p("not IF_ICMPGE", (256));
967
968                 p("LADDCONST:  ", l  +  (256));
969                 p("LSUBCONST:  ", l  -  (256));
970                 p("LMULCONST:  ", l  *  (256));
971                 p("LSHLCONST:  ", l <<  (256));
972                 p("LSHRCONST:  ", l >>  (256));
973                 p("LUSHRCONST: ", l >>> (256));
974                 p("LANDCONST:  ", l  &  (256));
975                 p("LORCONST:   ", l  |  (256));
976                 p("LXORCONST:  ", l  ^  (256));
977
978                 if (!(l == (256))) p("not IF_LCMPEQ", (256));
979                 if (!(l != (256))) p("not IF_LCMPNE", (256));
980                 if (!(l <  (256))) p("not IF_LCMPLT", (256));
981                 if (!(l <= (256))) p("not IF_LCMPLE", (256));
982                 if (!(l >  (256))) p("not IF_LCMPGT", (256));
983                 if (!(l >= (256))) p("not IF_LCMPGE", (256));
984
985                 p("IADDCONST:  ", i  +  (32767));
986                 p("ISUBCONST:  ", i  -  (32767));
987                 p("IMULCONST:  ", i  *  (32767));
988                 p("ISHLCONST:  ", i <<  (32767));
989                 p("ISHRCONST:  ", i >>  (32767));
990                 p("IUSHRCONST: ", i >>> (32767));
991                 p("IANDCONST:  ", i  &  (32767));
992                 p("IORCONST:   ", i  |  (32767));
993                 p("IXORCONST:  ", i  ^  (32767));
994
995                 if (!(i == (32767))) p("not IF_ICMPEQ", (32767));
996                 if (!(i != (32767))) p("not IF_ICMPNE", (32767));
997                 if (!(i <  (32767))) p("not IF_ICMPLT", (32767));
998                 if (!(i <= (32767))) p("not IF_ICMPLE", (32767));
999                 if (!(i >  (32767))) p("not IF_ICMPGT", (32767));
1000                 if (!(i >= (32767))) p("not IF_ICMPGE", (32767));
1001
1002                 p("LADDCONST:  ", l  +  (32767));
1003                 p("LSUBCONST:  ", l  -  (32767));
1004                 p("LMULCONST:  ", l  *  (32767));
1005                 p("LSHLCONST:  ", l <<  (32767));
1006                 p("LSHRCONST:  ", l >>  (32767));
1007                 p("LUSHRCONST: ", l >>> (32767));
1008                 p("LANDCONST:  ", l  &  (32767));
1009                 p("LORCONST:   ", l  |  (32767));
1010                 p("LXORCONST:  ", l  ^  (32767));
1011
1012                 if (!(l == (32767))) p("not IF_LCMPEQ", (32767));
1013                 if (!(l != (32767))) p("not IF_LCMPNE", (32767));
1014                 if (!(l <  (32767))) p("not IF_LCMPLT", (32767));
1015                 if (!(l <= (32767))) p("not IF_LCMPLE", (32767));
1016                 if (!(l >  (32767))) p("not IF_LCMPGT", (32767));
1017                 if (!(l >= (32767))) p("not IF_LCMPGE", (32767));
1018
1019                 p("IADDCONST:  ", i  +  (32768));
1020                 p("ISUBCONST:  ", i  -  (32768));
1021                 p("IMULCONST:  ", i  *  (32768));
1022                 p("ISHLCONST:  ", i <<  (32768));
1023                 p("ISHRCONST:  ", i >>  (32768));
1024                 p("IUSHRCONST: ", i >>> (32768));
1025                 p("IANDCONST:  ", i  &  (32768));
1026                 p("IORCONST:   ", i  |  (32768));
1027                 p("IXORCONST:  ", i  ^  (32768));
1028
1029                 if (!(i == (32768))) p("not IF_ICMPEQ", (32768));
1030                 if (!(i != (32768))) p("not IF_ICMPNE", (32768));
1031                 if (!(i <  (32768))) p("not IF_ICMPLT", (32768));
1032                 if (!(i <= (32768))) p("not IF_ICMPLE", (32768));
1033                 if (!(i >  (32768))) p("not IF_ICMPGT", (32768));
1034                 if (!(i >= (32768))) p("not IF_ICMPGE", (32768));
1035
1036                 p("LADDCONST:  ", l  +  (32768));
1037                 p("LSUBCONST:  ", l  -  (32768));
1038                 p("LMULCONST:  ", l  *  (32768));
1039                 p("LSHLCONST:  ", l <<  (32768));
1040                 p("LSHRCONST:  ", l >>  (32768));
1041                 p("LUSHRCONST: ", l >>> (32768));
1042                 p("LANDCONST:  ", l  &  (32768));
1043                 p("LORCONST:   ", l  |  (32768));
1044                 p("LXORCONST:  ", l  ^  (32768));
1045
1046                 if (!(l == (32768))) p("not IF_LCMPEQ", (32768));
1047                 if (!(l != (32768))) p("not IF_LCMPNE", (32768));
1048                 if (!(l <  (32768))) p("not IF_LCMPLT", (32768));
1049                 if (!(l <= (32768))) p("not IF_LCMPLE", (32768));
1050                 if (!(l >  (32768))) p("not IF_LCMPGT", (32768));
1051                 if (!(l >= (32768))) p("not IF_LCMPGE", (32768));
1052
1053                 p("IADDCONST:  ", i  +  (-32768));
1054                 p("ISUBCONST:  ", i  -  (-32768));
1055                 p("IMULCONST:  ", i  *  (-32768));
1056                 p("ISHLCONST:  ", i <<  (-32768));
1057                 p("ISHRCONST:  ", i >>  (-32768));
1058                 p("IUSHRCONST: ", i >>> (-32768));
1059                 p("IANDCONST:  ", i  &  (-32768));
1060                 p("IORCONST:   ", i  |  (-32768));
1061                 p("IXORCONST:  ", i  ^  (-32768));
1062
1063                 if (!(i == (-32768))) p("not IF_ICMPEQ", (-32768));
1064                 if (!(i != (-32768))) p("not IF_ICMPNE", (-32768));
1065                 if (!(i <  (-32768))) p("not IF_ICMPLT", (-32768));
1066                 if (!(i <= (-32768))) p("not IF_ICMPLE", (-32768));
1067                 if (!(i >  (-32768))) p("not IF_ICMPGT", (-32768));
1068                 if (!(i >= (-32768))) p("not IF_ICMPGE", (-32768));
1069
1070                 p("LADDCONST:  ", l  +  (-32768));
1071                 p("LSUBCONST:  ", l  -  (-32768));
1072                 p("LMULCONST:  ", l  *  (-32768));
1073                 p("LSHLCONST:  ", l <<  (-32768));
1074                 p("LSHRCONST:  ", l >>  (-32768));
1075                 p("LUSHRCONST: ", l >>> (-32768));
1076                 p("LANDCONST:  ", l  &  (-32768));
1077                 p("LORCONST:   ", l  |  (-32768));
1078                 p("LXORCONST:  ", l  ^  (-32768));
1079
1080                 if (!(l == (-32768))) p("not IF_LCMPEQ", (-32768));
1081                 if (!(l != (-32768))) p("not IF_LCMPNE", (-32768));
1082                 if (!(l <  (-32768))) p("not IF_LCMPLT", (-32768));
1083                 if (!(l <= (-32768))) p("not IF_LCMPLE", (-32768));
1084                 if (!(l >  (-32768))) p("not IF_LCMPGT", (-32768));
1085                 if (!(l >= (-32768))) p("not IF_LCMPGE", (-32768));
1086
1087                 p("IADDCONST:  ", i  +  (-32769));
1088                 p("ISUBCONST:  ", i  -  (-32769));
1089                 p("IMULCONST:  ", i  *  (-32769));
1090                 p("ISHLCONST:  ", i <<  (-32769));
1091                 p("ISHRCONST:  ", i >>  (-32769));
1092                 p("IUSHRCONST: ", i >>> (-32769));
1093                 p("IANDCONST:  ", i  &  (-32769));
1094                 p("IORCONST:   ", i  |  (-32769));
1095                 p("IXORCONST:  ", i  ^  (-32769));
1096
1097                 if (!(i == (-32769))) p("not IF_ICMPEQ", (-32769));
1098                 if (!(i != (-32769))) p("not IF_ICMPNE", (-32769));
1099                 if (!(i <  (-32769))) p("not IF_ICMPLT", (-32769));
1100                 if (!(i <= (-32769))) p("not IF_ICMPLE", (-32769));
1101                 if (!(i >  (-32769))) p("not IF_ICMPGT", (-32769));
1102                 if (!(i >= (-32769))) p("not IF_ICMPGE", (-32769));
1103
1104                 p("LADDCONST:  ", l  +  (-32769));
1105                 p("LSUBCONST:  ", l  -  (-32769));
1106                 p("LMULCONST:  ", l  *  (-32769));
1107                 p("LSHLCONST:  ", l <<  (-32769));
1108                 p("LSHRCONST:  ", l >>  (-32769));
1109                 p("LUSHRCONST: ", l >>> (-32769));
1110                 p("LANDCONST:  ", l  &  (-32769));
1111                 p("LORCONST:   ", l  |  (-32769));
1112                 p("LXORCONST:  ", l  ^  (-32769));
1113
1114                 if (!(l == (-32769))) p("not IF_LCMPEQ", (-32769));
1115                 if (!(l != (-32769))) p("not IF_LCMPNE", (-32769));
1116                 if (!(l <  (-32769))) p("not IF_LCMPLT", (-32769));
1117                 if (!(l <= (-32769))) p("not IF_LCMPLE", (-32769));
1118                 if (!(l >  (-32769))) p("not IF_LCMPGT", (-32769));
1119                 if (!(l >= (-32769))) p("not IF_LCMPGE", (-32769));
1120
1121         }
1122
1123         static public void testrem0x10001(int a) {
1124                 p("IREM0X10001 (" + a + " % 0x10001):  ", a % 0x10001);
1125                 }
1126
1127         static public void testrem0x10001(long a) {
1128                 p("LREM0X10001 (" + a + " % 0x10001):  ", a % 0x10001L);
1129                 }
1130
1131         static public void testdivremconst(int a) {
1132                 p("IDIVPOW2 (" + a + " / 0x00000002):  ", a / 0x00000002);
1133                 p("IDIVPOW2 (" + a + " / 0x00000004):  ", a / 0x00000004);
1134                 p("IDIVPOW2 (" + a + " / 0x00000008):  ", a / 0x00000008);
1135                 p("IDIVPOW2 (" + a + " / 0x00000010):  ", a / 0x00000010);
1136                 p("IDIVPOW2 (" + a + " / 0x00000020):  ", a / 0x00000020);
1137                 p("IDIVPOW2 (" + a + " / 0x00000040):  ", a / 0x00000040);
1138                 p("IDIVPOW2 (" + a + " / 0x00000080):  ", a / 0x00000080);
1139                 p("IDIVPOW2 (" + a + " / 0x00000100):  ", a / 0x00000100);
1140                 p("IDIVPOW2 (" + a + " / 0x00000200):  ", a / 0x00000200);
1141                 p("IDIVPOW2 (" + a + " / 0x00000400):  ", a / 0x00000400);
1142                 p("IDIVPOW2 (" + a + " / 0x00000800):  ", a / 0x00000800);
1143                 p("IDIVPOW2 (" + a + " / 0x00001000):  ", a / 0x00001000);
1144                 p("IDIVPOW2 (" + a + " / 0x00002000):  ", a / 0x00002000);
1145                 p("IDIVPOW2 (" + a + " / 0x00004000):  ", a / 0x00004000);
1146                 p("IDIVPOW2 (" + a + " / 0x00008000):  ", a / 0x00008000);
1147                 p("IDIVPOW2 (" + a + " / 0x00010000):  ", a / 0x00010000);
1148                 p("IDIVPOW2 (" + a + " / 0x00020000):  ", a / 0x00020000);
1149                 p("IDIVPOW2 (" + a + " / 0x00040000):  ", a / 0x00040000);
1150                 p("IDIVPOW2 (" + a + " / 0x00080000):  ", a / 0x00080000);
1151                 p("IDIVPOW2 (" + a + " / 0x00100000):  ", a / 0x00100000);
1152                 p("IDIVPOW2 (" + a + " / 0x00200000):  ", a / 0x00200000);
1153                 p("IDIVPOW2 (" + a + " / 0x00400000):  ", a / 0x00400000);
1154                 p("IDIVPOW2 (" + a + " / 0x00800000):  ", a / 0x00800000);
1155                 p("IDIVPOW2 (" + a + " / 0x01000000):  ", a / 0x01000000);
1156                 p("IDIVPOW2 (" + a + " / 0x02000000):  ", a / 0x02000000);
1157                 p("IDIVPOW2 (" + a + " / 0x04000000):  ", a / 0x04000000);
1158                 p("IDIVPOW2 (" + a + " / 0x08000000):  ", a / 0x08000000);
1159                 p("IDIVPOW2 (" + a + " / 0x10000000):  ", a / 0x10000000);
1160                 p("IDIVPOW2 (" + a + " / 0x20000000):  ", a / 0x20000000);
1161                 p("IDIVPOW2 (" + a + " / 0x40000000):  ", a / 0x40000000);
1162                 p("IDIVPOW2 (" + a + " / 0x80000000):  ", a / 0x80000000);
1163
1164                 p("IREMPOW2 (" + a + " % 0x00000002):  ", a % 0x00000002);
1165                 p("IREMPOW2 (" + a + " % 0x00000004):  ", a % 0x00000004);
1166                 p("IREMPOW2 (" + a + " % 0x00000008):  ", a % 0x00000008);
1167                 p("IREMPOW2 (" + a + " % 0x00000010):  ", a % 0x00000010);
1168                 p("IREMPOW2 (" + a + " % 0x00000020):  ", a % 0x00000020);
1169                 p("IREMPOW2 (" + a + " % 0x00000040):  ", a % 0x00000040);
1170                 p("IREMPOW2 (" + a + " % 0x00000080):  ", a % 0x00000080);
1171                 p("IREMPOW2 (" + a + " % 0x00000100):  ", a % 0x00000100);
1172                 p("IREMPOW2 (" + a + " % 0x00000200):  ", a % 0x00000200);
1173                 p("IREMPOW2 (" + a + " % 0x00000400):  ", a % 0x00000400);
1174                 p("IREMPOW2 (" + a + " % 0x00000800):  ", a % 0x00000800);
1175                 p("IREMPOW2 (" + a + " % 0x00001000):  ", a % 0x00001000);
1176                 p("IREMPOW2 (" + a + " % 0x00002000):  ", a % 0x00002000);
1177                 p("IREMPOW2 (" + a + " % 0x00004000):  ", a % 0x00004000);
1178                 p("IREMPOW2 (" + a + " % 0x00008000):  ", a % 0x00008000);
1179                 p("IREMPOW2 (" + a + " % 0x00010000):  ", a % 0x00010000);
1180                 p("IREMPOW2 (" + a + " % 0x00020000):  ", a % 0x00020000);
1181                 p("IREMPOW2 (" + a + " % 0x00040000):  ", a % 0x00040000);
1182                 p("IREMPOW2 (" + a + " % 0x00080000):  ", a % 0x00080000);
1183                 p("IREMPOW2 (" + a + " % 0x00100000):  ", a % 0x00100000);
1184                 p("IREMPOW2 (" + a + " % 0x00200000):  ", a % 0x00200000);
1185                 p("IREMPOW2 (" + a + " % 0x00400000):  ", a % 0x00400000);
1186                 p("IREMPOW2 (" + a + " % 0x00800000):  ", a % 0x00800000);
1187                 p("IREMPOW2 (" + a + " % 0x01000000):  ", a % 0x01000000);
1188                 p("IREMPOW2 (" + a + " % 0x02000000):  ", a % 0x02000000);
1189                 p("IREMPOW2 (" + a + " % 0x04000000):  ", a % 0x04000000);
1190                 p("IREMPOW2 (" + a + " % 0x08000000):  ", a % 0x08000000);
1191                 p("IREMPOW2 (" + a + " % 0x10000000):  ", a % 0x10000000);
1192                 p("IREMPOW2 (" + a + " % 0x20000000):  ", a % 0x20000000);
1193                 p("IREMPOW2 (" + a + " % 0x40000000):  ", a % 0x40000000);
1194                 p("IREMPOW2 (" + a + " % 0x80000000):  ", a % 0x80000000);
1195                 }
1196
1197         static public void testdivremconst(long a) {
1198                 p("LDIVPOW2 (" + a + " / 0x00000002):  ", a / 0x00000002);
1199                 p("LDIVPOW2 (" + a + " / 0x00000004):  ", a / 0x00000004);
1200                 p("LDIVPOW2 (" + a + " / 0x00000008):  ", a / 0x00000008);
1201                 p("LDIVPOW2 (" + a + " / 0x00000010):  ", a / 0x00000010);
1202                 p("LDIVPOW2 (" + a + " / 0x00000020):  ", a / 0x00000020);
1203                 p("LDIVPOW2 (" + a + " / 0x00000040):  ", a / 0x00000040);
1204                 p("LDIVPOW2 (" + a + " / 0x00000080):  ", a / 0x00000080);
1205                 p("LDIVPOW2 (" + a + " / 0x00000100):  ", a / 0x00000100);
1206                 p("LDIVPOW2 (" + a + " / 0x00000200):  ", a / 0x00000200);
1207                 p("LDIVPOW2 (" + a + " / 0x00000400):  ", a / 0x00000400);
1208                 p("LDIVPOW2 (" + a + " / 0x00000800):  ", a / 0x00000800);
1209                 p("LDIVPOW2 (" + a + " / 0x00001000):  ", a / 0x00001000);
1210                 p("LDIVPOW2 (" + a + " / 0x00002000):  ", a / 0x00002000);
1211                 p("LDIVPOW2 (" + a + " / 0x00004000):  ", a / 0x00004000);
1212                 p("LDIVPOW2 (" + a + " / 0x00008000):  ", a / 0x00008000);
1213                 p("LDIVPOW2 (" + a + " / 0x00010000):  ", a / 0x00010000);
1214                 p("LDIVPOW2 (" + a + " / 0x00020000):  ", a / 0x00020000);
1215                 p("LDIVPOW2 (" + a + " / 0x00040000):  ", a / 0x00040000);
1216                 p("LDIVPOW2 (" + a + " / 0x00080000):  ", a / 0x00080000);
1217                 p("LDIVPOW2 (" + a + " / 0x00100000):  ", a / 0x00100000);
1218                 p("LDIVPOW2 (" + a + " / 0x00200000):  ", a / 0x00200000);
1219                 p("LDIVPOW2 (" + a + " / 0x00400000):  ", a / 0x00400000);
1220                 p("LDIVPOW2 (" + a + " / 0x00800000):  ", a / 0x00800000);
1221                 p("LDIVPOW2 (" + a + " / 0x01000000):  ", a / 0x01000000);
1222                 p("LDIVPOW2 (" + a + " / 0x02000000):  ", a / 0x02000000);
1223                 p("LDIVPOW2 (" + a + " / 0x04000000):  ", a / 0x04000000);
1224                 p("LDIVPOW2 (" + a + " / 0x08000000):  ", a / 0x08000000);
1225                 p("LDIVPOW2 (" + a + " / 0x10000000):  ", a / 0x10000000);
1226                 p("LDIVPOW2 (" + a + " / 0x20000000):  ", a / 0x20000000);
1227                 p("LDIVPOW2 (" + a + " / 0x40000000):  ", a / 0x40000000);
1228                 p("LDIVPOW2 (" + a + " / 0x80000000):  ", a / 0x80000000);
1229
1230                 p("LREMPOW2 (" + a + " % 0x00000002):  ", a % 0x00000002L);
1231                 p("LREMPOW2 (" + a + " % 0x00000004):  ", a % 0x00000004L);
1232                 p("LREMPOW2 (" + a + " % 0x00000008):  ", a % 0x00000008L);
1233                 p("LREMPOW2 (" + a + " % 0x00000010):  ", a % 0x00000010L);
1234                 p("LREMPOW2 (" + a + " % 0x00000020):  ", a % 0x00000020L);
1235                 p("LREMPOW2 (" + a + " % 0x00000040):  ", a % 0x00000040L);
1236                 p("LREMPOW2 (" + a + " % 0x00000080):  ", a % 0x00000080L);
1237                 p("LREMPOW2 (" + a + " % 0x00000100):  ", a % 0x00000100L);
1238                 p("LREMPOW2 (" + a + " % 0x00000200):  ", a % 0x00000200L);
1239                 p("LREMPOW2 (" + a + " % 0x00000400):  ", a % 0x00000400L);
1240                 p("LREMPOW2 (" + a + " % 0x00000800):  ", a % 0x00000800L);
1241                 p("LREMPOW2 (" + a + " % 0x00001000):  ", a % 0x00001000L);
1242                 p("LREMPOW2 (" + a + " % 0x00002000):  ", a % 0x00002000L);
1243                 p("LREMPOW2 (" + a + " % 0x00004000):  ", a % 0x00004000L);
1244                 p("LREMPOW2 (" + a + " % 0x00008000):  ", a % 0x00008000L);
1245                 p("LREMPOW2 (" + a + " % 0x00010000):  ", a % 0x00010000L);
1246                 p("LREMPOW2 (" + a + " % 0x00020000):  ", a % 0x00020000L);
1247                 p("LREMPOW2 (" + a + " % 0x00040000):  ", a % 0x00040000L);
1248                 p("LREMPOW2 (" + a + " % 0x00080000):  ", a % 0x00080000L);
1249                 p("LREMPOW2 (" + a + " % 0x00100000):  ", a % 0x00100000L);
1250                 p("LREMPOW2 (" + a + " % 0x00200000):  ", a % 0x00200000L);
1251                 p("LREMPOW2 (" + a + " % 0x00400000):  ", a % 0x00400000L);
1252                 p("LREMPOW2 (" + a + " % 0x00800000):  ", a % 0x00800000L);
1253                 p("LREMPOW2 (" + a + " % 0x01000000):  ", a % 0x01000000L);
1254                 p("LREMPOW2 (" + a + " % 0x02000000):  ", a % 0x02000000L);
1255                 p("LREMPOW2 (" + a + " % 0x04000000):  ", a % 0x04000000L);
1256                 p("LREMPOW2 (" + a + " % 0x08000000):  ", a % 0x08000000L);
1257                 p("LREMPOW2 (" + a + " % 0x10000000):  ", a % 0x10000000L);
1258                 p("LREMPOW2 (" + a + " % 0x20000000):  ", a % 0x20000000L);
1259                 p("LREMPOW2 (" + a + " % 0x40000000):  ", a % 0x40000000L);
1260                 p("LREMPOW2 (" + a + " % 0x80000000):  ", a % 0x80000000L);
1261                 }
1262
1263
1264         static public void testint(int a, int b) {
1265                 p ("TESTINT CALLED WITH ", a);
1266                 p ("                AND ", b);
1267                 
1268                 p("IADD:  ", a+b);
1269                 p("ISUB:  ", a-b);
1270                 p("IMUL:  ", a*b);
1271                 try { p("IDIV:  ", a/b); } 
1272                 catch (ArithmeticException e) { p("divison by zero"); }
1273                 try { p("IREM:  ", a%b); } 
1274                 catch (ArithmeticException e) { p("divison by zero"); }
1275                 p("INEG:  ", -a);
1276                 p("ISHL:  ", a<<b);
1277                 p("ISHR:  ", a>>b);
1278                 p("IUSHR: ", a>>>b);
1279                 p("IAND:  ", a & b);
1280                 p("IOR:   ", a | b);
1281                 p("IXOR:  ", a ^ b);
1282
1283                 p("I2L:   ", (long) a);
1284                 p("I2F:   ", (float) a);
1285                 p("I2D:   ", (double) a);
1286                 p("INT2BYTE: ", (byte) a);      
1287                 p("INT2CHAR: ", (char) a);      
1288                 p("INT2SHORT: ", (short) a);    
1289
1290                 if (!(a==0)) p("not IFEQ");
1291                 if (!(a!=0)) p("not IFNE");
1292                 if (!(a<0))  p("not IFLT");
1293                 if (!(a<=0)) p("not IFLE");
1294                 if (!(a>0))  p("not IFGT");
1295                 if (!(a>=0)) p("not IFGE");
1296
1297                 if (!(a==b)) p("not IF_ICMPEQ");
1298                 if (!(a!=b)) p("not IF_ICMPNE");
1299                 if (!(a<b))  p("not IF_ICMPLT");
1300                 if (!(a<=b)) p("not IF_ICMPLE");
1301                 if (!(a>b))  p("not IF_ICMPGT");
1302                 if (!(a>=b)) p("not IF_ICMPGE");
1303                 
1304                 p("COND_ICMPEQ " + a + " == 0: " + ((a == 0) ? 0 : 1));
1305                 p("COND_ICMPNE " + a + " != 0: " + ((a != 0) ? 0 : 1));
1306                 p("COND_ICMPLT " + a + " <  0: " + ((a <  0) ? 0 : 1));
1307                 p("COND_ICMPLE " + a + " <= 0: " + ((a <= 0) ? 0 : 1));
1308                 p("COND_ICMPGT " + a + " >  0: " + ((a >  0) ? 0 : 1));
1309                 p("COND_ICMPGE " + a + " >= 0: " + ((a >= 0) ? 0 : 1));
1310                 
1311                 p("COND_ICMPEQ " + a + " == 0: " + ((a == 0) ? 1 : 0));
1312                 p("COND_ICMPNE " + a + " != 0: " + ((a != 0) ? 1 : 0));
1313                 p("COND_ICMPLT " + a + " <  0: " + ((a <  0) ? 1 : 0));
1314                 p("COND_ICMPLE " + a + " <= 0: " + ((a <= 0) ? 1 : 0));
1315                 p("COND_ICMPGT " + a + " >  0: " + ((a >  0) ? 1 : 0));
1316                 p("COND_ICMPGE " + a + " >= 0: " + ((a >= 0) ? 1 : 0));
1317                 
1318                 p("COND_ICMPEQ " + a + " == 0: " + ((a == 0) ? 2 : 3));
1319                 p("COND_ICMPNE " + a + " != 0: " + ((a != 0) ? 2 : 3));
1320                 p("COND_ICMPLT " + a + " <  0: " + ((a <  0) ? 2 : 3));
1321                 p("COND_ICMPLE " + a + " <= 0: " + ((a <= 0) ? 2 : 3));
1322                 p("COND_ICMPGT " + a + " >  0: " + ((a >  0) ? 2 : 3));
1323                 p("COND_ICMPGE " + a + " >= 0: " + ((a >= 0) ? 2 : 3));
1324                 
1325                 p("COND_ICMPEQ " + a + " == " + b + ": " + (a == b));
1326                 p("COND_ICMPNE " + a + " != " + b + ": " + (a != b));
1327                 p("COND_ICMPLT " + a + " <  " + b + ": " + (a <  b));
1328                 p("COND_ICMPLE " + a + " <= " + b + ": " + (a <= b));
1329                 p("COND_ICMPGT " + a + " >  " + b + ": " + (a >  b));
1330                 p("COND_ICMPGE " + a + " >= " + b + ": " + (a >= b));
1331                 
1332         }
1333
1334         static public void testlong(long a, long b) {
1335                 p ("TESTLONG called with ", a);
1336                 p ("                 AND ", b);
1337                 
1338                 p("LADD:  ", a + b);
1339                 p("LSUB:  ", a - b);
1340                 p("LMUL:  ", a * b);
1341                 try { p("LDIV:  ", a / b); } 
1342                 catch (ArithmeticException e) { p("divison by zero"); }
1343                 try { p("LREM:  ", a % b); } 
1344                 catch (ArithmeticException e) { p("divison by zero"); }
1345                 p("LNEG:  ", -a);
1346                 p("LSHL:  ", a << b);
1347                 p("LSHR:  ", a >> b);
1348                 p("LUSHR: ", a >>>b);
1349                 p("LAND:  ", a &  b);
1350                 p("LOR:   ", a |  b);
1351                 p("LXOR:  ", a ^  b);
1352
1353                 p("L2I:   ", (int) a);
1354                 p("L2F:   ", (float) a);
1355                 p("L2D:   ", (double) a);
1356
1357                 p("LCMP a == b : ", a == b);
1358                 p("LCMP a != b : ", a != b);
1359                 p("LCMP a <  b : ", a <  b);
1360                 p("LCMP a <= b : ", a <= b);
1361                 p("LCMP a >  b : ", a >  b);
1362                 p("LCMP a >= b : ", a >= b);
1363
1364                 if ((a==b)) p("not IF_LCMPEQ");
1365                 if ((a!=b)) p("not IF_LCMPNE");
1366                 if ((a<b))  p("not IF_LCMPLT");
1367                 if ((a<=b)) p("not IF_LCMPLE");
1368                 if ((a>b))  p("not IF_LCMPGT");
1369                 if ((a>=b)) p("not IF_LCMPGE");
1370         }
1371
1372         static public void testfloat(float a, float b) {
1373                 p ("TESTFLOAT called with ", a);
1374                 p ("                  AND ", b);
1375                 
1376                 p("FADD:  ", a+b);
1377                 p("FSUB:  ", a-b);
1378                 p("FMUL:  ", a*b);
1379                 p("FDIV:  ", a/b); 
1380                 p("FREM:  ", a%b);
1381                 
1382                 p("F2I:   ", (int) a);
1383                 p("F2L:   ", (long) a);
1384                 p("F2D:   ", (double) a);
1385
1386                 if ((a==b)) p("FCMP a=b");
1387                 if ((a!=b)) p("FCMP a!=b");
1388                 if ((a<b))  p("FCMP a<b");
1389                 if ((a<=b)) p("FCMP a<=b");
1390                 if ((a>b))  p("FCMP a>b");
1391                 if ((a>=b)) p("FCMP a>=b");
1392         }
1393
1394         static public void testdouble(double a, double b) {
1395                 p ("TESTDOUBLE called with ", a);
1396                 p ("                   AND ", b);
1397                 
1398                 p("DADD:  ", a+b);
1399                 p("DSUB:  ", a-b);
1400                 p("DMUL:  ", a*b);
1401                 p("DDIV:  ", a/b); 
1402                 p("DREM:  ", a%b);
1403                 
1404                 p("D2I:   ", (int) a);
1405                 p("D2L:   ", (long) a);
1406                 p("D2F:   ", (float) a);
1407
1408                 if ((a==b)) p("DCMP a=b");
1409                 if ((a!=b)) p("DCMP a!=b");
1410                 if ((a<b))  p("DCMP a<b");
1411                 if ((a<=b)) p("DCMP a<=b");
1412                 if ((a>b))  p("DCMP a>b");
1413                 if ((a>=b)) p("DCMP a>=b");
1414         }
1415
1416
1417         // ********************* output methods ****************************
1418         
1419         public static int linenum = 0;
1420         public static void pnl() {
1421                 System.out.println ();
1422                 System.out.print (linenum);
1423                 System.out.print (".    ");
1424                 linenum++;
1425                 }
1426
1427         public static void p(String a) { System.out.print(a); pnl(); }
1428         public static void p(boolean a) {System.out.print(a); 
1429                                       pnl();  }
1430         public static void p(int a) { System.out.print ("int: ");
1431                                       System.out.print(a); 
1432                                       pnl();  }
1433         public static void p(long a) { System.out.print ("long: ");
1434                                        System.out.print(a); 
1435                                        pnl(); }
1436         public static void p(short a) { System.out.print ("short: ");
1437                                        System.out.print(a); 
1438                                        pnl(); }
1439         public static void p(byte a) { System.out.print ("byte: ");
1440                                        System.out.print(a); 
1441                                        pnl(); }
1442         public static void p(char a) { System.out.print ("char: ");
1443                                        System.out.print((int)a); 
1444                                        pnl(); }
1445         public static void p(float a) { System.out.print ("float: ");
1446                                         System.out.print ( java.lang.Float.floatToIntBits(a) ); 
1447                                         pnl(); }
1448         public static void p(double a) { System.out.print ("double: ");
1449                                          System.out.print( java.lang.Double.doubleToLongBits(a) ); 
1450                                          pnl(); }
1451
1452         public static void p(String s,boolean i) { 
1453                 System.out.print(s); p(i);
1454                 }
1455         public static void p(String s,int i) { 
1456                 System.out.print(s); p(i);
1457                 }
1458         public static void p(String s,byte i) { 
1459                 System.out.print(s); p(i);
1460                 }
1461         public static void p(String s,char i) { 
1462                 System.out.print(s); p(i);
1463                 }
1464         public static void p(String s,short i) { 
1465                 System.out.print(s); p(i);
1466                 }
1467         public static void p(String s,long l) { 
1468                 System.out.print(s); p(l);
1469                 }
1470         public static void p(String s,float f) { 
1471                 System.out.print(s); p(f);
1472                 }
1473         public static void p(String s,double d) {
1474                 System.out.print(s); p(d);
1475                 }
1476
1477
1478
1479
1480         // methods for testing interface and method calls
1481
1482         public void jctest() { p (" <init> wird aktiviert"); };
1483         public void p_manyparam (int p_i1,int p_i2,
1484                                  int p_i3, int p_i4, 
1485                                  long p_l1,long p_l2,
1486                                  long p_l3,long p_l4, 
1487                                  float p_f1, float p_f2, 
1488                                  float p_f3, float p_f4,
1489                                  double p_d1, double p_d2,
1490                                  double p_d3, double p_d4) {
1491                 n_i1 = p_i1;
1492                 n_i2 = p_i2;
1493                 n_i3 = p_i3;
1494                 n_i4 = p_i4;
1495                 n_l1 = p_l1;
1496                 n_l2 = p_l2;
1497                 n_l3 = p_l3;
1498                 n_l4 = p_l4;
1499                 n_f1 = p_f1;
1500                 n_f2 = p_f2;
1501                 n_f3 = p_f3;
1502                 n_f4 = p_f4;
1503                 n_d1 = p_d1;
1504                 n_d2 = p_d2;
1505                 n_d3 = p_d3;
1506                 n_d4 = p_d4;
1507                 }
1508                 
1509         public void p_nonstatic (String a) { 
1510                 p(a); 
1511                 p(n_i1);
1512                 p(n_i2);
1513                 p(n_i3);
1514                 p(n_i4);
1515                 p(n_l1);
1516                 p(n_l2);
1517                 p(n_l3);
1518                 p(n_l4);
1519                 p(n_f1);
1520                 p(n_f2);
1521                 p(n_f3);
1522                 p(n_f4);
1523                 p(n_d1);
1524                 p(n_d2);
1525                 p(n_d3);
1526                 p(n_d4);
1527                 
1528                 }
1529
1530         }
1531         
1532         
1533 interface jcinterface { 
1534         public void p_nonstatic (String a);
1535         }
1536         
1537