This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix PR23230 - wrong code generated in inner class


On Sun, Aug 07, 2005 at 10:36:34AM +0530, Ranjit Mathew wrote:
> Robin Green wrote:
> > This one-liner fixes PR java/23230 by saying "if the inner class has a matching
> > method, don't call a matching method in an outer class." In other words, always
> > use the innermost scope.
> > 
> > Tested against libjava/testsuite and jacks - no new failures (or passes). I'll
> > submit a new test case to jacks.
> 
> Just to be sure, you did a *clean* build of libjava and then a testsuite
> run with Jacks included, right?

Not quite. I did a clean build, yes, but Jacks was skipped in the testsuite
(because it wasn't on the PATH I assume). However, I ran Jacks myself, and did
"diff -u gcj.log.orig gcj.log". No changes. So I think that is OK.

> Jacks is most likely not the place for such a testcase - AFAICT, they
> only check for compilation success, error or warning.

That's not the case. There are runtime tests as well. It is a JLS test not a
test of any specific API, so it should go in Jacks, I think - but I will
double-check on that when I submit it.

> A better place
> would be the libjava testsuite's "libjava.lang" sub-testsuite. A simple
> testcase that reproduces the problem for me is:

Thanks! My patch works for this test case. Please could you grant me
permission to submit a massaged version of that to Jacks under the GPL.

> ------------------------------- 8< -------------------------------
> class Snafu
> {
>   public void whoami( )
>   {
>     System.out.println( this.getClass( ).getName( ));
>   }
> }
> 
> public class PR23230 extends Snafu
> {
>   class Foo extends Snafu
>   {
>     Foo( )
>     {
>       whoami( );
>     }
>   }
> 
>   void bar( )
>   {
>     new Foo( );
>   }
> 
>   public static void main( String[] args)
>   {
>     new PR23230( ).bar( );
>   }
> }
> ------------------------------- 8< -------------------------------
> 
> This currently prints "PR23230$Foo" when compiled with Jikes or
> javac, but only prints "PR23230" when compiled with "gcj -C".
> 
> Thanks,
> Ranjit.

Regards,
-- 
Robin

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]