This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [patch] Fix PR23230 - wrong code generated in inner class
- From: Ranjit Mathew <rmathew at gmail dot com>
- To: Robin Green <greenrd at greenrd dot org>
- Cc: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Sun, 07 Aug 2005 10:36:34 +0530
- Subject: Re: [patch] Fix PR23230 - wrong code generated in inner class
- References: <20050805152201.GA6662@pob>
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? Stuff like this can very easily
introduce miscompilations (and was the reason I withdrew my own
patch for PR19870 Part 2, by the way).
Jacks is most likely not the place for such a testcase - AFAICT, they
only check for compilation success, error or warning. A better place
would be the libjava testsuite's "libjava.lang" sub-testsuite. A simple
testcase that reproduces the problem for me is:
------------------------------- 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.
--
Ranjit Mathew Email: rmathew AT gmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.hostingzero.com/