Bug 17691 - error on valid java code from freenet
error on valid java code from freenet
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: java
3.4.2
: P2 normal
: 4.3.0
Assigned To: Not yet assigned to anyone
: rejects-valid
Depends on: 28067
Blocks: 18131
  Show dependency treegraph
 
Reported: 2004-09-27 12:36 UTC by Ruben Garcia
Modified: 2007-01-09 20:46 UTC (History)
2 users (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail: 4.0.0 3.4.3
Last reconfirmed: 2004-09-27 13:27:55


Attachments
Test case (with int x() in both A and B) (111 bytes, text/x-java-code)
2004-09-27 12:38 UTC, Ruben Garcia
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ruben Garcia 2004-09-27 12:36:11 UTC
>cat a.java

class A {
int x (){
return 0;
}
}
class B extends A {
int y(){
B.super.x();
return 0;
}
}

>javac a.java
#no error

>gcj a.java
a.java:8: error: '(' expected.
   B.super.x();
          ^
1 error

I know it is not good to use another compiler to check for validity of code.
Nevertheless, I looked this up and it is valid code according to Sun.
I can't find the reference now.
The super in this example is redundant, but it wouldn't be if B had an x() method.

The errors are the same in either case.

This is needed to compile freenet/crypt/ThrottledAsyncEntropyYarrow.java

Please check
Comment 1 Ruben Garcia 2004-09-27 12:38:19 UTC
Created attachment 7224 [details]
Test case (with int x() in both A and B)
Comment 2 Andrew Pinski 2004-09-27 13:27:55 UTC
Confirmed.
Comment 3 Mark Wielaard 2004-09-27 22:14:20 UTC
A workaround is to change B.super.x() to just super.x().
Comment 4 Ruben Garcia 2004-09-28 09:10:02 UTC
The workaround does not work when in an inner class. This was the original problem.

>cat a.java

class A {
    int x() {
        return 0;
    }
}
class B extends A {
    int x(){
        return 1;
    }
    class C {
        int y(){
            return B.super.x();
        }
    }
}

>javac a.java

#no error

>gcj a.java
a.java:13: error: 'class' or 'this' expected.
            return B.super.x();
                        ^
1 error
Comment 5 Ruben Garcia 2004-09-28 09:13:22 UTC
(In reply to comment #4)

This might be a completely unrelated bug; at least the error message is different.
Comment 6 Mark Wielaard 2004-09-29 22:44:47 UTC
Then a workaround is:

class A
{
  int x()
  {
    return 0;
  }
}

class B extends A
{
  int x()
  {
    return 1;
  }

  // Extra workaround method
  int ax()
  {
    return super.x();
  }

  class C
  {
    int y()
    {
      return ax();
    }
  }
}

But this is getting silly indeed.
It is a real bug that mist be fixed.
Comment 7 Tom Tromey 2007-01-09 20:46:31 UTC
All gcj front end bugs have been fixed by the gcj-eclipse branch merge.
I'm mass-closing the affected PRs.
If you believe one of these was closed in error, please reopen it
with a note explaining why.
Thanks.