Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Method calls on arrays assigned to java.lang.Object

37 views
Skip to first unread message

Ming-Ho Yee

unread,
Mar 8, 2014, 4:55:00 PM3/8/14
to
The Joos Languages page says that array method calls are not supported:

public class A {
public void m() {
int[] x = new int[42];
x.clone(); // Not supported in Joos
}
}

However, array types are subclasses of java.lang.Object, and furthermore, can be assigned to the java.lang.Object type.

I suspect that the following is valid, since I can't find anything that rules it out, but I'd like some confirmation.

public class A {
public void m() {
int[] x = new int[42];
Object o = x;
o.toString(); // Is this valid Joos?
}
}

Ondřej Lhoták

unread,
Mar 8, 2014, 10:09:32 PM3/8/14
to
On Sat, Mar 08, 2014 at 01:55:00PM -0800, Ming-Ho Yee wrote:
> The Joos Languages page says that array method calls are not supported:
>
> public class A {
> public void m() {
> int[] x = new int[42];
> x.clone(); // Not supported in Joos
> }
> }

Correct: this is not allowed in Joos.

> However, array types are subclasses of java.lang.Object, and furthermore, can be assigned to the java.lang.Object type.
>
> I suspect that the following is valid, since I can't find anything that rules it out, but I'd like some confirmation.
>
> public class A {
> public void m() {
> int[] x = new int[42];
> Object o = x;
> o.toString(); // Is this valid Joos?
> }
> }

Correct: this is allowed in Joos. However, you should not need to worry
about it until you get to code generation, Assignment 5.

0 new messages