1 /* tests/regression/bugzilla/TestPatcher.java
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 import junit.framework.*;
27 import junit.textui.*;
31 public class TestPatcher extends TestCase {
32 public static void main(String[] args) {
33 TestRunner.run(suite());
36 public static Test suite() {
37 return new TestSuite(TestPatcher.class);
40 static boolean doit = true;
42 final static int i = 123;
43 final static long l = 1234567890123L;
44 final static float f = 123.456F;
45 final static double d = 789.012;
46 final static Object o = new Object();
48 public void testNormal() {
69 public void testWithoutClasses() {
70 // Delete all classes.
71 //new File("TestPatcher$invokestatic.class").delete();
93 private void invokestatic() {
97 } catch (NoClassDefFoundError e) {
102 private void getstatic() {
105 assertTrue(getstaticI.i + " != " + i, getstaticI.i == i);
106 } catch (NoClassDefFoundError e) {
112 assertTrue(getstaticJ.l + " != " + l, getstaticJ.l == l);
113 } catch (NoClassDefFoundError e) {
119 assertTrue(getstaticF.f + " != " + f, getstaticF.f == f);
120 } catch (NoClassDefFoundError e) {
126 assertTrue(getstaticD.d + " != " + d, getstaticD.d == d);
127 } catch (NoClassDefFoundError e) {
133 assertTrue(getstaticL.o + " != null", getstaticL.o == null);
134 } catch (NoClassDefFoundError e) {
139 private void putstatic() {
143 assertTrue(putstaticI.i + " != " + i, putstaticI.i == i);
145 } catch (NoClassDefFoundError t) {
152 assertTrue(putstaticJ.l + " != " + l, putstaticJ.l == l);
154 } catch (NoClassDefFoundError t) {
161 assertTrue(putstaticF.f + " != " + f, putstaticF.f == f);
163 } catch (NoClassDefFoundError t) {
170 assertTrue(putstaticD.d + " != " + d, putstaticD.d == d);
172 } catch (NoClassDefFoundError t) {
180 assertTrue(putstaticL.o + " != " + o, putstaticL.o == o);
182 } catch (NoClassDefFoundError t) {
187 private void putstaticconst() {
190 putstaticconstI.i = i;
191 assertTrue(putstaticconstI.i + " != " + i, putstaticconstI.i == i);
193 } catch (NoClassDefFoundError t) {
199 putstaticconstJ.l = l;
200 assertTrue(putstaticconstJ.l + " != " + l, putstaticconstJ.l == l);
202 } catch (NoClassDefFoundError t) {
208 putstaticconstF.f = f;
209 assertTrue(putstaticconstF.f + " != " + f, putstaticconstF.f == f);
211 } catch (NoClassDefFoundError t) {
217 putstaticconstD.d = d;
218 assertTrue(putstaticconstD.d + " != " + d, putstaticconstD.d == d);
220 } catch (NoClassDefFoundError t) {
226 putstaticconstI.i = 0;
227 assertTrue(putstaticconstI.i + " != " + 0, putstaticconstI.i == 0);
229 } catch (NoClassDefFoundError t) {
235 putstaticconstJ.l = 0L;
236 assertTrue(putstaticconstJ.l + " != " + 0L, putstaticconstJ.l == 0L);
238 } catch (NoClassDefFoundError t) {
244 putstaticconstF.f = 0.0F;
245 assertTrue(putstaticconstF.f + " != " + 0.0F, putstaticconstF.f == 0.0F);
247 } catch (NoClassDefFoundError t) {
253 putstaticconstD.d = 0.0;
254 assertTrue(putstaticconstD.d + " != " + 0.0, putstaticconstD.d == 0.0);
256 } catch (NoClassDefFoundError t) {
262 putstaticconstL.o = null;
263 assertTrue(putstaticconstL.o + " != " + null, putstaticconstL.o == null);
265 } catch (NoClassDefFoundError t) {
271 putstaticconstC.c = putstaticconstC.class;
272 assertTrue(putstaticconstC.c + " != " + Class.forName("TestPatcher$putstaticconstC"), putstaticconstC.c == Class.forName("TestPatcher$putstaticconstC"));
274 } catch (NoClassDefFoundError t) {
276 } catch (ClassNotFoundException t) {
281 private void getfield() {
284 assertTrue(new getfieldI().i + " != " + i, new getfieldI().i == i);
285 } catch (NoClassDefFoundError t) {
291 assertTrue(new getfieldJ().l + " != " + l, new getfieldJ().l == l);
292 } catch (NoClassDefFoundError t) {
298 assertTrue(new getfieldF().f + " != " + f, new getfieldF().f == f);
299 } catch (NoClassDefFoundError t) {
305 assertTrue(new getfieldD().d + " != " + d, new getfieldD().d == d);
306 } catch (NoClassDefFoundError t) {
312 assertTrue(new getfieldL().o + " != " + null, new getfieldL().o == null);
313 } catch (NoClassDefFoundError t) {
318 private void putfield() {
321 TestPatcher.putfieldI pfi = new TestPatcher.putfieldI();
323 assertTrue(pfi.i + " != " + i, pfi.i == i);
325 } catch (NoClassDefFoundError t) {
331 putfieldJ pfj = new putfieldJ();
333 assertTrue(pfj.l + " != " + l, pfj.l == l);
335 } catch (NoClassDefFoundError t) {
341 putfieldF pff = new putfieldF();
343 assertTrue(pff.f + " != " + f, pff.f == f);
345 } catch (NoClassDefFoundError t) {
351 putfieldD pfd = new putfieldD();
353 assertTrue(pfd.d + " != " + d, pfd.d == d);
355 } catch (NoClassDefFoundError t) {
361 putfieldL pfl = new putfieldL();
363 assertTrue(pfl.o + " != " + o, pfl.o == o);
365 } catch (NoClassDefFoundError t) {
370 private void putfieldconst() {
373 putfieldconstI pfci = new putfieldconstI();
375 assertTrue(pfci.i + " != " + i, pfci.i == i);
377 } catch (NoClassDefFoundError t) {
383 putfieldconstJ pfcj = new putfieldconstJ();
385 assertTrue(pfcj.l + " != " + l, pfcj.l == l);
387 } catch (NoClassDefFoundError t) {
393 putfieldconstF pfcf = new putfieldconstF();
395 assertTrue(pfcf.f + " != " + f, pfcf.f == f);
397 } catch (NoClassDefFoundError t) {
403 putfieldconstD pfcd = new putfieldconstD();
405 assertTrue(pfcd.d + " != " + d, pfcd.d == d);
407 } catch (NoClassDefFoundError t) {
413 putfieldconstI pfci = new putfieldconstI();
415 assertTrue(pfci.i + " != " + 0, pfci.i == 0);
417 } catch (NoClassDefFoundError t) {
423 putfieldconstJ pfcj = new putfieldconstJ();
425 assertTrue(pfcj.l + " != " + 0L, pfcj.l == 0L);
427 } catch (NoClassDefFoundError t) {
433 putfieldconstF pfcf = new putfieldconstF();
435 assertTrue(pfcf.f + " != " + 0.0F, pfcf.f == 0.0F);
437 } catch (NoClassDefFoundError t) {
443 putfieldconstD pfcd = new putfieldconstD();
445 assertTrue(pfcd.d + " != " + 0.0, pfcd.d == 0.0);
447 } catch (NoClassDefFoundError t) {
453 putfieldconstL pfcl = new putfieldconstL();
455 assertTrue(pfcl.o + " != " + null, pfcl.o == null);
457 } catch (NoClassDefFoundError t) {
463 putfieldconstC pfcc = new putfieldconstC();
464 pfcc.c = putfieldconstC.class;
465 assertTrue(pfcc.c + " != " + Class.forName("TestPatcher$putfieldconstC"), pfcc.c == Class.forName("TestPatcher$putfieldconstC"));
467 } catch (NoClassDefFoundError t) {
469 } catch (ClassNotFoundException t) {
474 private void newarray() {
477 newarray[] na = new newarray[1];
480 } catch (NoClassDefFoundError t) {
485 private void multianewarray() {
488 multianewarray[][] ma = new multianewarray[1][1];
491 } catch (NoClassDefFoundError t) {
496 private void invokespecial() {
500 } catch (NoClassDefFoundError t) {
505 private void checkcast() {
506 Object o = new Object();
511 checkcastC cc = (checkcastC) o;
514 } catch (ClassCastException success) {
516 } catch (NoClassDefFoundError t) {
523 checkcastI ci = (checkcastI) o;
526 } catch (ClassCastException success) {
528 } catch (NoClassDefFoundError t) {
534 Object[] oa = new Object[1];
538 checkcastC[] cca = (checkcastC[]) oa;
541 } catch (ClassCastException e) {
543 } catch (NoClassDefFoundError t) {
548 private void _instanceof() {
549 Object o = new Object();
553 if (o instanceof instanceofC)
555 } catch (NoClassDefFoundError t) {
561 if (o instanceof instanceofI)
563 } catch (NoClassDefFoundError t) {
569 Object[] oa = new Object[1];
573 if (oa instanceof instanceofC[])
575 } catch (NoClassDefFoundError t) {
580 private void aastoreconst() {
581 Class[] ca = new Class[1];
585 ca[0] = aastoreconstClass.class;
590 assertTrue(ca[0] + " != " + Class.forName("TestPatcher$aastoreconstClass") , ca[0] == Class.forName("TestPatcher$aastoreconstClass"));
592 } catch (NoClassDefFoundError t) {
594 } catch (ClassNotFoundException t) {
599 static class invokestatic { static void sub() {} }
600 static class invokespecial { void invokespecial() {} }
602 static class getstaticI { static int i = TestPatcher.i; }
603 static class getstaticJ { static long l = TestPatcher.l; }
604 static class getstaticF { static float f = TestPatcher.f; }
605 static class getstaticD { static double d = TestPatcher.d; }
606 static class getstaticL { static Object o = null; }
608 static class putstaticI { static int i; }
609 static class putstaticJ { static long l; }
610 static class putstaticF { static float f; }
611 static class putstaticD { static double d; }
612 static class putstaticL { static Object o; }
614 static class putstaticconstI { static int i; }
615 static class putstaticconstJ { static long l; }
616 static class putstaticconstF { static float f; }
617 static class putstaticconstD { static double d; }
618 static class putstaticconstL { static Object o; }
619 static class putstaticconstC { static Class<putstaticconstC> c; }
621 static class getfieldI { int i = TestPatcher.i; }
622 static class getfieldJ { long l = TestPatcher.l; }
623 static class getfieldF { float f = TestPatcher.f; }
624 static class getfieldD { double d = TestPatcher.d; }
625 static class getfieldL { Object o = null; }
627 static class putfieldI { int i; }
628 static class putfieldJ { long l; }
629 static class putfieldF { float f; }
630 static class putfieldD { double d; }
631 static class putfieldL { Object o; }
633 static class putfieldconstI { int i; }
634 static class putfieldconstJ { long l; }
635 static class putfieldconstF { float f; }
636 static class putfieldconstD { double d; }
637 static class putfieldconstL { Object o; }
638 static class putfieldconstC { Class<putfieldconstC> c; }
640 static class newarray {}
641 static class multianewarray {}
643 static class instanceofC {}
644 static interface instanceofI {}
646 static class checkcastC {}
647 static interface checkcastI {}
649 static class aastoreconstClass {}