This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Alpha vs. new ABI
(OK, now that I've slept a bit maybe I can contribute something useful to this
thread again :\)
Alexandre Petit-Bianco wrote:
> So we could simplify the code in typeck.c like below, or am I
> definitively missing something obvious? I haven't tried this patch
> yet, especially on alpha (disk space problem.)
This is getting closer. My test exhibits a different failure now:
public class Hello {
static int[] i = {1,2,3,4};
public static native void print(int[] iarray);
public static native void print(int i);
public static void main(String[] args) {
print(i);
print(new int[] {1,2,3,4});
for (int n = 0; n < i.length; n++) print(i[n]);
}
}
$ gcj -I/opt/gcj/include Hello.java natHello.cc --main=Hello -o hello
$ ./hello
i[0] = 1
i[1] = 2
i[2] = 3
i[3] = 4
i[0] = 1
i[1] = 2
i[2] = 3
i[3] = 4
2
3
4
0
Looks like C++ and the runtime are basically working both for static and
dynamically allocated arrays. But the Java expression `i[n]' seems to get the
array offset wrong. And compiling from bytecode yields yet another variation:
$ gcj -C Hello.java
$ gcj -I/opt/gcj/include Hello.class natHello.cc --main=Hello -o hello
$ ./hello
i[0] = 0
i[1] = 1
i[2] = 2
i[3] = 3
i[0] = 0
i[1] = 1
i[2] = 2
i[3] = 3
1
2
3
4
I tried to look at build_array_ref in both cp and java. I don't understand how
and why they are different, so I am stuck at this point.
--
Jeff Sturm
jeff.sturm@commerceone.com