PR144 (aligned patchers on x86_64)
[cacao.git] / tests / regression / bugzilla / PR144.java
1 /* tests/regression/bugzilla/PR144.java
2
3    Copyright (C) 1996-2011
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
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.
12
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.
17
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
21    02110-1301, USA.
22
23 */
24
25
26 import org.junit.Test;
27 import static org.junit.Assert.*;
28
29 interface test_summable {
30     long sum();
31 }
32
33 class y implements test_summable {
34     public long l;
35     public int i;
36     public long sum() {
37         return l+i;
38     }
39 }
40
41 public class PR144 {
42     static long do_test(Object o, int val) {
43         y vy = (y) o;
44         test_summable sm = null;
45         if (o instanceof test_summable)
46             sm = (test_summable) o;
47         vy.l = 0x123456789L;
48         vy.i = 0x98765;
49         long r = sm.sum();
50         vy.l = val;
51         vy.i = val;
52         return r + sm.sum();
53     }
54
55     @Test
56     public void test() {
57         try {
58             do_test(null, 0);
59         } catch (NullPointerException e) {
60         }
61         assertEquals(4887631770L, do_test(new y(), 0x23456));
62     }
63 }
64
65
66
67