Freenet compilation errors.
Mark J. Roberts
mjr@statesmean.com
Sat Jan 6 20:18:00 GMT 2001
On Sun, 7 Jan 2001, Bryce McKinlay wrote:
> Bryce McKinlay wrote:
>> > > I'm asking
> > > our local Java Gods what's up with the three super()/this errors.
> >
> > This one is definatly a bug in gcj. Its illegal to use a classes own "this" before calling the superclass constructor, however it should be perfectly okay to reference a "this"
> > from an enclosing context. I'm going to look into this.
>> I submitted a patch for this which is awaiting approval:
>> http://gcc.gnu.org/ml/gcc-patches/2001-01/msg00479.html
>> Please try this and let me know if it fixes the problem you were seeing.
I'm compiling as we speak.
I found another bug. It emerges in our Key.java:
protected Key(byte[] val) {
this.val = val;
}
private boolean isGreater(Key k) {
for (int i = 0 ; true ; i++) {
if (i == k.val.length)
return false; // k is equal or smaller
else if (i == val.length)
return true;
else if (val[i] < k.val[i])
return true;
else if (val[i] > k.val[i])
return false;
}
}
gcj complains that there is no return statement in isGreater. Sun's javac
doesn't mind because eventually i will equal val.length.
I tried to write a test case for this:
public class Test {
static byte b[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
public static void main(String[] args) {
for (int i = 0 ; true ; i++)
if (i == b.length) return;
}
}
It did not produce an error and ran fine. So I tried again, with a
different approach:
public class Test {
private byte b[];
public static void main(String[] args) {
return;
}
protected Test(byte[] b) {
this.b = b;
}
private boolean testMe() {
for (int i = 0 ; true ; i++)
if (i == b.length) return false;
}
}
and got the error:
[root@rm03-24-131-185-22 /freenet]# gcj -o test --main=Test Test.java
Test.java: In class `Test':
Test.java: In method `testMe()':
Test.java:15: Missing return statement.
}
^
1 error
javac compiled and ran it fine.
--
Mark Roberts
mjr@statesmean.com
More information about the Java
mailing list