Re: [abc] Jastadd compile bugs

From: Pavel Avgustinov <pavel.avgustinov@magdalen.oxford.ac.uk>
Date: Thu Jan 12 2006 - 15:14:35 GMT

Neil Ongkingco wrote:

> I've attached one more jastadd bug. Note that the comments are just my
> best guesses on what the problem is, as I haven't really tried to
> debug the jastadd compiler code yet. As with the other examples, this
> compiles fine in both javac and abc.

Comments beneath the example code.

>
> I'm getting the impression that there seems to be a good number of
> bugs that need fixing, and that it may not as yet be worth moving to
> jastadd. There are still some bugs that I haven't isolated yet
> (including a rather strange one that says "primitive.Illegal is not
> assignable to a variable of type primitive.Unknown"), so there may be
> more to come.

Anything involving primitive.Unknown is, in my experience, down to an
unresolved class -- jastadd tries to continue gracefully, but usually
produces hundreds of bogus errors instead. Determine which class the
primitive.Unknown corresponds to and make sure it's on your classpath.

>import java.util.*;
>
>class ArrayTest {
> public static void main(String args[]) {
> byte[] row = new byte[10];
> Vector v = new Vector(10);
> byte[][] varr = new byte[10][];
> //jastadd seems to have a problem with n-dim arrays, n>1.
> v.copyInto(varr);
>
> //jastadd compiles 1D arrays fine
> Vector v2 = new Vector(10);
> Integer[] v2arr = new Integer[10];
> v2.copyInto(v2arr);
> }
>}
>
>
The signature of copyInto is 'void copyInto(Object[] anArray)'. It seems
that abc and javac interpret 'byte[]' as a subtype of Object, whence
'byte[][]' is a subtype of 'Object[]'. This seems, to say the least,
counterintuitive to me -- but
http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html#40879
suggests Object is indeed meant to be the direct supertype of any array
type. As such we can boil down the example even further:

public class Test2 {
    public static void main(String[] args) {
        Object[] o = new byte[10][10];
    }
}

JastAdd then complains that byte[][] isn't assignable to Object[].
Interestingly, it correctly assigns byte[] to Object.

Actually, this may be a spec ambiguity --
http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html#40879
says "The direct superclass of an array type is Object", in other words
the superclass of byte[][] is Object, not Object[].

Two brief experiments confirm that both javac and jastadd accept 'Object
o = new byte[2][2];', and javac also accepts 'Object o[] = new
byte[2][2];'. It's a matter of interpretation of the spec -- but again,
the de-facto spec is javac, so this should probably be reported as a bug.

- P
Received on Thu Jan 12 15:14:46 2006

This archive was generated by hypermail 2.1.8 : Fri Jan 13 2006 - 11:50:09 GMT